2011-11-24 13 views
0

私は間違っていることを完全に知らない。以下は、動作する2つのコードスニペットです。しかし、スニペット-1のプロセッサーをスニペット-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"); 

      } 
     }); 
関連する問題