Configuring messaging service trigger for subscribing messages

You can use the Messaging Service Trigger in workflows to subscribe to messages, eliminating the need to configure Messaging separately. When a message is published to the specified destination, the workflow is automatically triggered. It is the same as linking a Messaging subscriber to a workflow under Default invocation. This setup creates and attaches a Messaging Service Trigger to the workflow automatically.

Before you begin

Make sure that the destination (queue or topic) exists. Otherwise, create a destination from Messaging before you start the workflow creation.

Procedure

  1. Go to Integrations > 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.
    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.
    Note: Version 1 Messaging Service triggers cannot be modified.
  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 details.
      Subscriber Name
      Name of the subscriber.
      Description
      Short explanation about the subscriber.
      Destination type
      Type of destination, either queue or topic.
      Destination
      Name of the destination.
    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 all filter conditions.
      Name
      Name for the filter. This name must be unique for each filter. It is used to identify the routing rule in other parts of the application.
      Filter Expression
      Expression that must be evaluated before running the invocation; can be empty for default routing rule.
    Note: These filters are called as the routing rules in Messaging. All routing rules defined for a subscriber (either from workflow or Subscriber) are listed in the respective Subscriber details page under the Routing rules section.
  9. Click Save.
    The Test trigger page is displayed.
    Note: If you want to test the trigger for a subscriber, 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. Drag and drop the Logger connector on to the canvas from the Search pane.
  13. Click the warning icon on the Logger.
    The Logger page is displayed.
  14. Click Next.
    The Logger connector fields appear.
  15. Connect the 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.
    Note:
    • You can edit a subscriber's filters by clicking the Edit button of the Messaging Service trigger from a workflow.
    • If a workflow is associated with only one subscriber and you deleted the trigger, then the subscriber is also deleted.

Results

The Messaging Service Trigger is configured for the subscriber.

Subscribers that are created either from workflows or directly from Messaging are all listed in the Subscribers list table on the Events > Messaging page. If you modify or add more routing rules to a subscriber from the Subscribers details page in Messaging, the corresponding Messaging Service Trigger is automatically updated with these changes. The newly added routing rules are listed under Filters for a Messaging Service Trigger. Similarly, if you modify any values or add more filters to a Messaging Service Trigger, then those details are automatically updated and listed in the Subscriber details page. Since only the filters that trigger this workflow are listed here, the message evaluation might not always follow the order that you see here. To know the actual order, check the Routing rules section in the Subscriber details page.

For instance, a subscriber S1 associated to a workflow. You added filter F1 from workflow, then add routing rule R1 from the Subscriber details page for S1. Upon viewing the Routing rules section, F1 is followed by R1 as the rules. Later, you added another filter, F2. Now, if you look at the Routing rules section, you see that there are three rules that are listed: F1, R1, and F2. But, in workflows under Add Filters, the order is shown as F1 and F2. Subscribers evaluate the routing rules as listed under the Routing rules section. Hence, the message evaluation might not always follow the order in which the rules are listed for a workflow.

Note:
  • If the Messaging Service Trigger is used in a workflow, the maximum runtime limit is 6 minutes. Messaging Trigger workflows and any sync workflows time out if execution exceeds 6 minutes. In such cases, options that are specified under the Transient Error Handling in msg_configuring_error_handling_for_subscribers.html#task_yr4_2wh_jfc setting take effect, and the workflow execution can be retried depending on the maximum retry count value. Therefore, you need to add a Return Data on Sync Webhook action in your workflow immediately after the Start action if the workflow is expected to take more than 6 minutes to run. However, if you do so, then error handling options cannot be used.
  • This limit does not apply to the flow services.