C
C#16mo ago
M B V R K

❔ Is it Possible to Consume a Queue Message by Multiple Consumers ( RabbitMQ & MassTransit ) ?

Hi friends, I'm working on a project using Microservices architecture, I have AuthService, ExpenseService and EventSourcererService, the last one is used as a separated service for Event-Sourcing for all other services. When a nnew User created in the AuthService a message will be published to the AuthService-UserCreatedEventQueue Queue, inside the ExpenseService I have a consumer who configured to consume the messages in that queue, inside the EventSourcererService I have an other consumer who also configured to consume the published messasges in the AuthService-UserCreatedEventQueue Queue. The issue: When the user created only one consumer who get triggered and the other not. For example when a user created the consumer in the ExpenseService do his job by consuming that message, but the EventSourcererService's consumer not triggered. I knew later that using MassTransit and RabbitMQ only one Consumer who can consume the message in a queue. So please from your experience how do I can consume the same message from the same queue by multiple consumers ? And maassive thanks in advance <3
13 Replies
Tvde1
Tvde116mo ago
make another queue the publisher shall publish to a topic, and rabitmq will put the message in the queue for every subscription
M B V R K
M B V R KOP16mo ago
Is thiis means that every Queue's messages can only consumed by one and only one Consumer ??
Tvde1
Tvde116mo ago
yes, that's how you want it in case you have multiple instances of a microservice and each instance should receive a message, each instance should make a (temporary) queue
M B V R K
M B V R KOP16mo ago
So the solution is to make a Queue for every service who it's Consumer should consumes that message???
Tvde1
Tvde116mo ago
MassTransit will do this for you If you have multiple consumers/instances/microservices, each consumer should make its own queue. The exception is, that let's say, you have 3 of the same microservice running, and you only need an event to be handled once (3 times is unnecessary), then you can share one queue
M B V R K
M B V R KOP16mo ago
omg I didn't understood this one, could you please simply re-explain it if you have time I have a shitty brain
Tvde1
Tvde116mo ago
Multiple Workers, Each with Its Own Queue: - When you have several workers that should each do their own thing and not interfere with each other, you give each worker its own queue. - This is like giving each worker a separate to-do list. They can work independently without stepping on each other's toes. Multiple Workers of the Same Kind: - If you have many identical workers (like 3 copies of the same program) and you only want one of them to handle a particular task, you can use a shared queue. - This is like having a single to-do list that the identical workers look at. One worker takes a task, and the others see that it's already done and move on.
M B V R K
M B V R KOP16mo ago
more understandable now, I really appreciate
Tvde1
Tvde116mo ago
Read https://masstransit.io/documentation/transports/rabbitmq carefully ^^ These docs contain a lot of information, it's hard to read, but if you understand it, it's amazing
RabbitMQ Transport
RabbitMQ is an open-source message broker software that implements the Advanced Message Queuing Protocol (AMQP). It is written in the Erlang programming language and is built on the Open Telecom Platform framework for clustering and failover.
M B V R K
M B V R KOP16mo ago
so the solution is to make a Queue for each Consumer right ?
Tvde1
Tvde116mo ago
yes
M B V R K
M B V R KOP16mo ago
Massive thanks my bro, really appreciate <3
Accord
Accord16mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server