javax.jms.JMSException: MQJMS2002: failed to get message from MQ queue

I have a asynchronous JMS receiver coded thus (obvious details missing):

connection = connectionFactory.createConnection();
connection.setExceptionListener(new ExceptionListener() {
    @Override
    public void onException(JMSException ex) {
        logger.info("JMS exception " + ex.getMessage());
    }
});

session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
consumer = session.createConsumer(queue);
consumer.setMessageListener(listener);
logger.info("Waiting for a message");
connection.start();

Everything starts up nicely, but when a message arrives I get a JMSException which the ExceptionListener picks up. The exception says:

javax.jms.JMSException: MQJMS2002: failed to get message from MQ queue.
at com.ibm.msg.client.wmq.v6.jms.internal.ConfigEnvironment.newException(ConfigEnvironment.java:374)
at com.ibm.msg.client.wmq.v6.jms.internal.MQMessageConsumer.getMessage(MQMessageConsumer.java:3047)
at com.ibm.msg.client.wmq.v6.jms.internal.MQMessageConsumer.receiveAsync(MQMessageConsumer.java:4042)
at com.ibm.msg.client.wmq.v6.jms.internal.SessionAsyncHelper.run(SessionAsyncHelper.java:507)
at java.lang.Thread.run(Thread.java:662)

The linked exception just says NullPointerException and gives no other details.

I've trawled the web looking for an answer but I am no MQ expert and have got nowhere with this. The middleware people here are not very helpful and getting them to do anything is proving slow and painful. I get the impression it's something to do with queue config but I feel I am clutching at straws.

If anyone has got any suggestions I would be grateful - especially if it is something I can arm myself with and confront middleware :)

I'm using the MQ 7.0.0.2 client jars.

Answers


Embarrassingly I have just found that a bit of the 'obvious' code that I skipped above had a finally block in it that closed the connection shortly after it was opened. Not sure why the error message has to be so vague - telling me that the connection was closed would have saved me hours of head scratching.

Thanks for those that took time to read through my problem!


Along with the exception there might have been a MQ reason code given. That could have been really helpful saving your time.


Need Your Help

Is it possible to use Mono static compilation on Windows?

static mono compilation

I was wondering if it is possible to use Mono static compilation on Windows. If so, what should I do?

Intercepting and Disabling Global Mouse Events

windows winapi mouseevent

I have a problem with my mouse. Every now and then it will double click when I only single click. I know this is a problem with the mouse, and I've contacted the manufacturer, still waiting for a r...

Ajax/Php - Real Time Online User Counter

php ajax counter

I want to have an Online user counter but something which performs real time. I mean when someone comes in, the counter updates, or when someone leaves the site, the counter decrease.