2011-11-24 3 views
0

나는 잘못하고있는 것을 완전히 알지 못합니다. 다음은 작동하는 2 개의 코드 스 니펫입니다. 하지만 snippet-2의 프로세서를 snippet-1에 두어야한다면 작동하지 않습니다. 이유를 아는 것을 도와주세요. 이 문제를 지금 당면히 해결해야합니다.Apache Camel 멀티 캐스팅 후 멀티 캐스팅 CBR이 프로세서와 함께 작동하지 않습니다.

근무 조각 -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”); 
        } 
      } 
} 

답변

0

뭔가가 마침내했다.

class MutlicastRecoveryProcessor implements Processor { 
      private String endpointSeq; 

      public MutlicastRecoveryProcessor(String endpointSeq) { 
       this.endpointSeq = endpointSeq; 
      } 

      @Override 
      public void process(Exchange exchange) throws Exception { 
       if ("output1".equals(this.endpointSeq)) { 
        exchange.getIn().setHeader("foo", "one"); 
       } else { 
        System.out.println("endpoint " + this.endpointSeq); 
       } 
      } 
     } 

     CamelContext context = new DefaultCamelContext(); 

     context.addRoutes(new RouteBuilder() { 

      public void configure() { 
       from("file://d://log//camel").convertBodyTo(String.class) 
         .multicast().to("seda:a", "seda:b"); 

       from("seda:a") 
         .process(new MutlicastRecoveryProcessor("output1")) 
         .choice() 
         .when(header("foo").isEqualTo("one")) 
         .to("log:org.apache.camel.DeadLetterChannel?level=error") 
         .otherwise().to("file://c://log//camel//output1"); 

       from("seda:b") 
         .process(new MutlicastRecoveryProcessor("output2")) 
         .choice() 
         .when(header("foo").isEqualTo("one")) 
         .to("log:org.apache.camel.DeadLetterChannel?level=error") 
         .otherwise().to("file://d://log//camel//output2"); 

      } 
     }); 
관련 문제