Skip to main content

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, OMGT calls CommunicationBiz to "Send Confirmation". CommunicationBiz decides:
    1. Which template to load.
    2. Whether to generate a PDF attachment.
    3. Whether to send SMS or Email or both.

Benefits

  1. Decoupling: Business logic (Booking) doesn't know about SMTP servers or SMS Gateways.
  2. 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), and OrderOMGT calls Router, 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.