<route>
<from uri="direct:A"/>
<log message="B is starting"/>
<to uri="direct:B"/>
<log message="B is finished"/>
</route>
<route>
<from uri="direct:B"/>
<!-- Common B logic here -->
<log message="Common B logic finished"/>
<choice>
<when>
<!-- your condition inverted -->
<wireTap uri="direct:B-cont"/>
</when>
</choice>
<!-- Remaining B logic if needed to prepare required response for A -->
<log message="Response to A prepared"/>
</route>
<route>
<from uri="direct:B-cont"/>
<log message="B processing after returning response to A"/>
<!-- remaining B logic -->
</route>
此类路由的日志输出如下所示:
B is starting
Common B logic finished
Response to A prepared
B is finished
B processing after returning response to A
或:
B is starting
Common B logic finished
Response to A prepared
B processing after returning response to A
B is finished
或:
B is starting
Common B logic finished
B processing after returning response to A
Response to A prepared
B is finished
4条答案
按热度按时间tyg4sfes1#
您可以使用窃听来实现这一点。在这种情况下,您的逻辑必须更改:
有关窃听的详细信息,请访问:http://camel.apache.org/wire-tap.html
配置示例:
此类路由的日志输出如下所示:
或:
或:
正如您所看到的,“窃听”路由将(在大多数情况下)与其被调用的路由的其余部分并行运行。
quhf5bfb2#
我想你是直接连接到路由B,你能简单地在你的路由B中设置一个报头(当条件满足时),当它返回到路由A时,过滤掉没有设置这个报头的交换机吗?如果不清楚,请告诉我,我会给你一个例子。
R.
iyr7buue3#
从由direct组件连接的多条路由中选择路由A。在路由B中,在特定条件下使用
to("direct:partRouteA")
调用路由A的所需部分k5ifujac4#
事实上,
stop()
确实完全停止路由,而不是当前路由中的return
或break
。我还没有测试过它,但是在路由B中的filter(false)
如何?这应该会使交换在路由A上恢复。