Skip to content
Advertisement

Customize the automatic reconnection settings to IBM MQ

I have written a code to connect to IBM MQ, and i am using ConnectionNameList which automatically reconnects to ibm mq.

I want to customize the reconnection which is happening implicitly. I have referred many articles on the internet but i am not able to figure it out.

This is my Queue Manager Config:

JavaScript

When i stop the queue manager, i get the following exceptions every 5 seconds:

JavaScript

So i want that first 3 reconnection attempts should be a warn messages instead of error message as shown in above logs and 4th attempt onwards i want it to be an error message. and reconnection attempt to be every 10/15 seconds.

How do i configure these re-connection settings ?

Any help would be greatly appreciated ! Thanks !

EDIT: I have added an exception listener as follows:

JavaScript

Now My logs are as follows:

JavaScript

I dont want the default message listener container log to be printed onto console. how do we achieve that ?

Advertisement

Answer

I would add that the 5 second interval reconnect attempts are the DefaultMessageListenerContainer trying to reconnect. The default reconnect interval is 5 seconds – DEFAULT_RECOVERY_INTERVAL, so I’m not thinking that this involves the MQ reconnect mechanism.

With the exception handler listed above in place, you could programatically change the DefaultMessageListenerContainer setRecoveryInterval() or use setBackOff() to control the backoff interval.

As to disabling the logging, setting the log level for the DefaultMessageListenerContainer to FATAL should do it.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement