MQ

 View Only

 Java Service with connection to MQ eventually becomes unresponsive

Ivan Tomasevski's profile image
Ivan Tomasevski posted 09/11/26 03:35 AM

Hello,

I have a Java service which successfully connects to an MQ Queue, successfully sends and receives messages. After a period of about two days of inactivity (no messages incoming or outgoing) my service stops responding to messages. Restarting the service helps, but sometimes not immediately. I assume this a timeout somewhere. Does somebody know where in the documentation I can read about this?

Thank you

Kind regards,

Ivan

Morag Hughson's profile image
Morag Hughson IBM Champion

Are you connected over the network, i.e. a client connection? If so, there are plenty of things that could cause your connection to have been broken. Your program should receive a reason code notifying it of the broken connection, but perhaps the application is not paying attention to that. 

You could keep the channel alive by using client heartbeats, with an interval shorter than that of your firewall timeout. Might be worth setting your SVRCONN HBINT to something shorter than it currently is. I would assume it is currently at the default of 300 seconds, might be better to try something shorter like 60 seconds.

Cheers,
Morag

Ivan Tomasevski's profile image
Ivan Tomasevski

Hello @Morag Hughson

thank you for your response. Yes I am connecting over a client connection. I already thought about using keepAlive heartbeats, I guess I will start implementing them.

SVRCONN HBINT -> where can I find the documentation for this? Do I set this in my program (Java, Spring) or does it need to be set server side?

default of 300 seconds -> does this mean that an inactive connection disconnects after 5 min?

Your program should receive a reason code notifying it of the broken connection -> can you please send me link to the documentation?

Thank you again

Kind regards,

Ivan

Morag Hughson's profile image
Morag Hughson IBM Champion

The SVRCONN is the channel on the queue manager, so yes, you will need to get someone to set this server side.

You can review the documentation here.

The default value of 300 seconds means that if the socket is idle for 5 minutes, then a heartbeat flow will be sent. This 5 minutes is likely way longer than the idle timeout on your firewall, hence you want this heartbeat flow to go more frequently, so setting the 300 seconds down to a lower number like 60 seconds, or even 30 seconds, will mean more frequent heartbeat flows which will keep the channel connection alive and make it less likely that the firewall will close it for being idle. However, it is worth checking with your firewall administrators what they are using as an idle timeout.

You can read about MQRC_BROKEN_CONNECTION here.

Cheers,
Morag

Ivan Tomasevski's profile image
Ivan Tomasevski

@Morag Hughson thank you! Will look over the documentation

Paul Titheridge's profile image
Paul Titheridge

Hi Ivan,

Based on the description, I was wondering if the application has hung or got into a deadlock somehow. Do you know if it is still connected to the queue manager and has an open input/output handle to the queue when it becomes unresponsive, or has it been disconnected?

Thanks,

Paul