Pattern: Message Router (Communication Hub)
Description
The Message Router pattern is an integration pattern where a central component receives messages (or events) from various publishers and routes them to the appropriate channels (Email, SMS, PDF, Push) without the publishers needing to know the details of the delivery mechanism.
In WepNG, this is implemented via CommunicationBiz.
Context in WepNG
- Module:
Common/CommunicationBiz. - Usage: When an Order is confirmed,
OMGTcallsCommunicationBizto "Send Confirmation".CommunicationBizdecides:- Which template to load.
- Whether to generate a PDF attachment.
- Whether to send SMS or Email or both.
Benefits
- Decoupling: Business logic (Booking) doesn't know about SMTP servers or SMS Gateways.
- Centralization: All templates and communication logs are in one place.
Risks (Circular Dependency)
- The Trap: If the Router needs to read data back from the Business Entities to render the template (e.g.,
Router->OrderOMGT), andOrderOMGTcallsRouter, you have a Circular Dependency. - Solution: The Router should only accept DTOs (Data Transfer Objects) full of data, or use a "Pull" mechanism via an abstract Interface (
ICommunicable), avoiding strict reference to the OMGT module.