I'm not a super expert in this area, but since you are building a @Component 
you could maybe use the async capability of Camel processors.

There's a decent explanation and example in the Camel in Action 2nd edition.

-Steve

> -----Original Message-----
> From: Robson Vargas Farias [mailto:robsonvargasfar...@gmail.com]
> Sent: Thursday, October 19, 2017 7:44 PM
> To: users@camel.apache.org
> Subject: One-way handler processing
> 
> hey guys, I'm facing an issue using @Handler.
> 
> Currently I've a route that get messages from a MQ and send to a bean
> annotated with @Handler, this bean instantiate a new Spring prototype bean
> (programatically) and process the message - just to have the processing
> happening in a different thread and avoid conflicts among multiple queues
> accessing this handler bean, that´s generic.
> 
> The issue happens with the throttle configuration, that is not working
> properly, because the thread is released only when the Handler completes
> its processing.
> 
> My idea is turn this processing asynchronous using Spring's @Async, but I'd
> like to hear from you if there´s any other "Camel" way idea to use in place?
> 
> My bean is like:
> 
> @Component("processor_handler_endpoint")
> class MyBean {
> 
>    @Handler
>    method(Exchange e) {
>       SpringFactory.createNewPrototypeOf(ProcessorClass.class).process(e);
>    }
> 
> }
> 
> My route is like:
> 
> <!-- MyQueue MQ Configuration -->
> 
> <camel:route id="MyQueue_route"
> autoStartup="{{MyQueue_config.queue.enabled}}">
> <camel:from ref="MyQueue_mq_endpoint" /> <camel:throttle
> timePeriodMillis="1000">
> <camel:simple>${properties:MyQueue_config.throttle.request_per_second
> }</camel:simple>
> <camel:setHeader headerName="feed_staging_type_id">
> <camel:simple>${properties:MyQueue_config.header.feed_staging_type_id
> .value}
> </camel:simple>
> </camel:setHeader>
> <camel:to ref="processor_handler_endpoint" /> </camel:throttle>
> </camel:route>

Reply via email to