You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by kikou1984 <hi...@atos.net> on 2013/04/02 10:02:29 UTC

recursion with Camel ?

Hi, 

I m trying to simulate recursion with camel, i tried with a Loop but it s
not the reel purpose.


public ArrayList <ArrayList <String>> simule_EclatBQE(Exchange exchange){
	
  ArrayList<ArrayList&lt;String>> lstOflst = new ArrayList <ArrayList
<String>>();
  ArrayList <String> lstOne = new ArrayList <String>();
  ArrayList <String> lstTwo = new ArrayList <String>();
		
  lstOne.add("JE CONTIENS SORTIE A AGREGGER");
  lstTwo.add("Je CONTIENS SORTIE A RETRAITER");
			
  lstOflst.add(lstOne);
  lstOflst.add(lstTwo);
	
  exchange.getOut().setHeader("ToAggregate",1);
  exchange.getOut().setBody(lstOflst);
		 
  return lstOflst;
		
	}

I got this Bean, I want to re loop on this processor , but the In Body
should be the Out Body for the first iteration. 

Is it possible to make it with camel ? 

Thxs.



--
View this message in context: http://camel.465427.n5.nabble.com/recursion-with-Camel-tp5730193.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: recursion with Camel ?

Posted by kikou1984 <hi...@atos.net>.
Hi,

I don t think i need a dynamic routes , i only want make a recursive form to
my Bean.
 

The output of the bean, should be  injected as input of the same bean !!!
like the exemple below.

If i have to use dynamic routes, how can i do , i read on the website but i
didn't understand how can i used for my case.


Txhs



--
View this message in context: http://camel.465427.n5.nabble.com/recursion-with-Camel-tp5730193p5730219.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: recursion with Camel ?

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

I suggest looking at the dynamic router eip


On Tue, Apr 2, 2013 at 10:02 AM, kikou1984 <hi...@atos.net> wrote:
> Hi,
>
> I m trying to simulate recursion with camel, i tried with a Loop but it s
> not the reel purpose.
>
>
> public ArrayList <ArrayList <String>> simule_EclatBQE(Exchange exchange){
>
>   ArrayList<ArrayList&lt;String>> lstOflst = new ArrayList <ArrayList
> <String>>();
>   ArrayList <String> lstOne = new ArrayList <String>();
>   ArrayList <String> lstTwo = new ArrayList <String>();
>
>   lstOne.add("JE CONTIENS SORTIE A AGREGGER");
>   lstTwo.add("Je CONTIENS SORTIE A RETRAITER");
>
>   lstOflst.add(lstOne);
>   lstOflst.add(lstTwo);
>
>   exchange.getOut().setHeader("ToAggregate",1);
>   exchange.getOut().setBody(lstOflst);
>
>   return lstOflst;
>
>         }
>
> I got this Bean, I want to re loop on this processor , but the In Body
> should be the Out Body for the first iteration.
>
> Is it possible to make it with camel ?
>
> Thxs.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/recursion-with-Camel-tp5730193.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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

Re: recursion with Camel ?

Posted by kikou1984 <hi...@atos.net>.
Hi,

Thxs for u r answer , i tried it and it works. sometimes  , I complicates
things.



--
View this message in context: http://camel.465427.n5.nabble.com/recursion-with-Camel-tp5730193p5730226.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: recursion with Camel ?

Posted by "valerian.merkling" <va...@capgemini.com>.
Why don't you just make your processor call a recursive function ? 

A processor isn't made to be able to invoke another processor, you need to
make it recursive with your route


<bean id="myrecursivebean" class="..."/>

<camelContext errorHandlerRef="errorHandler"
xmlns="http://camel.apache.org/schema/spring">
    <route>
        <from uri="direct:a"/>
        <choice>
            <when>
                <simple>$in.header.continue = 'true'</simple>
                <to uri="myrecursivebean"/>
                <to uri="direct:a"/>
            </when>
            <otherwise>
                <to uri="direct:b"/>
            </otherwise>
        </choice>
    </route>
</camelContext>



--
View this message in context: http://camel.465427.n5.nabble.com/recursion-with-Camel-tp5730193p5730224.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: recursion with Camel ?

Posted by kikou1984 <hi...@atos.net>.
Hi,

Actually, i want to restart this bean each time by changing the body.

Here an exemple,

public void simule_EclatBQE(Exchange exchange){ 

     List<String> in_lst = new ArrayList<String>();
     in_lst  = (List<String>) exchange.getIn().getBody();

    //treatment
    ArrayList<ArrayList&lt;String>> out_lstOflst = new ArrayList <ArrayList
<String>>();
    ArrayList <String> lstOne = new ArrayList <String>();
    ArrayList <String> lstTwo = new ArrayList <String>();
	   
    lstOne.add("JE CONTIENS SORTIE A AGREGGER");
    lstTwo.add("Je CONTIENS SORTIE A RETRAITER");
			
    out_lstOflst.add(lstOne);
    out_lstOflst.add(lstTwo);
		
     exchange.getOut().setBody(out_lstOflst.get(1));
}

Then, The bean simule_EclatBQE should restart and it should take
out_lstOflst.get(1) in its input.

How can i make it ? 

Thxs




--
View this message in context: http://camel.465427.n5.nabble.com/recursion-with-Camel-tp5730193p5730202.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: recursion with Camel ?

Posted by Willem jiang <wi...@gmail.com>.
Hi,

I'm not quite understand you question.
Do you want to write a unit test or you just want to call this process in the camel route with loop?


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Tuesday, April 2, 2013 at 4:02 PM, kikou1984 wrote:

> Hi,  
>  
> I m trying to simulate recursion with camel, i tried with a Loop but it s
> not the reel purpose.
>  
>  
> public ArrayList <ArrayList <String>> simule_EclatBQE(Exchange exchange){
>  
> ArrayList<ArrayList&lt;String>> lstOflst = new ArrayList <ArrayList
> <String>>();
> ArrayList <String> lstOne = new ArrayList <String>();
> ArrayList <String> lstTwo = new ArrayList <String>();
>  
> lstOne.add("JE CONTIENS SORTIE A AGREGGER");
> lstTwo.add("Je CONTIENS SORTIE A RETRAITER");
>  
> lstOflst.add(lstOne);
> lstOflst.add(lstTwo);
>  
> exchange.getOut().setHeader("ToAggregate",1);
> exchange.getOut().setBody(lstOflst);
>  
> return lstOflst;
>  
> }
>  
> I got this Bean, I want to re loop on this processor , but the In Body
> should be the Out Body for the first iteration.  
>  
> Is it possible to make it with camel ?  
>  
> Thxs.
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/recursion-with-Camel-tp5730193.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).