如何在Mulesoft中实现IF [英] How do I implement IF in mulesoft
问题描述
我想在Mulesoft流程中做出决定,并研究了Choice Flow Control.我的问题是,如果条件为真,我想做某事,如果条件为假,我什么都不做,就像这样:
I want to make a decision in a Mulesoft flow, and have looked at the Choice Flow Control. My problem, is that I want to do something if the condition is true, and nothing if it is false, something like:
if (condition == true)
do some work
或者,在可能不正确的xml中:
or, in probably incorrect xml:
<choice doc:name="call a subflow if the test is true">
<when expression="#[flowVars.someVariable == True]">
<flow-ref name="doSomething" doc:name="do another thing"/>
</when>
</choice>
没有else子句,也没有默认流程.如何在Mulesoft流程中实现这一点?我可以作弊,然后将日志记录调用添加到默认流中,但我不希望这样做.
no else clause, and no default flow. How is this implemented in a Mulesoft flow? I could cheat, and throw a logging call into a default flow, but I would prefer not to.
推荐答案
不幸的是,Mule中没有简单的"if"处理器.暂时要选择假人,否则要使用路由或过滤器.
Unfortunately there is no simple 'if' processor in Mule. Choice with a dummy otherwise route or filters are the way to go for now.
此处对此进行了很好的讨论: https://www.mulesoft.org/jira/browse/MULE-6129 .这进一步链接到可能的增强功能,例如if/detour路由器.
There is a good discussion on this here: https://www.mulesoft.org/jira/browse/MULE-6129. THis has further links to possible enhancements such as an if/detour router.
M子4更新
在m子4中,您现在可以定义选择路由器,而无需否则
路由.并且过滤器不再存在
In mule 4, you can now define a choice router with no need for an otherwise
route. And filters no longer exist
这篇关于如何在Mulesoft中实现IF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!