Working with more than one messages in Actor

HI All,
I am using Dropwizard & Actors to work on messages(RabbitMQ). I had a scenario where working on ‘X’ messages together would be a cost saving. Also the wait time for getting ‘X’ messages should be bounded(lets say 1s) So that the response time shouldnt be affected. Could you let me know how can this be achieved.

Thanks,
Vishal

Hi @vishal1991k,

writing an actor that aggregates messages in a batch (with a limited batch size or a time bound) is a great exercise if you are new to Akka. It’s a very good fit for the actor model. So, to answer your question, “yes, it can be achieved” ;-)

But considering the details of your use case, I think you can also consider using Akka Streams and, in particular, the AMQP Alpakka Connector. Then, what you could do is use RabbitMQ as a Source[Message] and use the groupedWithin operator which will aggregate messages in batches of at most a given size or for as long as a given timeout which is exactly what you are looking for.

Summing up, not only it can be done, but you have two options: (1) using a hand-made actor or (2) using Akka streams.

Cheers,

Thanks @ignasi35 looked into AKKA streams & groupWithin. That is exactly what i require!. Will use and implement it. :)