Apache Camel 多播 CBR 在多播后无法与处理器一起使用
我完全不知道我做错了什么。下面是两个有效的代码片段。但如果我需要将 snippet-2 的处理器放在 snippet-1 中,它就不起作用。我怎样才能找出原因?
工作片段 -1
from("file:inbox")
.multicast()
.to("seda:a")
.choice()
.when(header("foo").isEqualTo("one"))
.to("log:org.apache.camel.DeadLetterChannel?level=error")
.otherwise()
.to("file://d://log//camel//output1<file:///d://log//camel//output1>")
.to("seda:b")
.choice()
.when(header("foo").isEqualTo("one"))
.to("log:org.apache.camel.DeadLetterChannel?level=error")
.otherwise()
.to("file://d://log//camel//output2<file:///d://log//camel//output2>");
工作片段 -2
from("file:inbox")
.multicast()
.process(new MutlicastRecoveryProcessor (“output1”))
.to ("file://d://log//camel//output1<file:///d://log//camel//output1>")
. process(new MutlicastRecoveryProcessor (“output2”))
.to("file://d://log//camel//output2<file:///d://log//camel//output2>");
class MutlicastRecoveryProcessor implements Processor {
private String endpointSeqID;
public MutlicastRecoveryProcessor(String endpointSeqID) {
this.endpointSeqID = endpointSeqID;
}
@Override
public void process(Exchange exchange) throws Exception {
if (“output1”.equals(this.endpointSeqID)) {
exchange.getIn().setHeader(“foo”,”one”);
}
}
}
非工作片段 -1
from("file:inbox")
.multicast()
.process(new MutlicastRecoveryProcessor (“output1”))
.to("seda:a")
.choice()
.when(header("foo").isEqualTo("one"))
.to("log:org.apache.camel.DeadLetterChannel?level=error")
.otherwise()
.to("file://d://log//camel//output1<file:///d://log//camel//output1>")
.process(new MutlicastRecoveryProcessor (“output2”))
.to("seda:b")
.choice()
.when(header("foo").isEqualTo("one"))
.to("log:org.apache.camel.DeadLetterChannel?level=error")
.otherwise()
.to("file://d://log//camel//output2<file:///d://log//camel//output2>");
class MutlicastRecoveryProcessor implements Processor {
private String endpointSeqID;
public MutlicastRecoveryProcessor(String endpointSeqID) {
this.endpointSeqID = endpointSeqID;
}
@Override
public void process(Exchange exchange) throws Exception {
if (“output1”.equals(this.endpointSeqID)) {
exchange.getIn().setHeader(“foo”,”one”);
}
}
}
I am completely clueless of what I am doing wrong. Below are the 2 code snippets that works. But if I need to place the processor of snippet-2 in snippet-1 it doesn't work. How can I find out the reason?
Working snippet -1
from("file:inbox")
.multicast()
.to("seda:a")
.choice()
.when(header("foo").isEqualTo("one"))
.to("log:org.apache.camel.DeadLetterChannel?level=error")
.otherwise()
.to("file://d://log//camel//output1<file:///d://log//camel//output1>")
.to("seda:b")
.choice()
.when(header("foo").isEqualTo("one"))
.to("log:org.apache.camel.DeadLetterChannel?level=error")
.otherwise()
.to("file://d://log//camel//output2<file:///d://log//camel//output2>");
Working snippet -2
from("file:inbox")
.multicast()
.process(new MutlicastRecoveryProcessor (“output1”))
.to ("file://d://log//camel//output1<file:///d://log//camel//output1>")
. process(new MutlicastRecoveryProcessor (“output2”))
.to("file://d://log//camel//output2<file:///d://log//camel//output2>");
class MutlicastRecoveryProcessor implements Processor {
private String endpointSeqID;
public MutlicastRecoveryProcessor(String endpointSeqID) {
this.endpointSeqID = endpointSeqID;
}
@Override
public void process(Exchange exchange) throws Exception {
if (“output1”.equals(this.endpointSeqID)) {
exchange.getIn().setHeader(“foo”,”one”);
}
}
}
Non Working snippet -1
from("file:inbox")
.multicast()
.process(new MutlicastRecoveryProcessor (“output1”))
.to("seda:a")
.choice()
.when(header("foo").isEqualTo("one"))
.to("log:org.apache.camel.DeadLetterChannel?level=error")
.otherwise()
.to("file://d://log//camel//output1<file:///d://log//camel//output1>")
.process(new MutlicastRecoveryProcessor (“output2”))
.to("seda:b")
.choice()
.when(header("foo").isEqualTo("one"))
.to("log:org.apache.camel.DeadLetterChannel?level=error")
.otherwise()
.to("file://d://log//camel//output2<file:///d://log//camel//output2>");
class MutlicastRecoveryProcessor implements Processor {
private String endpointSeqID;
public MutlicastRecoveryProcessor(String endpointSeqID) {
this.endpointSeqID = endpointSeqID;
}
@Override
public void process(Exchange exchange) throws Exception {
if (“output1”.equals(this.endpointSeqID)) {
exchange.getIn().setHeader(“foo”,”one”);
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这样的事情终于奏效了。
Something like this finally worked.