'JMS JMSCC3032 exception

I use IBM MQ. I upgraded the com.ibm.mq jar in my application from 7.5 to 9.1.1.0 as:

<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.allclient</artifactId> 
<version>9.1.1.0</version>

My consumer that is receiving messages from topic started to get error JMSCC0111.

As I read this is new behavior in the JMS libraries above version 8.0 where by default a JMS ID can not be reused. As a solution I set clientId on connection as below. I'm getting connection from ConnectionFactory.

public Connection getConnectionWithUuid() throws JMSException {
    Connection connection = connFactory.createConnection();
    String uid = UUID.randomUUID().toString();
    connection.setClientID(uid);
    connection.start();
    return connection;
}

Now I started to get exception:

JMSCC3032: Resetting the client ID is not allowed.
Connection jmsConnection = null;
Session jmsSession = null;
MessageConsumer consumer = null;
MessageProducer producer = null;
try {
    jmsConnection = QueueManager.getInstance().getConnectionWithUuid();
    jmsSession = jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Destination responseTopic = QueueManager.getInstance()
            .getDestination(this.parameters.getResponseTopicName());
    Destination outGoingQueue = QueueManager.getInstance()
            .getDestination(this.parameters.getOutGoingQueueName());
    consumer = jmsSession.createConsumer(responseTopic);
    producer = jmsSession.createProducer(outGoingQueue);
    TextMessage requestMessage = jmsSession.createTextMessage(request);
    requestMessage.setJMSCorrelationID(parameters.getSessionId());
    producer.send(requestMessage);
    logMessage("OutGoing Message:\n", requestMessage);
    String response = null;
    long begin = System.currentTimeMillis();
    while (response == null && System.currentTimeMillis() - begin < protocolTimeoutSecs * 1000) {
        Message responseMessage = consumer.receive(protocolTimeoutSecs * 1000);

On the last line (consumer.receive) it throws JMSCC3032.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source