You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Achim Nierbeck <bc...@googlemail.com> on 2011/09/13 10:57:19 UTC

Recursive Calls and CXF

Hi,

I'm using Camel 2.8 in conjunction with camel-cxf.

Now I have the following scenario.

I have 2 specialized .NET services which do server me the following two services

- doSomeSpecialHandling
-- this is a rather lengthy process running which returns right after
start and keeps on processing

- checkStatus
-- checks if the other process is still running


For the second service I have a speicalized route which looks like this:


		<camel:route id="checkRoute">
			<camel:from uri="direct:checkRoute" />
			<camel:setBody>
				<camel:mvel>[ ]</camel:mvel>
			</camel:setBody>
			<camel:doTry>
				<camel:recipientList parallelProcessing="true">
					<camel:simple>cxf:bean:productionServer?address=${header.address}&amp;wrappedStyle=true</camel:simple>
				</camel:recipientList>
				<camel:choice>
					<camel:when>
						<camel:mvel>
						<![CDATA[request.body[0] != 'Success' && request.body[0] !=
'Failure' && request.body[0] != 'Unknown']]>
					</camel:mvel>
						<delay>
							<constant>5000</constant>
						</delay>
						<camel:to uri="direct:checkRoute" />
					</camel:when>
				</camel:choice>
				<camel:doCatch>
					<camel:exception>java.lang.Exception</camel:exception>
					<camel:to uri="direct:handleException" />
				</camel:doCatch>
			</camel:doTry>
		</camel:route>

This Route runs recursively, after a while if the underlying system
takes to long, I'll run into a problem cause the stack runs full due
to the recursive calls.
Is there a way of looping with an unknown end? Cause the looping
component only loops for n-iterations where n needs to be known
beforehand. Basically I'm trying to
do a while(condition) loop with camel :)

Any Idea is welcome.

Thanks, Achim

Re: Recursive Calls and CXF

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Sep 14, 2011 at 11:17 AM, Achim Nierbeck
<bc...@googlemail.com> wrote:
> Hi Claus,
>
> yeah, that could be helpfull :)
> Any timeline on this ;)
>
> On the other hand I'm wondering if there might be a more elegant way
> of calling these WebServices that I just didn't think of yet.
>

The error handler / onException should have a retryWhile predicate.
So you can have it retry until the web service respond with an OK, or
if you have some failsafe after 100+ attempts :)

See examples here:
http://camel.apache.org/exception-clause.html



> regards, Achim
>
> 2011/9/13 Claus Ibsen <cl...@gmail.com>:
>> Hi
>>
>> Yeah the loop EIP should be improved to support a "do while" style as
>> well. I have a vague memory of a JIRA ticket about this.
>> Then you should be able to specify a predicate instead of the fixed number.
>>
>>
>>
>> On Tue, Sep 13, 2011 at 10:57 AM, Achim Nierbeck
>> <bc...@googlemail.com> wrote:
>>> Hi,
>>>
>>> I'm using Camel 2.8 in conjunction with camel-cxf.
>>>
>>> Now I have the following scenario.
>>>
>>> I have 2 specialized .NET services which do server me the following two services
>>>
>>> - doSomeSpecialHandling
>>> -- this is a rather lengthy process running which returns right after
>>> start and keeps on processing
>>>
>>> - checkStatus
>>> -- checks if the other process is still running
>>>
>>>
>>> For the second service I have a speicalized route which looks like this:
>>>
>>>
>>>                <camel:route id="checkRoute">
>>>                        <camel:from uri="direct:checkRoute" />
>>>                        <camel:setBody>
>>>                                <camel:mvel>[ ]</camel:mvel>
>>>                        </camel:setBody>
>>>                        <camel:doTry>
>>>                                <camel:recipientList parallelProcessing="true">
>>>                                        <camel:simple>cxf:bean:productionServer?address=${header.address}&amp;wrappedStyle=true</camel:simple>
>>>                                </camel:recipientList>
>>>                                <camel:choice>
>>>                                        <camel:when>
>>>                                                <camel:mvel>
>>>                                                <![CDATA[request.body[0] != 'Success' && request.body[0] !=
>>> 'Failure' && request.body[0] != 'Unknown']]>
>>>                                        </camel:mvel>
>>>                                                <delay>
>>>                                                        <constant>5000</constant>
>>>                                                </delay>
>>>                                                <camel:to uri="direct:checkRoute" />
>>>                                        </camel:when>
>>>                                </camel:choice>
>>>                                <camel:doCatch>
>>>                                        <camel:exception>java.lang.Exception</camel:exception>
>>>                                        <camel:to uri="direct:handleException" />
>>>                                </camel:doCatch>
>>>                        </camel:doTry>
>>>                </camel:route>
>>>
>>> This Route runs recursively, after a while if the underlying system
>>> takes to long, I'll run into a problem cause the stack runs full due
>>> to the recursive calls.
>>> Is there a way of looping with an unknown end? Cause the looping
>>> component only loops for n-iterations where n needs to be known
>>> beforehand. Basically I'm trying to
>>> do a while(condition) loop with camel :)
>>>
>>> Any Idea is welcome.
>>>
>>> Thanks, Achim
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>
>
>
>
> --
> --
> *Achim Nierbeck*
>
>
> Apache Karaf <http://karaf.apache.org/> Committer & PMC
> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
> Committer & Project Lead
> blog <http://notizblog.nierbeck.de/>
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Recursive Calls and CXF

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi Claus,

yeah, that could be helpfull :)
Any timeline on this ;)

On the other hand I'm wondering if there might be a more elegant way
of calling these WebServices that I just didn't think of yet.

regards, Achim

2011/9/13 Claus Ibsen <cl...@gmail.com>:
> Hi
>
> Yeah the loop EIP should be improved to support a "do while" style as
> well. I have a vague memory of a JIRA ticket about this.
> Then you should be able to specify a predicate instead of the fixed number.
>
>
>
> On Tue, Sep 13, 2011 at 10:57 AM, Achim Nierbeck
> <bc...@googlemail.com> wrote:
>> Hi,
>>
>> I'm using Camel 2.8 in conjunction with camel-cxf.
>>
>> Now I have the following scenario.
>>
>> I have 2 specialized .NET services which do server me the following two services
>>
>> - doSomeSpecialHandling
>> -- this is a rather lengthy process running which returns right after
>> start and keeps on processing
>>
>> - checkStatus
>> -- checks if the other process is still running
>>
>>
>> For the second service I have a speicalized route which looks like this:
>>
>>
>>                <camel:route id="checkRoute">
>>                        <camel:from uri="direct:checkRoute" />
>>                        <camel:setBody>
>>                                <camel:mvel>[ ]</camel:mvel>
>>                        </camel:setBody>
>>                        <camel:doTry>
>>                                <camel:recipientList parallelProcessing="true">
>>                                        <camel:simple>cxf:bean:productionServer?address=${header.address}&amp;wrappedStyle=true</camel:simple>
>>                                </camel:recipientList>
>>                                <camel:choice>
>>                                        <camel:when>
>>                                                <camel:mvel>
>>                                                <![CDATA[request.body[0] != 'Success' && request.body[0] !=
>> 'Failure' && request.body[0] != 'Unknown']]>
>>                                        </camel:mvel>
>>                                                <delay>
>>                                                        <constant>5000</constant>
>>                                                </delay>
>>                                                <camel:to uri="direct:checkRoute" />
>>                                        </camel:when>
>>                                </camel:choice>
>>                                <camel:doCatch>
>>                                        <camel:exception>java.lang.Exception</camel:exception>
>>                                        <camel:to uri="direct:handleException" />
>>                                </camel:doCatch>
>>                        </camel:doTry>
>>                </camel:route>
>>
>> This Route runs recursively, after a while if the underlying system
>> takes to long, I'll run into a problem cause the stack runs full due
>> to the recursive calls.
>> Is there a way of looping with an unknown end? Cause the looping
>> component only loops for n-iterations where n needs to be known
>> beforehand. Basically I'm trying to
>> do a while(condition) loop with camel :)
>>
>> Any Idea is welcome.
>>
>> Thanks, Achim
>>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>



-- 
--
*Achim Nierbeck*


Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
Committer & Project Lead
blog <http://notizblog.nierbeck.de/>

Re: Recursive Calls and CXF

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

Yeah the loop EIP should be improved to support a "do while" style as
well. I have a vague memory of a JIRA ticket about this.
Then you should be able to specify a predicate instead of the fixed number.



On Tue, Sep 13, 2011 at 10:57 AM, Achim Nierbeck
<bc...@googlemail.com> wrote:
> Hi,
>
> I'm using Camel 2.8 in conjunction with camel-cxf.
>
> Now I have the following scenario.
>
> I have 2 specialized .NET services which do server me the following two services
>
> - doSomeSpecialHandling
> -- this is a rather lengthy process running which returns right after
> start and keeps on processing
>
> - checkStatus
> -- checks if the other process is still running
>
>
> For the second service I have a speicalized route which looks like this:
>
>
>                <camel:route id="checkRoute">
>                        <camel:from uri="direct:checkRoute" />
>                        <camel:setBody>
>                                <camel:mvel>[ ]</camel:mvel>
>                        </camel:setBody>
>                        <camel:doTry>
>                                <camel:recipientList parallelProcessing="true">
>                                        <camel:simple>cxf:bean:productionServer?address=${header.address}&amp;wrappedStyle=true</camel:simple>
>                                </camel:recipientList>
>                                <camel:choice>
>                                        <camel:when>
>                                                <camel:mvel>
>                                                <![CDATA[request.body[0] != 'Success' && request.body[0] !=
> 'Failure' && request.body[0] != 'Unknown']]>
>                                        </camel:mvel>
>                                                <delay>
>                                                        <constant>5000</constant>
>                                                </delay>
>                                                <camel:to uri="direct:checkRoute" />
>                                        </camel:when>
>                                </camel:choice>
>                                <camel:doCatch>
>                                        <camel:exception>java.lang.Exception</camel:exception>
>                                        <camel:to uri="direct:handleException" />
>                                </camel:doCatch>
>                        </camel:doTry>
>                </camel:route>
>
> This Route runs recursively, after a while if the underlying system
> takes to long, I'll run into a problem cause the stack runs full due
> to the recursive calls.
> Is there a way of looping with an unknown end? Cause the looping
> component only loops for n-iterations where n needs to be known
> beforehand. Basically I'm trying to
> do a while(condition) loop with camel :)
>
> Any Idea is welcome.
>
> Thanks, Achim
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/