Previous Topic: JMS MessageNext Topic: Test the JMS Send Receive Step


JMS Correlation Schemes

Consider a messaging service with two clients that are running simultaneously. Each client can send a request message to the same request queue. The service can process the requests in any order and can send the response messages to a response queue. How does each client receive its own response and not receive the response that is meant for the other client?

The most common solution is to incorporate some type of identifier into the request, and copy the identifier into the response. This identifier is known as a correlation ID. Each client uses a unique correlation ID. Some mechanism is used to ensure that each client can only receive a response containing the correlation ID for that client.

You can enable correlation in the JMS Send Receive step. The following correlation schemes are available:

Correlation schemes differ based on:

JMS Correlation ID

Most messaging platforms have a correlation ID field. In this scheme, the client generates a unique ID and sends a request message containing that ID in the correlation ID field. Before the service sends the response message, the service copies the correlation ID from the request message to the response message. The client listens for a response message that contains the same correlation ID as the original request.

By default, the correlation ID is automatically generated. To specify the value manually, use the Manual Value field.

The Reuse ID list indicates whether to generate a new correlation ID for each new transaction or use the same correlation ID throughout the test.

JMS Message ID to Correlation ID

This scheme is similar to the JMS Correlation ID scheme.

Most messaging platforms also have a message ID field, which contains a unique identifier for the message. The message ID is automatically generated.

Before the service sends the response message, the service copies the message ID of the request message to the correlation ID of the response message. The client listens for a response message that contains a correlation ID that matches the message ID of the original request.

You cannot specify the message ID manually. You cannot reuse message IDs.

JMS Payload

This scheme is based on a correlation ID that is embedded in the payload of the request and response messages. The scheme has an associated payload scheme that controls how the correlation ID is embedded. The default payload scheme lets you define XPath expressions for obtaining the correlation ID from the messages.

The following graphic shows an example of the JMS Payload correlation scheme with the XPath payload scheme.

Screen capture of JMS Payload correlation scheme with XPath payload scheme.

The Reuse ID list indicates whether to generate a new correlation ID for each new transaction or use the same correlation ID for the duration of the test.

You cannot mix the JMS Payload correlation scheme with the other two correlation schemes on the same queue. If one listener is listening on a queue with the JMS Payload correlation scheme, then all listeners on that queue must be using JMS Payload. However, you can use JMS Correlation ID and JMS Message ID to Correlation ID as payload schemes for the JMS Payload correlation scheme.