Message Routing

COMP 310    Java Resources  Eclipse Resources

Routing of messages to chatrooms isn't necessary!

A common question is how to make sure that messages sent from one chatroom end up at the correct destination chatroom?  This issue comes up in both fully-connected-graph type distributed chatroom architectures as well as star-topology chatroom architectures.   A frequent solution is to tag every message with a chatroom ID, send it (and all other messages from all other rooms) to a common message handler (the RMI server end) on the receiving application, which then first interprets the message to figure out the chatroom ID and then routes the message on to the appropriate room.   There is a false sense of simplicity here because there is only one message receiving object but this is at the cost of added routing complexity that couples the chatrooms together.

But routing is not necessary to achieve the same end.  Since the message is originating from a particular chatroom, why not simply send it to directly the corresponding chatroom on the receiving application?    Instead of having a single message receiver, simply have one receiver per chatroom.   Messages can now be sent directly from one chatroom to its associated room without any routing.   Messages do not have to be tagged with a chatroom ID because they are only ever going to that room.   Plus, the fundamental decoupling of the mini-model architecture of chatrooms is preserved.   No global management of messages is needed.  The cost of  the addtional RMI server objects far outweighs the cost of maintaining the routing management.  By respecting the encapsulation and decoupling of the chatrooms, global management is restricted to only operations of creating and deleting entire chatrooms and nothing concerning anything internal to the chatrooms, such as its messages.

In the following diagrams, we see the differences between routing and non-routing architectures.   Note that the discussion is still valid even if the sending room is not technically the same sort of entity as the receiving room, as would happen in star-topology chatroom implementations.

Message routing architectures

© 2020 by Stephen Wong