For example, if there's a network outage and your producer loses connection to your RabbitMQ broke, how can you prevent messages from being black holed that need to be queued up? I have a few ideas one of them being to write all your messages to a local db and remove them once they're acked and periodically resend after some time period, but that only works if your connection factory is set to have the publisher confirm.
-
What is the source of your messages? – Gary Russell Apr 01 '15 at 07:43
-
I'm just generating messages from my test application to simulate event logging. I'm essentially trying to create a durable producer. Is there a way to detect when you can reconnect to RabbitMQ also? I see there's a ConnectionListener interface, but it seems you cannot send messages to flush an internal queue in the ConnectionListener. – 2Real Apr 01 '15 at 07:53
1 Answers
I'm just generating messages from my test application to simulate event logging. I'm essentially trying to create a durable producer. Is there a way to detect when you can reconnect to RabbitMQ also? I see there's a ConnectionListener interface, but it seems you cannot send messages to flush an internal queue in the ConnectionListener.
If you have a SimpleMessageListenerContainer
(perhaps listening to a dummy queue) it will keep trying to reconnect (and fire the connection listener when successful). Or you can have a simple looper that calls createConnection()
on the connection factory from time-to-time (it won't create a new connection each time, just return the single shared connection - if open); this will also fire the listener when a new connection is made.
You can use transactions instead of publisher confirms - but they're much slower due to the handshake. It depends on what your performance requirements are.

- 166,535
- 14
- 146
- 179