0
votes

I am pretty new to RabbitMQ, I want to to consume multiple messages from RabbitMQ so that work can be done parallely also sending acknowledgement only when any of the actor has finished it's task so as not to loose messages. How should I proceed, I want to use spring support for AKKA.

Can I use an actor as a consumer or it should be a plain consumer that can consume multiple messages without sending acknowledgement for any of the message or it should be that I have multiple classes/threads working as consumer instantiated to listen a single message at a time than calling actor (but that would be as if it had no actor or parallelism via AKKA model).

1

1 Answers

0
votes

I haven't worked with RabbitMQ per se, but I would probably designate one actor as a dispatcher, that would:

  1. Handle RabbitMQ connection.
  2. Receive messages (doesn't matter if one-by-one or in a batch for efficiency).
  3. Distribute work between worker actors, either by creating a new worker for each message, or by sending messages to a pre-created pool of workers.
  4. Receive confirmation from worker once task is completed and results are committed, and send acknowledgement back to RabbitMQ. Acknowledgment token may be included as a part of worker's task, so no need to track the mappings inside the dispatcher.

Some additional things to consider are:

  • Supervision strategy: who supervises the dispatcher? Who supervises the workers? What happens if they crash?
  • Message re-sends when running in a distributed environment.