Use JMS 2.0 to use delivery delay with IBM MQ

I'm using IBM MQ with Spring Boot and I'm trying to delay messages with the setDeliveryDelay(time) method. This function is only supported in JMS 2.0 and I'm having problems with this, as I am running with JMS 1.1 and I cannot figure out how to upgrade to 2.0

I'm using this dependency

implementation(group: 'com.ibm.mq', name: 'mq-jms-spring-boot-starter', version: '2.6.2')

and creating this bean:

@Bean("mqTemplate")
public JmsTemplate jmsClient(ConnectionFactory connectionFactory) throws JMSException {
    System.out.println(connectionFactory.createConnection().getMetaData().toString());
    JmsTemplate temp = new JmsTemplate(connectionFactory);
    return temp;
}

Then I simply set the delay and send the message:

jmsTemplate.setDeliveryDelay(101010);
jmsTemplate.convertAndSend(queue, message);

At startup I can see this:

|   com.ibm.msg.client.jms.internal.JmsConnectionMetaDataImpl@71f29d91  :-  
|   |   XMSC_JMS_MAJOR_VERSION     :-  1
|   |   XMSC_JMS_MINOR_VERSION     :-  1
|   |   XMSC_JMS_VERSION           :-  1.1
|   |   XMSC_MAJOR_VERSION         :-  6
|   |   XMSC_MINOR_VERSION         :-  0
|   |   XMSC_OBJECT_IDENTITY       :-  1911725457
|   |   XMSC_PROVIDER_NAME         :-  IBM MQ
|   |   XMSC_VERSION               :-  6.0
|   |   XMSC_WMQ_COMMAND_LEVEL     :-  910
|   |   XMSC_WMQ_PROVIDER_VERSION  :-  6.0.0.0

And as you can see the XMSC_JMS_VERSION is 1.1 and when I try to send to the queue I get the following error:

JMSCC5008: Use of the JMS2.0 Function 'Delayed Delivery' is not supported with this instance of this connection

This makes sense since I'm not using JMS 2.0, but can I change the JMS version from 1.1 to 2.0?


Solution 1:

Make sure the SVRCONN you connect to has a SHARECNV value of 1 or higher, if it is set to 0 the client will treat the queue manager being connected to as a v6 queue manager which didn't support JMS 2.0 features including delayed delivery, shared subscriptions. It also does not support IBM MQ auto reconnect logic and bidirectional heart beat messages.

Solution 2:

Just continuing the conversation, but I'd like to do some formatting...

I change my maven dependency from:

    <dependency>
        <groupId>com.ibm.mq</groupId>
        <artifactId>com.ibm.mq.allclient</artifactId>
        <version>9.1.0.6</version>
    </dependency>

to:

    <dependency>
        <groupId>com.ibm.mq</groupId>
        <artifactId>mq-jms-spring-boot-starter</artifactId>
        <version>2.6.2</version>
    </dependency>

This still resulted in:

com.ibm.msg.client.jms.internal.JmsConnectionMetaDataImpl@70988f36  :-
XMSC_IS_Z_SERIES           :-  false
XMSC_JMS_MAJOR_VERSION     :-  2
XMSC_JMS_MINOR_VERSION     :-  0
XMSC_JMS_VERSION           :-  2.0
XMSC_MAJOR_VERSION         :-  8
XMSC_MINOR_VERSION         :-  0
XMSC_OBJECT_IDENTITY       :-  1889046326
XMSC_PROVIDER_NAME         :-  IBM MQ JMS Provider
XMSC_VERSION               :-  8.0.0.0
XMSC_WMQ_COMMAND_LEVEL     :-  910
XMSC_WMQ_PROVIDER_VERSION  :-  8.0.0.0

With text message properties:

JMSMessage class: jms_text
JMSType:          null
JMSDeliveryMode:  1
JMSDeliveryDelay: 0
JMSDeliveryTime:  0
JMSExpiration:    0

I have no idea how XMSC_VERSION can get set to 6.0. I don't see an option on the client code or in anything like mqclient.ini.

Hopefully helpful.