Skip to content

Instantly share code, notes, and snippets.

@bgener
Last active January 17, 2022 16:14
Show Gist options
  • Save bgener/3606272cd13ebca97f5712e9e1def026 to your computer and use it in GitHub Desktop.
Save bgener/3606272cd13ebca97f5712e9e1def026 to your computer and use it in GitHub Desktop.
rabbitmq-cqrs-topology

Messaging topology The rabbitmq broker is configured as demonstrated below. Key points to note:

commands.fanout exchange is used for routing a command to single queue events.fanout exchange is used for broadcasting the events to all subscribed queues error.fanout exchange collects all unhandled errors, i.e. when the service does not use a dedicated error queue. This is specified on a queue level (x-dead-letter-exchange: error.fanout) or globally via policies audit queue is used to keep track of all the messages sent throught the rabbitmq broker |_commands.fanout |_audit.queue (routing_key=*) |_order.queue (routing_key=createOrder)

|_events.fanout |_audit.queue (routing_key=*) |_order.orderCreated.fanout (routing_key=orderCreated) |_apigateway.queue |_order.orderConfirmed.fanout (routing_key=orderConfirmed) |_apigateway.queue |_notification.queue

|_error.fanout |_error.queue

{
"vhosts": [{
"name": "\/"
},
{
"name": "\/integrationtest"
}
],
"parameters": [],
"policies": [],
"queues": [{
"name": "audit",
"vhost": "/",
"durable": true,
"auto_delete": false,
"arguments": {}
},
{
"name": "error",
"vhost": "/",
"durable": true,
"auto_delete": false,
"arguments": {}
},
{
"name": "order",
"vhost": "/",
"durable": true,
"auto_delete": false,
"arguments": {
"x-dead-letter-exchange":"error"
}
}
],
"exchanges": [{
"name": "error.fanout",
"vhost": "/",
"type": "fanout",
"durable": true,
"auto_delete": false,
"internal": true,
"arguments": {}
},
{
"name": "commands.topic",
"vhost": "/",
"type": "fanout",
"durable": true,
"auto_delete": false,
"internal": false,
"arguments": {}
}
],
"bindings": [{
"source": "commands.topic",
"vhost": "/",
"destination": "audit",
"destination_type": "queue",
"routing_key": "*",
"arguments": {}
},
{
"source": "commands.topic",
"vhost": "/",
"destination": "order",
"destination_type": "queue",
"routing_key": "createOrder",
"arguments": {}
},
{
"source": "error.fanout",
"vhost": "/",
"destination": "error",
"destination_type": "queue",
"routing_key": "*",
"arguments": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment