Chapter 3

Message Patterns and Architecture

Message Patterns and Architecture

Enterprise Integration Patterns (EIP) define solutions for common messaging challenges. This chapter covers the most important patterns tested in TT1.

Core Messaging Patterns

1. Point-to-Point (P2P)

In point-to-point messaging, a message is sent to exactly one consumer.

  • Use case: Task distribution, work queues
  • Example: Order processing where each order is handled by exactly one worker
  • 2. Publish/Subscribe (Pub/Sub)

    A message is broadcast to all interested subscribers.

  • Use case: Event notifications, real-time updates
  • Example: Price updates sent to all trading terminals
  • 3. Request/Reply

    A sender expects a response from the receiver.

  • Use case: Remote procedure calls over messaging
  • Example: Query a service and receive a result
  • 4. Dead Letter Queue (DLQ)

    Messages that cannot be processed are routed to a DLQ for inspection.

  • Use case: Error handling, debugging
  • Importance: Critical for production reliability
  • Enterprise Integration Patterns (EIP)

    Message Router

    Routes messages to different channels based on content or rules.

    Message Transformer

    Transforms a message from one format to another.

    Message Filter

    Removes unwanted messages from the stream.

    Aggregator

    Combines multiple related messages into a single message.

    Splitter

    Breaks one message into multiple smaller messages.

    Saga Pattern

    Manages distributed transactions across multiple services using a sequence of local transactions, each publishing events to trigger the next.

    Architecture Considerations

    Message Broker vs. Peer-to-Peer

  • Message Broker: Central intermediary (e.g., RabbitMQ, ActiveMQ)
  • Peer-to-Peer: Direct communication (e.g., ZeroMQ)
  • Event-Driven Architecture (EDA)

    Components react to events asynchronously. Benefits:

  • Loose coupling
  • High scalability
  • Better fault isolation
  • Summary

    Mastering these patterns is essential for the TT1 exam. Understand when to apply each pattern and the trade-offs involved.