Publishing and subscribing messages by using workflows

Tutorial to publish and subscribe messages by using topics and workflows.

About this task

Publishing and subscribing messages by using topics and workflows involves the following high-level tasks:

  1. Creating publishers - Create a workflow, T1_publish_workflow to publish the messages to topic T1.
  2. Creating subscribers - Create a Subscriber, T1_subscriber, which subscribes to T1 and runs a workflow, T1_subscriber_workflow, to consume the messages.
  3. Publishing messages - Run the publisher and view the consumer workflow execution logs.

Procedure

  1. Creating publishers
    1. In Projects, create a project. For example, Messaging_Ops. You can also select an existing project.
    2. Click Integrations > Workflows.
      The Workflows page is displayed.
    3. Click Add.
      The Start Building your Workflow page is displayed.
    4. Click Create New Workflow to start creating a workflow to publish the message.
      The Workflow canvas is displayed.
    5. Drag and drop the Messaging connector on to the canvas from the right-side Search box.
    6. Click the warning icon on the Messaging connector.
      The Messaging page is displayed.
    7. Provide the following details to configure the Messaging connector:
      1. Select action - publish
      2. Name - T1_publisher
      3. Destination Type - Topic
      4. Destination - T1 (You can also add a new destination by clicking Add.
      5. Connect to Messaging - DefaultAccount
      6. Click Next. The T1_publisher page is displayed.
      7. Type the message, Hello! I’m publishing a message, in the string field.
      8. Click Next. The Test this action page is displayed.
      9. Click Test. The Output tab shows that the message has been posted.
      10. Click Done. The workflow canvas page is displayed.
    8. Connect the Messaging step to the Stop button.
    9. Provide a name for the workflow, T1_publisher_workflow.
    10. Click Done.
      The workflow name is updated.
    11. Save the workflow.
  2. Creating subscribers
    1. ClickIntegrations > Workflows.
      The Workflows page is displayed.
    2. Click Add.
      The Start Building your Workflow page is displayed.
    3. Click Create New Workflow to start creating a workflow for subscribing messages.
      The workflow canvas is displayed.
    4. Click the Settings icon on the Start step.
      The Trigger page is displayed.
    5. Search and select the Messaging Service trigger.
    6. Click Next.
      The Messaging Service page is displayed.
    7. Do the following steps to add a subscriber.
      1. Click Add. The Add subscriber page is displayed.
      2. Enter the following values:
        1. Subscriber Name - T1_subscriber
        2. Description - Consumes messages that are received from T1
        3. Destination type: Topic.
        4. Destination: T1
      3. Click Save. The subscriber is created.
    8. Do the following to add filters.
      1. Click Add Filters. The filter fields appear.
      2. Enter the following details. Repeat this step to add more filters.
        1. Name - F1.
        2. Filter Expression - %body/string%==”Hello”.
    9. Click Save.
      The Test trigger page is displayed. If you want to test the trigger, you must first publish a message and then click the Test button to see whether the message is received.
    10. Click Skip.
      The Trigger output data page is displayed.
    11. Click Done.
      The workflow canvas is displayed.
    12. Search for the Logger connector and drag and drop the Logger connector on to the canvas.
    13. Click the warning icon on the Logger.
      The Logger page is displayed.
    14. Click Next.
      The Logger fields appear.
    15. Drag and drop string to the Log Data field.
    16. Click Next.
      The Test this action page is displayed.
    17. Click Done.
      The workflow canvas is displayed.
    18. Connect the Logger to the Stop step.
    19. Provide a name and description for the workflow.
    20. Save the workflow.
      Now, the workflow is ready to receive messages and process further steps based on the filters specified.
  3. Publishing messages
    1. Open the T1_publish_workflow from the Workflows page.
    2. Click Run.
    3. Go to Monitor > Execution results > Workflow execution.
      The workflow execution statistics appear. You can observe that the Execution source column for the:
      • T1_subscriber_workflow is Trigger.
      • T1_publisher_workflow is Manual.
      In this way, you can publish and subscribe messages by using workflows.