You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Joe Osowski <jo...@gmail.com> on 2013/10/17 01:40:58 UTC

Best practice question

Dear Camel users.

Given the following DSL.  What would be the best way to execute a task
when all the below processing is complete?

Specifically, I have a second long running task that needs to get
queued as soon as  FOO2_QUEUE is complete.

    from(FOO_QUEUE)
      .to("bean:service?method=getFoo(${body})")
      .process(new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
          //All we care about is the citedArticle IDs list
          List<Long> ids = exchange.getIn().getBody(Foo.class).getIDs();
          exchange.getOut().setBody(ids);
        }
      })
      .split().body() //Create a job for each ID
      .to(FOO2_QUEUE)

    from(FOO2_QUEUE)
      .to("bean:service?method=foo");

Re: Best practice question

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah you can also take a look at on completion
http://camel.apache.org/oncompletion.html

On Thu, Oct 17, 2013 at 2:37 AM, Henrique Viecili <vi...@gmail.com> wrote:
> Hi Joe,
>
> take a look at
> http://camel.apache.org/splitter.html#Splitter-Splitaggregaterequest%2Freplysample
> ,
> after you end() your split do a wireTap to the second long running task.
> (assuming the exchange pattern is InOut)
>
> Cheers,
> Henrique
>
> Henrique Viecili
>
>
> 2013/10/17 Joe Osowski <jo...@gmail.com>
>
>> Dear Camel users.
>>
>> Given the following DSL.  What would be the best way to execute a task
>> when all the below processing is complete?
>>
>> Specifically, I have a second long running task that needs to get
>> queued as soon as  FOO2_QUEUE is complete.
>>
>>     from(FOO_QUEUE)
>>       .to("bean:service?method=getFoo(${body})")
>>       .process(new Processor() {
>>         @Override
>>         public void process(Exchange exchange) throws Exception {
>>           //All we care about is the citedArticle IDs list
>>           List<Long> ids = exchange.getIn().getBody(Foo.class).getIDs();
>>           exchange.getOut().setBody(ids);
>>         }
>>       })
>>       .split().body() //Create a job for each ID
>>       .to(FOO2_QUEUE)
>>
>>     from(FOO2_QUEUE)
>>       .to("bean:service?method=foo");
>>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Best practice question

Posted by Henrique Viecili <vi...@gmail.com>.
Hi Joe,

take a look at
http://camel.apache.org/splitter.html#Splitter-Splitaggregaterequest%2Freplysample
,
after you end() your split do a wireTap to the second long running task.
(assuming the exchange pattern is InOut)

Cheers,
Henrique

Henrique Viecili


2013/10/17 Joe Osowski <jo...@gmail.com>

> Dear Camel users.
>
> Given the following DSL.  What would be the best way to execute a task
> when all the below processing is complete?
>
> Specifically, I have a second long running task that needs to get
> queued as soon as  FOO2_QUEUE is complete.
>
>     from(FOO_QUEUE)
>       .to("bean:service?method=getFoo(${body})")
>       .process(new Processor() {
>         @Override
>         public void process(Exchange exchange) throws Exception {
>           //All we care about is the citedArticle IDs list
>           List<Long> ids = exchange.getIn().getBody(Foo.class).getIDs();
>           exchange.getOut().setBody(ids);
>         }
>       })
>       .split().body() //Create a job for each ID
>       .to(FOO2_QUEUE)
>
>     from(FOO2_QUEUE)
>       .to("bean:service?method=foo");
>