Previous Topic

Next Topic

Book Contents

Book Index

JMS

The last example in this guide is JMS. NeoLoad supports various queuing technologies such as ActiveMQ, Rabbit MQ and IBM MQ through the use of custom Actions and its JMS support. These options can be found in the Actions view in the NeoLoad Design perspective. For more information, see Messaging.

The following examples use ActiveMQ and demonstrates sending and receiving items to and from a queue as well as subscribing and unsubscribing to a topic and publishing/receiving updates.

In ActiveMQ we have the following items created: someQueue and someTopic.

In NeoLoad we have created a User Path and dragged the required JMS custom Actions into the Action section of our test. These can be seen below.

The steps have been renamed to be more meaningful, queues are typically first in, first out. In our example, we add 2 items and remove 2 items, however, we have correlated the requests so we can decide the order items are removed from the queue. In order to connect, we enter the following parameters into the "connect" Action.

Depending on the queuing technology being used, "InitialContextFactory", "providerURL" and "ConnectionFactory" will vary. Details can be found in the appropriate MQ documentation. The "jndiPropertes" allows us to map the queue name onto the JNDI equivalent.

In order to send an item, we need to specify the queue, the message type and the message to send, we are also providing an extra parameter (properties) in order to correlate the send with the appropriate receive. The name/value pair in the properties field can be any user-defined text.

The delay is included in this example purely to give enough time see the message on the queue before it is taken from the queue and received by the NeoLoad "receive" Actions.

The "receive" requires the name of the queue, a timeout on how long to wait and the criteria to decide which item to receive from the queue (the jmsSelector). One important thing to note is that the correlation value should be in single quotes, this is unlike the send properties where the quotes are not required.

Once the "receive" has been executed, you can see the items are now dequeued.

In order to test this, we can execute the User Path by selecting the tool bar button and clicking Start checking.

We can see the sends have taken place successfully by looking request/response details in the Check User Path dialog.

Looking at the receives shows us that the messages have been received from the queue correctly and that the "jmsSelector" parameter has allowed us to take the correct items from the queue using the "JMSCorrelationID" value identifier.

The second part of this JMS example shows subscribing to a topic and publishing messages to it, those messages can then be received and the topic unsubscribed. Just like before, we create a User Path and drag the required JMS custom Actions into the Action section of our test. These can be seen below

We connect, subscribe and loop around publishing messages to a particular topic. We can then receive all 5 messages, unsubscribe and disconnect. Like the "connect" above, the JMS settings for the "connect" Action are the same except that we are now connecting to a topic rather than a queue.

The "subscribe" and "unsubscribe" Actions also refer to the topic.

Within our loop, we are publishing messages to the topic. The ${loop_5_times_counter} in the "textContent" refers to the current iteration around the loop, so with 5 iterations, we should publish messages numbered #1 - #5.

Finally, the "receive" Action will download all 5 messages, we unsubscribe and we disconnect using the "disconnect" Action.

To execute the User Path, we select the tool bar button and click Start checking from the Check User Path dialog.

We can see the test executed successfully as every Action has returned "OK".

By selecting the Actions, we can see the requests and responses values, showing items were published and received correctly.

See Also

Why does Component Testing matter?

So, how is it done?

It functions, but does it Scale?

Let’s test it and find out

Web Services

REST API

Database

So what’s next…