Asynchronous Processing

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Asynchronous Processing

shtek
This post has NOT been accepted by the mailing list yet.
Hi,
I am following the link  http://camel.apache.org/asynchronous-processing.html  which explains how to create an asynchronous process. I need to have a route which writes to DB asynchronously.
Here is my original route synchronous:

from("tibcoOut:topic:134").transacted().("bean:OutboundDataAccess").to(....)


here is my attempt to make it asynch:

from("tibcoOut:topic:134").transacted().threads().process(new OutboundDataAccess()).to(...)
almost worked but because my OutboundDataAccess contains some dependency which I currently inject via Spring it has null pointer exceptions because the param "outbound" are not initialized ( see the class code below).

Can someone provide syntax which will do the trick.





public class OutboundDataAccess implements AsyncProcessor {

        private InboundDao outbound;

        public void seOutbound(nboundDao outbound) {
                this.Outbound = Outbound;
        }

        @Override
        public boolean process(Exchange exchange, AsyncCallback callback) {
               
                System.out.println("inside ???? !!!!!!!!!!!!!!!!!!");
       
                return true;
        }


        @Override
        public void process(Exchange exchange) throws Exception {
                System.out.println("inside what am i 9999999999999999999999");
               
        }

}
Reply | Threaded
Open this post in threaded view
|

Re: Asynchronous Processing

Charles Moulliard
Just a remark. If you use an async processor, then your route cannot be transactional as Camel 2.x does not support Async Spring Tx (http://camel.apache.org/camel-30-roadmap.html).

Regards,

Charles
Apache Committer
Twitter: @cmoulliard
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com