Example: Work with queue messages

The API Engine enables you to work with messages from queues and topics. You create these messages when you use API connections such as Active MQ, IBM MQ, Microsoft Message Queuing (MSMQ), Oracle WebLogic, Rabbit MQ, or Tibco EMS.

A queue or topic temporarily stores messages that are sent by one or more senders and read by one or more receivers. This allows different systems to communicate independently of one another, for instance if one of them is offline. You can select whether you want to receive messages from a queue/topic or send messages to a queue/topic, i.e. if you want to pull messages or push messages. For more information on queues and topics, see chapter "Run JMS messages" and chapter "Run MSMQ messages".

In the following example, you will work with messages from an MSMQ queue and prepare them for your tests. The example includes the following steps:

Export queue messages

In this example, you use API Scan to run your MSMQ messages. In your new project, you created the folder MSMQ Folder that contains two messages:

  • Pull: a message that you pulled from the MSMQ queue

  • Push: a message that you pushed to the MSMQ queue

To use the queue messages in Tosca Commander, you export the folder from API Scan as an API TestCase.

Export folder from API Scan

Identify API Modules and XTestSteps

In Tosca Commander, the system automatically creates the following elements from the exported messages:

API Modules and XTestSteps

In order to work with the API Modules and XTestSteps, it is important to identify them correctly.

The following two Modules are created for the pull message:

  • Pull - Selector: the request to pull a message from the queue that was sent to the MSMQ broker. You can use a selector to specify which messages you want to pull.

  • Pull - Pull Message: the response from the MSMQ broker, i.e. the message that it pulled from the queue.

The following two Modules are created for the push message:

  • Push - Push Message: the message sent to the MSMQ broker, i.e. the message it pushes to the queue.

  • Push - Status: the response from the MSMQ broker which indicates if the message was pushed to the queue, i.e. the message's status.

The system also creates an API TestCase and XTestSteps for each of the API Modules.

Order API Modules and XTestSteps

By default, the API Modules and XTestSteps are arranged in alphabetical order. To run your tests successfully, you might have to rearrange them according to the logical order of queue messaging: you can only pull a message from a queue if a message was pushed to the queue beforehand. Otherwise the queue is empty, i.e. there are no messages to pull.

To arrange your API Modules and XTestSteps correctly, you drag and drop them into the following order:

  • First message: the message that was pushed to the queue, i.e. Push - Push Message.

  • Second message: the response from the broker that indicates if it successfully pushed the message to the queue, i.e. Push - Status.

  • Third message: the request to pull a message from the queue that was sent to the broker, i.e. Pull - Selector.

  • Fourth message: the message pulled from the queue, i.e. Pull - Pull Message.

Ordered API Modules and XTestSteps

You can now create Module Attributes and verify their values.