我想将消息路由到基于该属性的条件的不同信道。 比方说,我有得分财产。 如果得分<100,然后它去“perfectchannel”否则它会以“normalchannel”
我在哪里指定SPEL表达或条件
<si:router id="serviceRouter" input-channel="serviceRoutingChannel"
expression="payload.score" default-output-channel="badchannel"
resolution-required="false">
<si:mapping value="100" channel="perfectchannel" />
<si:mapping value="<100 ??" channel="normalchannel" />
</si:router>
非常感谢您对这个帮助。
我们有一个JIRA票对此事,但还没有拿出解决方案呢。
现在就可以实现从状态这种行为expression
,并提供用于映射true
和false
,并与路由器CASCAD:
<si:router id="serviceRouter" input-channel="serviceRoutingChannel"
expression="payload.score == 100">
<si:mapping value="true" channel="perfectChannel" />
<si:mapping value="false" channel="nestedRouterChannel" />
</si:router>
<si:router input-channel="nestedRouterChannel"
expression="payload.score lt 100">
<si:mapping value="true" channel="normalChannel" />
<si:mapping value="false" channel="badChannel" />
</si:router>
UPDATE
另一种选择使用<recipient-list-router>
:
<recipient-list-router id="serviceRouter" input-channel="serviceRoutingChannel">
<recipient selector-expression="payload.score == 100" channel="perfectchannel"/>
<recipient selector-expression="payload.score lt 100" channel="normalchannel"/>
<recipient selector-expression="payload.score gt 100" channel="badchannel"/>
</recipient-list-router>