gpt4 book ai didi

apache-camel - 否则停止路线

转载 作者:行者123 更新时间:2023-12-04 09:28:01 25 4
gpt4 key购买 nike

嗨,有一条这样的路线

<route id="route1">
<from uri="activemq:queuer1"/>
<choice>
<when>
<simple>${header.urn} regex '^user*'</simple>
<to uri="xslt:classpath:/xslt/rdf/user.xsl"/>
</when>
<when>
<simple>${header.urn} regex '^userdata:.*'</simple>
<to uri="xslt:classpath:/xslt/rdf/userdata.xsl"/>
</when>
....
<otherwise>
<setHeader headerName="errorMsg ">
<constant>no xsl file for this type</constant>
</setHeader>
<to uri="activemq:error"/>
</otherwise>
</choice>
<process ref="importer"/>
</route>

现在,如果路由进入其他部分,则不应处理该消息。
如果消息进入其他地方,我可以以某种方式停止路线吗?

我可能会在所有的when部分中添加流程部分,并在最后将其删除。
但是,我们已经有几个时机,还有更多。

其他解决方案将是首选。

最佳答案

您可以添加<stop/>以停止继续路由消息。

在Java代码中:

exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);

在Java DSL中:
.when(simple("${in.header.CamelHttpResponseCode} == 404"))
.stop()
.otherwise()
...

关于apache-camel - 否则停止路线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6830390/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com