路由到不同的信道根据状态(Routing to a different channels based

2019-10-20 18:26发布

我想将消息路由到基于该属性的条件的不同信道。 比方说,我有得分财产。 如果得分<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>

非常感谢您对这个帮助。

Answer 1:

我们有一个JIRA票对此事,但还没有拿出解决方案呢。

现在就可以实现从状态这种行为expression ,并提供用于映射truefalse ,并与路由器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>


文章来源: Routing to a different channels based on condition