On Tue, Jun 12, 2012 at 6:36 PM, Edwin <edwin.rabbi...@gmail.com> wrote:
> Hi > > My consumer monitors the state of a vendor product via an API which the > vendor provides. > > My consumer needs to run in its own thread. The logic in the consumer > method > will look something like: > > MyConsumer extends DefaultConsumer{ > > public void method1(){ > vendorStatsOK = true; > while (vendorStatsOK){ > //BLOCKING CALL > Message msg = VendorAPI.waitForMessage(); > Exchange exchange = endpoint.createExchange(); > exchange.getIn().setBody(msg); > getProcessor().process(exchange); > .... > } > > } > } > > Since the call to the vendor API is a blocking call, I am thinking the > ScheduledPollConsumer is not a good fit. I cannot use the event driven > consumer either as the vendor product will not invoke my method > > Hence, I am trying to figure out the best way to have my consumer run its > own thread, i.e. have method1 invoked in a separate thread. > > Just create a single threaded executor service, and submit a task to it. Then it runs in a separate thread. Camel has APIs to create the executor service, and to shutdown it as well. This allows you to have the thread pool enlisted in JMX, as well having thread naming pattern and whatnot. See details at http://camel.apache.org/threading-model.html > Thanks! > Edwin > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Camel-Component-Consumer-Threading-Question-tp5714233p5714377.html > Sent from the Camel - Users mailing list archive at Nabble.com. > -- Claus Ibsen ----------------- FuseSource Email: cib...@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen