You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Sachin <sa...@gmail.com> on 2013/04/26 14:26:07 UTC

Processors in parallel mode

Hi ,

When we set parallel processing in a route, do all processors run in
parallel or in sequence?
MY requirement is that i have 5-6 processors in my route and i want then to
be executed in parallel even for a single message, how can i achieve this?

from("direct:endpoint")
		.throttle(Long.parseLong(routeParams.get(RouteParam.THROTTLE)))
		.setBody().body(PaymentRequest.class)
                 .parallelProcessing()
                 .thread(4)
		.setHeader(ORIGINAL_REQUEST).javaScript("request.body")
		.convertBodyTo(PaymentRequest.class)		
		
		.process(processor1)		
		
		.process(processor2)	
		
		.process(processor3)
		
		.process(processor4)

.end()



--
View this message in context: http://camel.465427.n5.nabble.com/Processors-in-parallel-mode-tp5731613.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Processors in parallel mode

Posted by Sachin <sa...@gmail.com>.
Actually it worked with component scanning and even to add more if we keep
all processors in normal way after multicast and parallel processing, that
works too.
from("direct:endpoint") 

              multicast().
                 .parallelProcessing() 
                .process(processor1) 
                .process(processor2) 
                 .process(processor3) 
                .process(processor4) 
           .end() 



--
View this message in context: http://camel.465427.n5.nabble.com/Processors-in-parallel-mode-tp5731613p5731859.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Processors in parallel mode

Posted by Sachin <sa...@gmail.com>.
Thanks Diether, yeah i am using spring with package scanning with component
and service annotations. That will be great if it's so simple.



--
View this message in context: http://camel.465427.n5.nabble.com/Processors-in-parallel-mode-tp5731613p5731631.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Processors in parallel mode

Posted by Diether <di...@optis.be>.
Have a look at: http://camel.apache.org/processor.html
If you use Spring with component scanning you can simply annotate your processors as a @Service or @component and then use .multicast("processor1", "processor2");
Or define all your processors in you context xml file.
But the annotation are probably the fastes way to do this.


________________________________
Van: Sachin [via Camel] [ml-node+s465427n5731621h98@n5.nabble.com]
Verzonden: vrijdag 26 april 2013 16:08
To: Wuyts Diether
Onderwerp: RE: Processors in parallel mode

I will try it..Thanks

________________________________
If you reply to this email, your message will be added to the discussion below:
http://camel.465427.n5.nabble.com/Processors-in-parallel-mode-tp5731613p5731621.html
To start a new topic under Camel - Users, email ml-node+s465427n465428h15@n5.nabble.com
To unsubscribe from Camel - Users, click here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=ZGlldGhlci53dXl0c0BvcHRpcy5iZXw0NjU0Mjh8OTE4NjI3OTg5>.
NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>




--
View this message in context: http://camel.465427.n5.nabble.com/Processors-in-parallel-mode-tp5731613p5731624.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Processors in parallel mode

Posted by Sachin <sa...@gmail.com>.
I will try it..Thanks



--
View this message in context: http://camel.465427.n5.nabble.com/Processors-in-parallel-mode-tp5731613p5731621.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Processors in parallel mode

Posted by Diether <di...@optis.be>.
I haven't tested it, but perhaps you can do something like this:
from("direct:a").multicast().parallelProcessing().to("bean:processor1", "bean:processor2",....);

But then you'll have to create beans from all your processors.


________________________________
Van: Sachin [via Camel] [ml-node+s465427n5731617h74@n5.nabble.com]
Verzonden: vrijdag 26 april 2013 15:51
To: Wuyts Diether
Onderwerp: RE: Processors in parallel mode

Thanks for reply.
Yeah i can do that but only constraint is that i have so many processors and it doesnt make much sense to convert them to routes. Is there any other way i can run my processors concurrently?

________________________________
If you reply to this email, your message will be added to the discussion below:
http://camel.465427.n5.nabble.com/Processors-in-parallel-mode-tp5731613p5731617.html
To start a new topic under Camel - Users, email ml-node+s465427n465428h15@n5.nabble.com
To unsubscribe from Camel - Users, click here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=ZGlldGhlci53dXl0c0BvcHRpcy5iZXw0NjU0Mjh8OTE4NjI3OTg5>.
NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>




--
View this message in context: http://camel.465427.n5.nabble.com/Processors-in-parallel-mode-tp5731613p5731618.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Processors in parallel mode

Posted by Sachin <sa...@gmail.com>.
Thanks for reply.
Yeah i can do that but only constraint is that i have so many processors and
it doesnt make much sense to convert them to routes. Is there any other way
i can run my processors concurrently? 



--
View this message in context: http://camel.465427.n5.nabble.com/Processors-in-parallel-mode-tp5731613p5731617.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Processors in parallel mode

Posted by Diether <di...@optis.be>.
You create a simple route for each processor and then use multicast or recipientlist
http://camel.apache.org/multicast.html

Something like this:
from("direct:endpoint") 
                .throttle(Long.parseLong(routeParams.get(RouteParam.THROTTLE))) 
                .setBody().body(PaymentRequest.class) 
                 .parallelProcessing() 
                 .thread(4) 
                .setHeader(ORIGINAL_REQUEST).javaScript("request.body") 
                .convertBodyTo(PaymentRequest.class) 
              .multicast().parallelProcessing().to("direct:processor1route", "direct:processor2route");


from("direct:processor1route")
 .process(processor1) ;

from("direct:processor2route")
 .process(processor2) ;

And so on.



Van: Sachin [via Camel] [ml-node+s465427n5731613h50@n5.nabble.com]

Verzonden: vrijdag 26 april 2013 14:26

To: Wuyts Diether

Onderwerp: Processors in parallel mode







Hi , 



When we set parallel processing in a route, do all processors run in parallel or in sequence?


MY requirement is that i have 5-6 processors in my route and i want then to be executed in parallel even for a single message, how can i achieve this?




from("direct:endpoint") 

                .throttle(Long.parseLong(routeParams.get(RouteParam.THROTTLE))) 

                .setBody().body(PaymentRequest.class) 

                 .parallelProcessing() 

                 .thread(4) 

                .setHeader(ORIGINAL_REQUEST).javaScript("request.body") 

                .convertBodyTo(PaymentRequest.class) 

                

                .process(processor1) 

                

                .process(processor2) 

                

                .process(processor3) 

                

                .process(processor4) 



.end() 







If you reply to this email, your message will be added to the discussion below:
http://camel.465427.n5.nabble.com/Processors-in-parallel-mode-tp5731613.html



To start a new topic under Camel - Users, email ml-node+s465427n465428h15@n5.nabble.com


To unsubscribe from Camel - Users, 
click here.

NAML








--
View this message in context: http://camel.465427.n5.nabble.com/Processors-in-parallel-mode-tp5731613p5731614.html
Sent from the Camel - Users mailing list archive at Nabble.com.