In this section:

About the Plugin

The Rabbit MQ Message Listener is a custom message listener extension for Parasoft Virtualize. The listener connects to a Rabbit MQ broker and consumes messages on a specified queue. Depending on the mode of operation (passthrough or virtualize), the messages are forwarded to the real backend system or forwarded to Virtualize, respectively. This listener assumes the publisher uses the Reply To field to define the queue/routing key that will be used when sending the response. The listener also has options to enable the creation of the reply to queue on the fly or to use a predefined reply to queue.

Implementation

The Rabbit MQ Message Listener is implemented as com.parasoft.virtualize.listener.rabbitmq-<version>.jar, which depends upon Rabbit MQ AMQP Client 3.1.1 (amqp-client-3.3.1.jar). This dependency is packaged with the distribution.

Installation

This tool can be installed from the UI or the command line.

UI Installation

  1. Choose Parasoft> Preferences.


     
  2. In the System Properties preferences page, click Add JARs.


     
  3. In the file chooser that opens, select com.parasoft.virtualize.listener.rabbitmq-<version>.jar. Once this jar file is added to the classpath, all of the required dependencies will be loaded.
  4. Restart Virtualize.

Command Line Installation

Add the com.parasoft.virtualize.listener.rabbitmq-<version>.jar file to the system.properties.classpath property in your localsettings properties file.

For example:

system.properties.classpath=<path to jar>/com.parasoft.virtualize.listener.rabbitmq-1.0.1.jar

Once the classpath is modified, all of the required dependencies will be loaded.

Usage

Use of this listener requires additional configuration on the Rabbit MQ server.

Standard Configuration

Above is a standard Rabbit MQ configuration. The Publisher publishes a message through an Exchange. The exchange then routes the message to the proper Message Queue where the Consumer is listening. The consumer then handles the message and passes a response through the default exchange onto the Reply To Queue defined by the publisher. In order to include Virtualize in the configuration the exchange and message queue should be duplicated in the same Virtual Host with the same exact configuration (except for name).

Once the additional exchange and message queue have been configured either the publisher will have to be pointed at the new exchange, or the consumer will have to be pointed at the new message queue so that Virtualize can act as the man-in-the-middle and forward messages to the consumer’s message queue or forward the messages to a Virtualize Asset for a virtual response and respond directly to the publisher.

Publisher-side Virtualization Configuration

Consumer-side Virtualization Configuration

After the additional components are configured on the server and the listener has been installed in Virtualize, you can select and configure it in the Virtual Asset configuration panel.

  1. From the Virtualize Server view, select the virtual asset you want to use as the custom message listener
  2. Navigate to Transports> Custom in the Virtual Asset Deployment Settings. If multiple listeners are installed, use the Select Implementation drop-down menu to select Rabbit MQ Message Listener.

You can configure the following settings.

Configuring Connection Settings

Option

Description

Hostname

Defines the hostname of the Rabbit MQ server. If this field is empty, the default value of localhost will be used.

Port

Defines the port of the Rabbit MQ server. If this field is empty, the default Rabbit MQ port will be used.

Use SSLSet to true to use SSL when connecting to the Rabbit MQ Server. Default is false.

Username

Defines the Rabbit MQ username.

Password

Defines the Rabbit MQ password.

Virtual Host Name

Defines the Rabbit MQ Virtual Host to connect to.

Automatic Connection Recovery

Set to true if the listener should attempt to automatically recover from connection failures. Default is true.

Topology Recovery

Set to true if the listener should attempt to automatically recover from topological failures (i.e., failures with exchanges or queues). Default is true.

Configuring Listener Settings

Option

Description

Listener Mode

You can specify passthrough or virtualize mode.

Passthrough mode forwards the messages on the Listen Queue to the exchange in Forward Exchange Name.

Virtualize mode forwards the messages on the Listen Queue to Virtualize to generate a virtual response.

Listen Queue

Defines the queue that Virtualize will consume message from.

Auto Ack

Set to true if the listener consumer should automatically acknowledge the messages that it handles. If set to false, the messages will have to be acknowledged in a different manner or they will remain on the queue.

Consumer Tag

Defines the consumer tag to use when consuming from a queue.

Forward Exchange Name

Defines the exchange to use when forwarding the messages on the Listen Queue. This field is only used in Passthrough mode.

Configuring ReplyTo Settings

Option

Description

Generate ReplyTo Queue

Set to true if the listener should generate the Reply To queue before publishing a response. This field is only used in Virtualize mode.

ReplyTo Queue Durability

Set to true if the Reply To queue should be durable. A durable queue is a queue that will persist a server restart. This field is only used in Virtualize mode when Generate ReplyTo Queue is true.

Autodelete ReplyTo Queue

Set to true if the Reply To Queue should be deleted automatically. An autodelete queue is deleted after all messages living on the queue have been consumed. This field is only used in Virtualize mode when Generate ReplyTo Queue is true.

Configuring Logging Settings

Option

Description

Log Level

Set the log level for the listener. The following values are accepted:

1 - error

2 - warn

3 - info

4 - debug

Default is 3.



  • No labels