Back to Catalog
Integration
Messaging Endpoints
Messaging Gateway
Hide all messaging plumbing behind a clean domain API — callers never touch the broker.
Intent & Description
Real-world Use Case
NotificationGateway wraps all messaging infrastructure for the notification domain. Application code calls gateway.sendEmailNotification(userId, template, data). Gateway constructs the message, picks the right channel, attaches traceId, and publishes. Application never sees SQS or Kafka.
Source
📌 TL;DR
Messaging Gateway = clean API wrapper for your broker. Business code talks domain, gateway talks broker. Swap brokers by changing one class, not 50 call sites.
Advantages
- Application code is clean from messaging infrastructure concerns
- Broker can be swapped without touching business logic
- Gateway is the single place to enforce messaging standards (headers, tracing, serialization)
- Easy to mock in tests — just mock the gateway interface
Disadvantages
- Additional abstraction layer to build and maintain
- Gateway can hide important messaging behaviors from developers
- Overly generic gateways can become kitchen-sink classes
- Debugging requires understanding both the gateway and the broker