Messaging Service Trigger
You can subscribe for messages through workflows using the Messaging Service Trigger option instead of Messaging.
The workflow is run whenever messages are published to the associated destination. In other words, it is the same as creating a subscriber from Messaging and then associating it with the workflow under Default invocation. As a result, a Messaging Service Trigger is automatically created and attached to the workflow.
- 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 Subscribers 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.
The process is as follows,
Prerequisite- Make sure that the destination (queue or topic) exists. Otherwise, create a destination from Messaging before starting with the workflow creation.
- Create a workflow.
- Add a Messaging Service Trigger.
- Associate a destination, either queue or topic.
- Associate with an existing subscriber.Note: These filters are called as the routing rules filters that initiate to run the workflow if any of them match. If none of the existing subscribers meet the requirement you can also create a new subscriber and associate with the workflow from Messaging Service Trigger itself.
- Define filter conditions.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.
- Save the workflow. This workflow is ready to receive the published messages.
Subscribers that are created either from workflows or directly from Messaging are all listed in the Subscribers list table on the 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, there is a subscriber S1 associated to a workflow. You have 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. On the other hand, 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.
Configuring Messaging Service Trigger for Subscribing Messages
- Go to Workflows page appears. . The
- Click Add. The Start Building your Workflow page appears.
- Click Create New Workflow to start creating a workflow. The workflow canvas appears.
- Click the Settings icon on the Start step. The Trigger page appears.
- Search and select the Messaging Service trigger.Note: Version: 1 Messaging Service triggers cannot be modified.
- Click Next. The Messaging Service page appears.
- Perform the following steps to add a subscriber:
- Click Add. The Add subscriber page appears.
- 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.
- Click Save. The subscriber is created.
- Perform the following to add filters:
- Click Add Filters. The filter fields appear.
- Enter the following details.
- 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.
- Repeat the sub steps in this step to add more filters.
- Click Save. The Test trigger page appears.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.
- Click Skip. The Trigger output data page appears.
- Click Done. The workflow canvas appears.
- Drag the Logger connector on to the canvas from the Search page.
- Click the warning icon on the Logger. The Logger page appears.
- Click Next. The Logger connector fields appear.
- Drag the string to the Log Data field.
- Click Next. The Test this action page appears.
- Click Done. The workflow canvas appears.
- Connect the Logger to the Stop step.
- Provide a name and description for the workflow.
- 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.