SpinGo / op-rabbit

The Opinionated RabbitMQ Library for Scala and Akka
Other
232 stars 73 forks source link

Application Losing messages when RabbitMQ is not available and the Application crashes during that period #150

Closed AbacusIntegrationPlatform closed 6 years ago

AbacusIntegrationPlatform commented 6 years ago

I am having an issue where RabbitMQ Connection is getting disconnected intermittently. Op-Rabbit is able to recover the connection if it is available for a short period of time as it persists/queues the messages in the actor. But if the application crashes when the rabbit MQ is down, the persisted messages in the Actor is getting lost as it is in-memory persistence. I want this error to be thrown out rather than persisting it in the actor memory. I am using a default publisher as below.

val publisher = Publisher.queue(QName)   
rabbitControl ! Message(jsonString, publisher)
timcharper commented 6 years ago

Publisher confirmations is what you're looking for:

https://github.com/SpinGo/op-rabbit#publish-a-message

AbacusIntegrationPlatform commented 6 years ago

@timcharper Thank you.

I tried with this way given - val received = ( rabbitControl ? Message.queue(jsonmsg,queue = "demoqueue")).mapTo[ConfirmResponse]

Still, if there is a connection failure, it is internally retrying rather than throwing error out. Is there a way to throw the error so that i can send Nack to the source ?