Reputation: 59
Can you use an expression as a case condition? Take, for example, the following code:
<switch description="Path based on the output" source="$body/output">
<case regex="A|B">
<call description="Send request to endpoint">
<endpoint key="endpoint"/>
</call>
</case>
<default/>
</switch>
This works and will send the message to the endpoint if the $body/output evaluates to either A or B.
Is it possible to store the "A|B" somewhere else (for example in an local-entry called "output.xml"), and use an expression in the case regex instead? For example:
<case regex="get-property('output')">
If that's not possible and the case regex has to evaluate to a String, is it possible to store the contents of the local-entry in the sequence to I call upon them in the case regex, or does the case regex have to be "A|B"?
Upvotes: 2
Views: 205
Reputation: 14604
AKAIK you can only have a Regex
string in the case. The code also confirms this where it seems to store the regex string as a java.util.regex.Pattern
and uses java.util.regex.Matcher
to match it against the source. So simply you have to have A|B
or any other valid regex for the matcher to work.
Upvotes: 1