This documentation is for WSO2 Enterprise Integrator version 6.3.0 . View documentation for the latest release in the 6.x.x family and the latest release in the 7.x.x family.

All docs This doc
||
Skip to end of metadata
Go to start of metadata

This tutorial will get you started with Point-to-Point messaging using Queues in the Message Broker profile (MB profile) of WSO2 Enterprise Integrator (WSO2 EI).


Prerequisites

Install WSO2 EI and download JMS clients as explained below.

Download and start the MB profile of WSO2 EI

Follow the steps given below to download and start the MB profile of WSO2 EI.

  1. Download the product installer from here, and run the installer.
    Let's call the installation location of your product the <EI_HOME> directory.

    Note that if you used the product installer to install your product, the <EI_HOME> is located in a place specific to your OS as shown below:

    OSHome directory
    Mac OS/Library/WSO2/EnterpriseIntegrator/6.3.0
    WindowsC:\Program Files\WSO2\EnterpriseIntegrator\6.3.0\
    Ubuntu/usr/lib/wso2/EnterpriseIntegrator/6.3.0
    CentOS/usr/lib64/EnterpriseIntegrator/6.3.0
  2. Start the Message Broker profile:

    Open a terminal and execute the following command:

    wso2ei-6.3.0-broker
    Go to Start Menu -> Programs -> WSO2 -> Enterprise Integrator 6.3.0 Broker. This will open a terminal and start the Message Broker profile.
  3. The URL of the management console will be printed in the terminal as follows: https://localhost:9446/carbon/

Download and start Apache JMeter

We will be using Apache JMeter for the purpose of simulating how a JMS client sends messages to the MB profile, and how such a client subscribes to topics and queues in the broker. Therefore, let us install and start Apache JMeter by following the steps given below.

  1. Download Apache JMeter from here and install it. The location of your JMeter folder will be referred to as <JMeter_HOME> from hereon.

    This guide is tested with JMeter version 2.13.

  2. Copy the following JARs from the <EI_HOME>/wso2/broker/client-lib directory to the <JMeter_Home>/lib folder:
    • andes-client-3.2.4.jar
    • geronimo-jms_1.1_spec-1.1.0.wso2v1.jar
    • org.wso2.carbon.logging-4.4.26.jar
    • org.wso2.securevault-1.0.0-wso2v2.jar
  3. Start the JMeter by executing the following script from the <JMeter_Home>/bin folder: 
    • On windows: jmeter.bat
    • On Linux: sh jmeter.sh
    The JMeter UI will open.

In the following steps, we will go through the basics of creating a queue in the MB profile of WSO2 EI, and setting up a JMS client as a subscriber and publisher.

Step 1: Creating queues

We will now create a queue, using the MB profile's management console. Follow the instructions given below. 

  1. Log in to the management console using the credentials of the default system administrator: admin/admin.
    You will now be signing in to the super tenant domain. 
  2. In the Main tab, click Queues -> Add. The Add Queue screen will open.
  3. Enter 'myfirstqueue' as the name in the Queue Name field.
  4. Click Add Queue and the new queue will be listed in the Queue List page as shown below.
     
    You can access the Queue List page by clicking Queues -> List in the Main tab of the navigator.

Step 2: Publishing messages to the queue

We will now set up Apache JMeter as a JMS publisher to the queue we created in the previous step. Follow the instructions given below.

  1. Create the jndiqueues.properties file shown below and save it to a location in your system. The details in this file will establish the connection between your JMS publisher and the MB node you installed.

    # register some connection factories
    # connectionfactory.[jndiname] = [ConnectionURL]
    connectionfactory.QueueConnectionFactory = amqp://admin:[email protected]/carbon?brokerlist='tcp://localhost:5675'
    
    # register some queues in JNDI using the form
    # queue.[jndiName] = [physicalName]
    queue.FirstQueue = myfirstqueue 

    Note that we are using localhost as the IP address, which is the same IP we used for starting the management console of the MB profile.

  2. Go to the JMeter UI and create a JMS publisher as explained below.
    1. Create a new thread group in JMeter: Right-click the Test Plan (in the left navigator) and go to Add -> Threads (Users) -> Thread Group.
    2. The new thread group will now be listed in the left navigator as a test plan.
    3. Right-click the new thread group and go to Add -> Sampler -> JMS Publisher.
    4. Name the publisher as 'JMS Queue Publisher'.
    5. You will now have a JMS Publisher node in the left navigator. Select this node and enter the following details:

      Initial Context Factoryorg.wso2.andes.jndi.PropertiesFileInitialContextFactory
    6. The connection details you specified in the jndiqueues.properties file should be entered for the JMS Publisher as shown below.

      Provider URLThe location where you have the jndiqueues.properties file saved.
      Connection FactoryQueueConnectionFactory
      DestinationFirstQueue (i.e., the JNDI name given for the queue in the jndiqueues.properties file)
      Expiration0
      Priority0
    7. Enter the message that you want to publish to the queue in the relevant field. For example, follow the below steps to send a text message:
      • Select Text Message as the Message Type.
      • Enter the following message in the Text Message or Object Message serialized to XML by XStream field: This is a test text message.
    8. Save the information. You now have a JMS client ready to send messages to the 'myfirstqueue' queue in your MB server.

  3. Execute the JMeter publisher.
  4. Go back to the management console of the broker and go to the Queue List page from the navigator. See that the myfirstqueue queue has received one message.

    You can access the Queue List page by clicking Queues -> List in the Main tab of the navigator.

  5. Click Browse to view details of the message that has been published.

Step 3: Subscribing to queues

We will now set up Apache JMeter as a JMS subscriber for the queue we created in the previous step. Follow the instructions given below.

  1. Go to the JMeter UI and create a JMS subscriber as explained below.
    1. Create a new JMeter instance. 

      Note that you now have two individual JMeter instances corresponding to the Publisher client and the Subscriber client respectively.

    2. Right-click the Test Plan (in the left navigator) and go to Add -> Threads (Users) -> Thread Group.
    3. The new thread group will now be listed in the left navigator for the test plan.
    4. Right-click the new test plan and go to Add -> Sampler -> JMS Subscriber.
    5. Name the subscriber 'JMS Queue Subscriber'.
    6. You will now have a JMS Queue Subscriber node in the left navigator. Select this node and enter the following details:

      Initial Context Factoryorg.wso2.andes.jndi.PropertiesFileInitialContextFactory
    7. The connection details you specified in the jndiqueues.properties file should be entered for the JMS Subscriber as shown below.

      Provider URLThe location where you have the jndiqueues.properties file saved.
      Connection FactoryQueueConnectionFactory
      DestinationFirstQueue (i.e., the JNDI name given for the queue in the jndiqueues.properties file)
    8. Right-click the new thread group and go to Add -> Listener -> View Results Tree. This will create a listener node in the JMeter navigator for analyzing the output of the subscription.
    9. Save the information. You now have a JMS client subscribed to the 'myfirstqueue' queue in your MB server.
  2. Execute the JMeter script. This will create a subscription to the myfirstqueue queue in your MB server, and the message that was already published to that queue will be immediately consumed.

  3. Select the View Results in Tree node in the JMeter navigator and go to the Response data tab. You can now see that the message from the myfirstqueue queue has been received by the subscriber.

  4. Go back to the management console of the MB profile and view the Queue List. See that the number of messages published to the myfirstqueue has reverted to zero. 

    You can access the Queue List page by clicking Queues -> List in the Main tab of the navigator.

Step 4: Managing unconsumed subscriptions

In the above example, we saw that the subscriber immediately consumes the message that is published to the Message Broker. The following steps illustrate how subscriptions can be managed if a published message is not available to be consumed.

  1.  Repeat Step 3: Subscribing to queues given above to create another subscription to the same queue (myfirstqueue) in the broker. 
  2. Go to the management console of the Message Broker and go to Subscriptions -> Queue Subscription List in the Main tab. The Queue Subscription List page shows all the subscriptions that are waiting for published messages.
  • No labels