Configuration
Two pieces: point a Messenger transport at the BabelQueue serializer, and map inbound URNs to your message classes.
Messenger transport
Set the transport’s serializer to babelqueue.messenger.serializer. Routing and
retry stay exactly as Messenger defines them.
# config/packages/messenger.yaml
framework:
messenger:
transports:
babel:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%' # e.g. amqp:// or redis://
serializer: 'babelqueue.messenger.serializer'
routing:
'App\Message\OrderCreated': babel
buses:
messenger.bus.default:
middleware:
# Forward trace_id from a handled message to any it dispatches,
# so a chain of work stays in one trace.
- 'babelqueue.messenger.trace_middleware'
URN ↔ message-class map
To consume, the adapter needs to turn an inbound URN back into one of your
message classes. Declare the mapping, plus the default queue written to the
envelope’s meta.queue:
# config/packages/babelqueue.yaml
babelqueue:
queue: 'orders' # written to the envelope meta.queue
messages: # urn => message class (needed to consume)
'urn:babel:orders:created': 'App\Message\OrderCreated'
Producing only needs the message to declare its own URN (see Producing messages); the registry is what lets a consumer route an inbound envelope back to a class.
The trace middleware
babelqueue.messenger.trace_middleware (added to the bus above) attaches the
inbound trace_id to the message as a BabelTraceStamp and ensures any message a
handler dispatches inherits that trace_id — so end-to-end tracing needs no
manual plumbing. It is optional but recommended.
Next: Producing messages.