How to use camel recipentList -


i try camel route working using recipentlist. first question: difference beween

  • multicast / recipentlist (both without parallel processing)
  • multiple "to" ?

in case want parallel processing of routes. @ moment use multiple

"to" added within loop:

routedefinition someroute = createsomerout(frompart, id); \\ method (string pcrftarget : cepconfig.pcrfceptargets()) {     log.info("...to " + pcrftarget);     someroute.to(pcrftarget + "?mode=" + mode.insertaddid.name()); } 

is there direct way use recipientlist , add parallelprocessing @ end? tried create simple example fails (the example in books , internet 1 using/manipulating header :-(). here example (error):

public class experiments extends cameltestsupport {     private static final string mock2 = "mock:mock2";     private static final string mock1 = "mock:mock1";     private static string pcrf_test_files;      public experiments() throws urisyntaxexception {         pcrf_test_files = classloader.getsystemresource("pcrf-files").touri().tostring();     }      @test     public void test() throws interruptedexception {         mockendpoint mockin = getmockendpoint(mock1);         mockendpoint mockout = getmockendpoint(mock2);         mockin.expectedmessagecount(5);         mockout.expectedmessagecount(5);         // data in mock available after call         assertmockendpointssatisfied();     }      /*      * (non-javadoc)      *      * @see org.apache.camel.test.junit4.cameltestsupport#createroutebuilder()      */     @override     protected routebuilder createroutebuilder() throws exception {         return new routebuilder() {              @override             public void configure() throws exception {                 //from(pcrf_test_files + "?noop=true").unmarshal().gzip().to(mock1).to(mock2); //working                 from(pcrf_test_files + "?noop=true").unmarshal().gzip().recipientlist(method(experiments.class)).parallelprocessing(); //not working             }         };     }      @recipientlist     public string[] recipents() {         return new string[] { mock1, mock2 };     }  } 

i error:

org.apache.camel.camelexecutionexception: exception occurred during execution on exchange: exchange[edr_upcc244_mpu842_0370_20140428000008.csv.gz] ... caused by: java.lang.assertionerror: expected null, was:<[b@48d19957> 

i think reason camel tries use content of files recipients?! provide example how dynamically create recipentlist not based on data comes exchange on independent data (in case given in configuration).

thanks

mixing @recipientlist , recipientlist() not possible stated in camel documentation (section "using method call recipient list"). thus, use 1 or other.

1. use recipientlist()

remove @recipientlist method:

// no @recipientlist annotation public string[] recipents() {     return new string[] { mock1, mock2 }; } 

and define route follows:

from("direct:start")     .recipientlist()     .method(experiments.class)  // may define method name if there more 1     .parallelprocessing(); 

or:

from("direct:start")     .recipientlist(method(experiments.class))  // may define method name if there more 1     .parallelprocessing(); 

2. use @recipientlist

@recipientlist used bean:

from("direct:start")     .bean(experiments.class);  // may define method name if there more 1 

to achieve parallel processing, need add parallelprocessing attribute @recipientlist annotation:

@recipientlist(parallelprocessing = true) public string[] recipents() {     return new string[] { mock1, mock2 }; } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -