You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Cristiano Costantini <cr...@gmail.com> on 2015/02/18 12:31:05 UTC

Documentation of using bean: endpoint in a

Hi All,
I discovered casually that you can use a bean endpoint in a from (I did an
error and it started out an infinite loop of exchanges)

I checked the documentation
http://camel.apache.org/bean.html
but it still says that "A bean: endpoint cannot be defined as the input to
the route",

but then I've found in this message
http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-td5743580.html
that it is instead possible and it does call the method infinitely from a
single threaded consumer!

So, is this a feature that is not documented and I can use it safely (I do
take the responsibility to control the flow in the bean with sleeps or
whatever I need to avoid infinite loops), or is this going to be removed in
a next Camel releases?
Since how long is this feature available? (I'm now usingCamel 2.13.2, I
remember I tried time ago to use a bean: in a from but I got an exception
that the route could not be initialized...)


By the way, It could be nice to add a URI parameter to bean: that enable to
slow down the maximum rate (maybe using a
ScheduledExecutorService.scheduleAtFixedRate or
ScheduledExecutorService.scheduleAtFixedDelay
from a Executors.newSingleThreadScheduledExecutor() ) and a "retry time" to
be used in case of exceptions (which could be useful as if the bean gives
an exception, it could have lost its capability to control the flow and
then as a Route designer I want to limit the impact and avoid the infinite
loop).

Thank you !
Cristiano

Re: Documentation of using bean: endpoint in a

Posted by Cristiano Costantini <cr...@gmail.com>.
...sorry I was sending my last message at the same time of you and I didn't
read your reply,

using timer with scheduler is in fact the actual way I do implement that, I
would have liked the alternative to use bean as input as it improves
readability of the routes (I mostly use the spring xml dsl).

Think of it, maybe a beansched: endpoint ;-)

Thank you very much!
Cristiano




Il giorno Wed Feb 18 2015 at 12:46:36 Cristiano Costantini <
cristiano.costantini@gmail.com> ha scritto:

> ah!
> I just discovered that Claus you did eliminated that feature 4 days ago on
> the master branch! =>
>
>
> https://github.com/apache/camel/commit/727b3a74b7383f16ae797ed58b478755d64c2693
>
> Well, can it be considered to have it, maybe on a different camel
> component (i.e. a new "beanplus:" component that extends "bean:" and ALSO
> supports consumers) together with the previous optional parameters to
> enable better control the flow of the potentially infinite loop ?
>
>
> Could you please let me know your vision so I can orient my current
> developments,
> thank you very much,
>
> Cristiano
>
>
>
> Il giorno Wed Feb 18 2015 at 12:31:07 Cristiano Costantini <
> cristiano.costantini@gmail.com> ha scritto:
>
> Hi All,
>> I discovered casually that you can use a bean endpoint in a from (I did
>> an error and it started out an infinite loop of exchanges)
>>
>> I checked the documentation
>> http://camel.apache.org/bean.html
>> but it still says that "A bean: endpoint cannot be defined as the input
>> to the route",
>>
>> but then I've found in this message
>> http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-td5743580.html
>> that it is instead possible and it does call the method infinitely from a
>> single threaded consumer!
>>
>> So, is this a feature that is not documented and I can use it safely (I
>> do take the responsibility to control the flow in the bean with sleeps or
>> whatever I need to avoid infinite loops), or is this going to be removed in
>> a next Camel releases?
>> Since how long is this feature available? (I'm now usingCamel 2.13.2, I
>> remember I tried time ago to use a bean: in a from but I got an exception
>> that the route could not be initialized...)
>>
>>
>> By the way, It could be nice to add a URI parameter to bean: that enable
>> to slow down the maximum rate (maybe using a ScheduledExecutorService.scheduleAtFixedRate
>> or ScheduledExecutorService.scheduleAtFixedDelay from a Executors.
>> newSingleThreadScheduledExecutor() ) and a "retry time" to be used in
>> case of exceptions (which could be useful as if the bean gives an
>> exception, it could have lost its capability to control the flow and then
>> as a Route designer I want to limit the impact and avoid the infinite loop).
>>
>> Thank you !
>> Cristiano
>>
>>
>>

Re: Documentation of using bean: endpoint in a

Posted by Cristiano Costantini <cr...@gmail.com>.
ah!
I just discovered that Claus you did eliminated that feature 4 days ago on
the master branch! =>

https://github.com/apache/camel/commit/727b3a74b7383f16ae797ed58b478755d64c2693

Well, can it be considered to have it, maybe on a different camel component
(i.e. a new "beanplus:" component that extends "bean:" and ALSO supports
consumers) together with the previous optional parameters to enable better
control the flow of the potentially infinite loop ?


Could you please let me know your vision so I can orient my current
developments,
thank you very much,

Cristiano



Il giorno Wed Feb 18 2015 at 12:31:07 Cristiano Costantini <
cristiano.costantini@gmail.com> ha scritto:

> Hi All,
> I discovered casually that you can use a bean endpoint in a from (I did an
> error and it started out an infinite loop of exchanges)
>
> I checked the documentation
> http://camel.apache.org/bean.html
> but it still says that "A bean: endpoint cannot be defined as the input to
> the route",
>
> but then I've found in this message
> http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-td5743580.html
> that it is instead possible and it does call the method infinitely from a
> single threaded consumer!
>
> So, is this a feature that is not documented and I can use it safely (I do
> take the responsibility to control the flow in the bean with sleeps or
> whatever I need to avoid infinite loops), or is this going to be removed in
> a next Camel releases?
> Since how long is this feature available? (I'm now usingCamel 2.13.2, I
> remember I tried time ago to use a bean: in a from but I got an exception
> that the route could not be initialized...)
>
>
> By the way, It could be nice to add a URI parameter to bean: that enable
> to slow down the maximum rate (maybe using a
> ScheduledExecutorService.scheduleAtFixedRate or ScheduledExecutorService.scheduleAtFixedDelay
> from a Executors.newSingleThreadScheduledExecutor() ) and a "retry time"
> to be used in case of exceptions (which could be useful as if the bean
> gives an exception, it could have lost its capability to control the flow
> and then as a Route designer I want to limit the impact and avoid the
> infinite loop).
>
> Thank you !
> Cristiano
>
>
>

Re: Documentation of using bean: endpoint in a

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

No it was not really intended. Its being corrected and removed from
Camel 2.15 onwards.

Use a timer or other scheduler if you want to repeat call a bean.

On Wed, Feb 18, 2015 at 12:31 PM, Cristiano Costantini
<cr...@gmail.com> wrote:
> Hi All,
> I discovered casually that you can use a bean endpoint in a from (I did an
> error and it started out an infinite loop of exchanges)
>
> I checked the documentation
> http://camel.apache.org/bean.html
> but it still says that "A bean: endpoint cannot be defined as the input to
> the route",
>
> but then I've found in this message
> http://camel.465427.n5.nabble.com/Consume-from-a-java-bean-td5743580.html
> that it is instead possible and it does call the method infinitely from a
> single threaded consumer!
>
> So, is this a feature that is not documented and I can use it safely (I do
> take the responsibility to control the flow in the bean with sleeps or
> whatever I need to avoid infinite loops), or is this going to be removed in
> a next Camel releases?
> Since how long is this feature available? (I'm now usingCamel 2.13.2, I
> remember I tried time ago to use a bean: in a from but I got an exception
> that the route could not be initialized...)
>
>
> By the way, It could be nice to add a URI parameter to bean: that enable to
> slow down the maximum rate (maybe using a
> ScheduledExecutorService.scheduleAtFixedRate or
> ScheduledExecutorService.scheduleAtFixedDelay
> from a Executors.newSingleThreadScheduledExecutor() ) and a "retry time" to
> be used in case of exceptions (which could be useful as if the bean gives
> an exception, it could have lost its capability to control the flow and
> then as a Route designer I want to limit the impact and avoid the infinite
> loop).
>
> Thank you !
> Cristiano



-- 
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
hawtio: http://hawt.io/
fabric8: http://fabric8.io/