In JMeter, I have a JMS Publisher sampler configured to send a message to a remote queue. The message gets successfully published to the remote queue running on an ActiveMQ Artemis server and in the View Results Tree listener (Request -> Request Headers) I can see some JMS properties (which I set in the JMS Properties section of the JMS Publisher sampler). However, some of these header properties I see, I have never set (They are implicitly set by the JMS Publisher sampler): JMSMessageId, JMSTimestamp, JMSType, JMSExpiration.
JMSMessageId looks like this:
JMSMessageId ID:ip-100-100-100-100.eu-west-1.compute.internal-44444-1111111111111-2:2:2:1:1
I understand that this JMSMessageId header gets generated at runtime and its generation rules depends on the JMS vendor. It may only be unique for the current installation of the message server, or it may be universally unique.
I would like to know if I could get the value of the JMSMessageId property after it's generated and use it as a value for another JSM Property named JMSCorrelationID, before the message is published.
In order to get the JMSMessageID
that's generated for the message by the provider you need to invoke getJMSMessageID()
. However, in order to use this value for another header or property on the message you'd have to invoke this method before the message is sent. The problem is that the provider-assigned value for JMSMessageID
is not available until after the message is sent. The JavaDoc for getJMSMessageID()
states:
When the
send
orpublish
method returns, it contains a provider-assigned value.
Therefore, you can't use the JMSMessageID
for any other header or property value on the same message.