Apache骆驼:检测是否是链中的最后一条路线
我有以下情况。我正在使用链式路线key_123-> key_345-> key_678。闭塞方法 每条路线都被称为。在审查中,是否有可能检测它是否是链中的最后一条路线?因为我想要 仅在链条末端(在这种情况下为key_678路线)而不是在每条路线之后删除相关性_id。
代码:
from("quartz://key_123?cron=0+0/10+*+*+*+?+*")
.
.
.
.to("activemq:topic:key_345");
from("activemq:topic:key_345")
.
.
.
.to("direct:key_678");
onCompletion().onCompleteOnly()
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
CamelContext context = exchange.getContext();
Boolean isRunAllowed = context.isRunAllowed();
ServiceStatus status = context.getStatus();
//TODO: Check if it is the last route in the chain.
MDC.remove("correlation_id");
}
});
是否可以检测Apache Camel中链中的第一个也是最后一条路线?
I have the following scenario. I am working with chained routes key_123 --> key_345 --> key_678. The onCompletion method
is being called after every route. Is it possible in onCompletion to detect if it is the last route in the chain? Since I want
to remove the correlation_id just at the end of the chain (in this case key_678 route) and not after every route.
Code:
from("quartz://key_123?cron=0+0/10+*+*+*+?+*")
.
.
.
.to("activemq:topic:key_345");
from("activemq:topic:key_345")
.
.
.
.to("direct:key_678");
onCompletion().onCompleteOnly()
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
CamelContext context = exchange.getContext();
Boolean isRunAllowed = context.isRunAllowed();
ServiceStatus status = context.getStatus();
//TODO: Check if it is the last route in the chain.
MDC.remove("correlation_id");
}
});
Is it possible to detect the first and last route in the chain in Apache Camel?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论