Publishing and subscribing messages by using external messaging provider - JMS connector

Tutorial to publish and subscribe messages by using an external messaging provider and the JMS connector.

Before you begin

  • Access to Universal Messaging.
  • Universal Messaging must have a connection factory in the JNDI context.
  • If you want to use Two-Way SSL, then the appropriate client certificate that is generated from IBM® webMethods Cloud Container must be uploaded in webMethods Integration under Configurations > Certificates. For more information about client certificate, see Two-Way SSL and Messaging in IBM webMethods Cloud Container documentation.

About this task

To publish and subscribe messages by using the JMS connector.

  1. Create publishers - Create a flow service, say publish_flowservice to publish the messages to topic, JMSTopic.
  2. Create subscribers - Create a subscriber, say JMSsubscriber, which subscribes to JMSTopic and runs a flow service, JMSTopic_consumer_flowService , to consume the messages.
  3. Publish messages - Run the publisher and view the consumer flow service execution logs.

Creating publishers

Procedure

  1. Click Integrations > Flow services.
    The Flow services page is displayed.
  2. Click Add.
    The Start creating the Flow service page is displayed.
  3. Enter the flow service name as publisher_flowservice.
  4. Enter a short description of the flow service under the Flow service name.
  5. Type JMS in flow service step1 and select JMS from the list that is displayed.
    The fields that are associated with the JMS connector is displayed.
  6. Select the following options:
    1. Action - send
    2. Account - account that must be used to connect to the JMS connector. You can configure a new account if an account is not available. For more information, see JMS connector parameters.
  7. Click Pipeline to map the input and output fields.
    The Pipeline page is displayed.
  8. Double-click destinationName to specify the destination to which the messages must be published.
    The Set Value - destinationName dialog box is displayed.
  9. Enter the name of the destination. For example, JMSTopic.
  10. Double-click the string field.
    The Set Value - string page is displayed.
  11. Enter the message that I want to publish a message!
  12. Click Save.
    The Pipeline page is displayed.
  13. Close the Pipeline page.
    The flow service page is displayed.
  14. Click Save.
    The flow service details are saved.

Creating subscribers

About this task

You can create the consumer flow service in one of the following ways:

  • Directly from the flow services page.
  • Create the flow service when you create a subscriber. The subscriber listens to messages that the topic receives. If the topic receives messages, then the consumer flow service in the subscriber runs automatically.

Here, the steps are explained to create the JMSTopic_consumer_flowService using Messaging.

Procedure

  1. Go to Events > Messaging.
  2. Click Add new subscriber.
    The New subscriber page is displayed.
  3. Enter the following details:
    1. Subscriber Name - JMSSubscriber
    2. Description - Subscribes for messages that are published to JMSTopic
    3. Connector Type - JMS
    4. Account - Account that must be used to connect to JMS provider
    5. Destination type - Topic
    6. Select destination - JMSTopic
  4. Do the following to set the Default invocation.
    1. Invocation type - Flow service
    2. Select invocation -
      1. Click Add. The New Flow service page is displayed.
      2. Enter the name as JMSTopic_consumer_flowservice.
      3. Click Save.
  5. Click Save.
    The JMSSubscriber is created with the JMSTopic_consumer_flowService that consumes messages that arrive in JMSTopic.

Publishing messages

Procedure

  1. Open the publisher_flowservice.
  2. Click Run.
    If the publisher_flowservice runs successfully, the JMSTopic_consumer_flowService runs automatically. The publisher_flowservice sends the message to the topic JMSTopic and as the JMSSubscriber is listening to the topic, it runs the JMSTopic_consumer_flowService created in the JMSSubscriber.
  3. To verify whether the consumer Flow service ran:
    1. Go to Monitor > Execution results > Flow service execution.
      The flow service execution statistics are displayed.
    2. Go to the Executions section. You can observe that the Execution source column for,
      • JMSTopic_consumer_flowService is a Messaging Subscriber.
      • publisher_flowService is a User Interface.
      In this way, you can publish and subscribe messages by using the JMS connector.