The Choice EIP routes messages based on conditions, similar to an "if-else" structure. It evaluates the specified conditions and directs the message to the corresponding route.
To configure a Choice in an integration in the Diagram tab, follow these steps:
Click +Add Step on the canvas.
Select the EIPs tab.
Select the Choice EIP. You can use the search tool to locate it.
When adding a "Choice", two branches will be automatically created on the canvas: When and Otherwise.
You can continue adding steps after the branches, with no limit to the number of subsequent steps.
IMPORTANTIt is possible to add new "When" and "Otherwise" conditions by clicking the + button, but each "Choice" can only have one "Otherwise" branch.
The animation below shows the addition of the Choice EIP to the canvas and the "when" branch being configured to check if the message body contains the word "success":

The following parameters must be provided in the component configuration:
Parameter | Description | Type |
|---|---|---|
| When | Defines a condition for message processing, acting as the "if" block. | List |
| Otherwise | Defines the default route, used when none of the conditions specified in "When" are met (works as the "else" block). | OtherwiseDefinition |
| Precondition | Allows evaluating the conditions defined in the branches ("When" and "Otherwise") during route initialization, instead of evaluating them dynamically at runtime. | Boolean |
There are three deletion scenarios for the Choice EIP and its branches:

Consider the integration below:

See the same integration in code format:
Now, see the breakdown:
GET request to the hello endpoint.
The URI is the entry point of the flow, which receives the call response in the message body (${body}).Choice
When
First condition (when): checks if the response body (${body}) contains the word "success".
If true, it executes the following:
Second condition (when): checks if the response body contains the word "warning". If true, it executes the following:
Third condition (when): checks if the response body contains the word "error". If true, it executes the following:
Otherwise
If none of the previous conditions are met, the Otherwise step will be executed, that is, if the response body does not contain "success", "warning", or "error".
We use cookies to enhance your experience on our site. By continuing to browse, you agree to our use of cookies.Learn more