Websphere MQ asynchronous put not working

2019-09-17 16:02发布

问题:

We have an application using Websphere MQ v.7.0.1. The server is on linux, the client application runs on Windows 7 and is written in Java using the MQ classes for java. One of the queues between the client and the server is exclusively for a keepalive protocol between the client and the server. For a variety of reasons we don't need to go into, this is necessary to maintain connections to the "real back end" of which the MQ server is only a part.

The Keepalive protocol works reasonably well except in the instance when one of the servers goes down and the clients need to reconnect to it when it becomes available. Then we have problems.

We have decided that our implementation of the keepalive protocol is much too complicated. The client only needs to send these keepalive messages to the server at a regular interval and need not care if they reach the server or not. If they don't, the server will take
appropriate action.

Therefore, an asynchronous put suggests itself. Our first attempt at implementing it was as follows:

from this:

MQPutMessageOptions pmo = new MQPutMessageOptions();  // accept the defaults
QueueKL.put(mqMessage,pmo);                                             

to this:

MQPutMessageOptions pmo = new MQPutMessageOptions();                    
pmo.options |= CMQC.MQPMO_ASYNC_RESPONSE;                               
QueueKL.put(mqMessage,pmo); 

The results were an unpleasant surprise. Instead of returning immediately, the put call never returns and the thread from which it was called never shows another sign of life.

Of course this call is launched in a try-catch block and we've tried to catch as a last resort any possible Throwable that could be thrown i.e. catch (Throwable t) and log it. Nothing of the sort is logged. The thread appears to be blocked there at this point, the exact opposite of what I expected to happen.

I must be missing something critical in how I am implementing this
call, (is some special setup required in the Queue or QueueManager? The IBM docs are aggravatingly sparse here) but I don't know what that is. Please help me get to the bottom of this.

回答1:

Does this help? Are you at 7.0.1.8 by any unlucky chance?

http://www-01.ibm.com/support/docview.wss?uid=swg1IC85084

"This issue also affects users of the WebSphere MQ classes for Java who are putting messages to a WebSphere MQ queue specifying MQPMO_ASYNC_RESPONSE in the PUT Message Options (MQPMO) structure."

Try ensuring the client side is at 7.0.1.9 or 7.1.0.2 or higher