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”);
}
}
}
Something like this finally worked.