Guillaume opened SPR-17290 and commented
In my app, I have hundreds of JMS listeners which are plugged on the same topic. I would like these listeners to stop immediately when an error occurs, for example when the JMS provider is down.
I've created my own implementation of org.springframework.util.backoff.BackOff
so that the method nextBackOff always return STOP, and I set that BackOff to all my listeners :
this.jmsContainer.setBackOff(new DisabledBackOff());
The problem is in the DefaultMessageListenerContainer.refreshConnectionUntilSuccessful()
:
BackOffExecution execution = this.backOff.start();
while (isRunning()) {
try {
if (sharedConnectionEnabled()) {
refreshSharedConnection();
This code start the BackOffExecution and then immediately try to recover the connection. Then the method BackOffExecution.nextBackOff()
is called and the recoverring is stopped.
To avoid the first refresh, I've no choice to raise an Exception when this.backOff.start()
is called, but my JMS listener won't be stopped. And it's not a clean solution...
I think nextBackOff
should be called before any refresh is intended.
Or maybe there is another solution ?
Affects: 5.0.9
Comment From: snicoll
If you need the listener to stop immediately and not attempt to recover, a better solution would be to override refreshConnectionUntilSuccessful
and call stop
directly. This will effectively stop the listener when an error occurs.