ActiveMQ Artemis Condidtionals¶
Conditional Processing or Execution Conditions gives you the power to decide if a particular action on ActiveMQ Artemis 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.
We will take a scenario where you are using ActiveMQ Artemis as the trigger application. There could be multiple application actions attached to the flow that will be invoked upon receiving a ActiveMQ Artemis trigger. Each of the actions in the workflow would apply its own execution condition based on the data attributes of the ActiveMQ Artemis 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 ActiveMQ Artemis Queue. The action will be performed only if the execution conditions are evaluated to be true.
When using ActiveMQ Artemis as the trigger application, the following attributes will be available to you in all your application actions for filtering:
- Type - Message type of the incoming message.
- Message - The contents of the message. This attribute is not available if the message type is Map.
- Delivery Mode - Persistent if the message persists in queue/topic if the recipient is unavailable otherwise Non-Persistent.
- Priority - Messages can be specified with a priority value between 0 and 9. 0 represents the lowest priority and 9 represents the highest.
- Message ID - The alphanumeric Id of the message.
- Correlation ID - Helps correlate requesuests with responses.
- Timestamp: Timestamp of the time when the message was sent.
- Reply To - The destination where a reply to the current message should be sent. If it is null, no reply is expected.
- Redelivered: The redeliverd attribute is set to true if sending the message failed in first attempt and the message is being redeliverd.
In Figure 1 below, the action on RabbitMQ will only be performed if the
In case where Message Type is Map, You can define the keys of incoming Map type messsage and use them for filtering the Action.
For example In Figure 2, the Action on RabbitMQ will only be performed if the following conditions are true.
AppVersionis greater than 9. These values are coming from the contents of Map type Message.