EldoS
MsgConnect home / Documentation / Error and Timeout Handling
Navigation
Web site
Support
Table Of Contents

Since version 1.30 MsgConnect supports message routing. Message routing allows sending messages to receiver via one or more intermediate "nodes" (processes or hosts depending on the transport). Two types of message routing are supported.

1. Routing with routing tables

First type is similar to TCP packets routing, which is done using routers and routing tables. This type of routing is done on transport level. Not all transports support this feature. Currently SocketTransport and HTTPTransport support this type of routing.
When PostMessage/SendMessage* function is called, the Address parameter always contains final destination address. It might be necessary, however, to deliver a message to intermediate node first. This is done by using MCRouter class.
MCRouter allows Messenger to determine the real address, to which the message is sent. The address of the final destination is passed with the message, so intermediate receiver can re-send the message to other receiver. Multi-node routing is supported, however the sender can define only first recipient and final destination.

Example: we send a message from A to B. We specify B as the destination host. MCRouter of host A defines, that all messages sent to B must be sent to C. When C recieves a message for B, it checks where to deliver the message. It can happen that B's MCRouter tells Messenger that messages to B must be sent to D. And finally D will deliver the message to B.

When the message is sent, it's path is also sent together with the message. When the message reply is sent back to original sender, the message will be forwarded in the backward direction as it was received.

Example: in the example above message is processed by B. The reply is sent from B to D where it is sent back to C. And C delivers the reply back to A.

Nodes C and D are intermediate. By default transport can act as an intermediate node, but this is controlled by RoutingAllowed property of the transport. It is not possible to disable routing for nodes A and B in the above example.
When specifying routing rules transport name is specified. This is necessary to define via which transport the message is routed. Due to this it is important to make transports of the same class have the same transport name.

2. Routing using ForwardMessage method

Second type of routing is mesage forwarding. With this type of routing the message is sent to some recipient directly. The recipient decides whether to process the message locally or forward it to another host for processing.

Example: host A sends a message to host B. Host B receives a message via OnMessage event of Queue object. While in OnMessage event handler, host B decides to pass the message to host C. Host B calls ForwardMessage method to forward the message to host C. The message is sent, host B puts the message to the waiting list and returns from event handler. When the reply is sent from C to B, host B resends the reply to host A in background.

Forwarding of messages is an easy way to create multithreaded servers, where one thread receives the messages from clients, handles authentication, connection management and other similar tasks, and other (worker) threads perform actual tasks as requested by the messages.
MsgConnect includes MsgForward demo, which illustrates this approach to building multithreaded servers.

 
Contact Us | Subscribe | Terms of Use | Trademarks | Privacy Statement
Copyright (c) 1998-2005, EldoS Corporation