RabbitMQ Conditionals¶
Conditional Processing or Execution Conditions gives you the power to decide if a particular action on RabbitMQ will be performed or not when the workflow is triggered by the incoming event. This is akin to the ability to apply 'if-then-else' logic to the execution of an action based on the value of the attribute from the trigger event of the workflow.
Think of Conditional Processing as an equivalent of 'if-then-else', as decision diamond in the flow chart, or the Conditional Branching in BPEL (Business Process Execution Language).
You can add conditional processing to any action in your workflow and decide which actions should be performed in response to a particular trigger event identified by its characteristics or the data attributes. You can apply complex logic using AND, OR, and grouping of such conditions. Each of the conditions supports different operators based on the event data types like a string, number, boolean, etc. Read here to find more about Conditional Processing.
Example Scenario¶
We will take a scenario where you are using RabbitMQ as the trigger application. There could be multiple application actions attached to the flow that will be invoked upon receiving a RabbitMQ trigger. Each of the actions in the workflow would apply its own execution condition based on the data attributes of the RabbitMQ trigger event. This will allow each of the actions to independently choose to execute based on the defined execution conditions.
In this example, the workflow is triggered when a new message is received in the RabbitMQ Exchange. The action will be performed only if the execution conditions are evaluated to be true.
When using RabbitMQ as the trigger application, the following attributes will be available to you in all your application actions for filtering:
- Custom Headers - All the headers that you have defined in trigger will be available for Event filtering.
- AMQP Payload - The incoming AMQP Message
- Priority - The priority of AMQP message
- Character Encoding Type - The character encoding of AMQP message
- Size(Byte) - Size of message in bytes.
- Content Type - Content type, e.g. "application/json". Used by applications, not core RabbitMQ.
- Correlation Id - Helps correlate requests with responses. See More
- Reply To - Carries response queue name. See More
- Expiration - Per-message TTL
- Message Id - Arbitrary message ID
- Type - Application-specific message type, e.g. "orders.created"
- User Id - User ID. See More
- App Id - Application Name
- Cluster Id - Cluster Id
- Timestamp - Application-provided timestamp
See this to know more about AMQP message properties.
In Figure 1 below, the action on Microsoft Teams will only be performed if the Priority
of the message published to the RabbitMQ exchange is less than 5.