Reputation: 13486
I'm using RabbitMQ to coordinate events between a collection of services as follows:
user.collect
when it wants user data to be collected from a separate serviceuser.collected
which is emitted by a separate serviceuser.collect
when it is supposed to collect some user data, anduser.collected
when it's collected the data.There are also other services that listen for events like
user.created
,user.updated
,user.deleted
In addition there are services that listen for more general events like
#.created
user.#
and so on.
So I am using a topic
exchange.
| exchange | type | queue | routingKey |
| -------- | ----- | --------------- | -------------- |
| MY_APP | topic | USER_COLLECTION | user.collect |
| MY_APP | topic | USER_COLLECTION | user.collected |
All of the services talk to the exchange called MY_APP
.
The User Manager creates a producer that emits the user.collect
event to the MY_APP
exchange with routingKey
user.collect
, and it creates a consumer that listens on the queue USER_COLLECTION
for events with routingKey user.collected
.
The User Collector creates a producer that emits the user.collected
event to the MY_APP
exchange with routingKey user.collected
and it creates a consumer that listens on the queue USER_COLLECTION
for events with routingKey user.collect
.
However I'm finding that the User Manager emits user.collect
and this is picked up by the User Manager itself with the listener for user.collected
.
It's as if the routingKey is being ignored. What am I doing wrong?
Upvotes: 1
Views: 1713
Reputation: 130
Create different queues for each Consumer and bind queue(s) to topic exchange using appropriate binding key user.collect or user.collected.
Check this link for more detailed examples. https://www.rabbitmq.com/tutorials/tutorial-five-python.html
Upvotes: 1