Kaushlendra Jha
Kaushlendra Jha

Reputation: 396

Need to set JMS_IBM_LAST_MSG_IN_GROUP property to true for IBM MQ testing using JMeter

I am testing IBM MQ using JMeter and able to establish the connection with queue to send requests over it. However, I need to set "JMS_IBM_LAST_MSG_IN_GROUP" property as true for one of the message but unable to do so. I am using below piece of code while sending request or trying to set the property to true but it remains set to it's default value i.e. false when I am checking in backend. Any clue what I am missing here.

Note: Connection is being established in another sampler and making use of that connection here. This code is working fine to send any request, just that property is not getting set to true.

import java.time.Instant
import com.ibm.msg.client.jms.JmsConstants

def sess = System.getProperties().get("Session") 
def destination = System.getProperties().get("Destination")
def producer = sess.createProducer(destination)
def rnd = new Random(System.currentTimeMillis())
def payload = String.format('${groupid}|${sequencenumber}|rest of the payload|')

def msg = sess.createTextMessage(payload) 
println('Payload --> ' + payload)
msg.setBooleanProperty(JmsConstants.JMS_IBM_LAST_MSG_IN_GROUP,true)

def start = Instant.now()
producer.send(msg)
def stop = Instant.now()
producer.close()
SampleResult.setResponseData(msg.toString())
SampleResult.setDataType( org.apache.jmeter.samplers.SampleResult.TEXT) 
SampleResult.setLatency( stop.toEpochMilli() - start.toEpochMilli())

Upvotes: 0

Views: 208

Answers (3)

Kaushlendra Jha
Kaushlendra Jha

Reputation: 396

Sharing as it might help someone else. Was able to set the property to true by making below changes, rest of the code is same as mentioned in original question

import com.ibm.msg.client.wmq.WMQConstants

def gid=String.format('${groupid}')
def msg = sess.createTextMessage()
println('Payload --> ' + payload)
msg.setStringProperty(WMQConstants.JMSX_GROUPID,gid)
msg.setBooleanProperty(WMQConstants.JMS_IBM_LAST_MSG_IN_GROUP,true)
msg.text=payload

Upvotes: 0

Dmitri T
Dmitri T

Reputation: 168122

As per JMS_IBM_LAST_MSG_IN_GROUP chapter of IBMMQ documentation

This property is ignored in the publish/subscribe domain and is not relevant when an application connects to a service integration bus.

In general it's not necessary to use this property, you can come up with your own custom one, i.e. for the producer:

msg.setBooleanProperty("X_CUSTOM_PROPERTY_LAST_MESSAGE",true)

and for the consumer:

msg.getBooleanProperty("X_CUSTOM_PROPERTY_LAST_MESSAGE")

More information: IBM MQ testing with JMeter - Learn How

Upvotes: 0

Morag Hughson
Morag Hughson

Reputation: 7527

Your code does not include anything to set the Group ID or sequence number. I assume we have all the relevant code shown, in which case, I think you are missing code something along these lines:

msg.setStringProperty("JMSXGroupID", groupid);
msg.setIntProperty("JMSXGroupSeq", sequencenumber);

Upvotes: 1

Related Questions