You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by cgiera <ch...@mic-cust.com> on 2014/05/20 10:49:17 UTC

beanRef is caching instances in camel 2.13.0 - unwanted behavior

Hello,

I've upgraded our application from camel 2.11.0 to camel 2.13.0.
First all looked fine, but now we are facing huge problems with all our
processes.

All our routes are caching the instances of our beans now, so we have a lot
of unwanted behavior in our application.

I've found an improvement point in jira
https://issues.apache.org/jira/browse/CAMEL-6725
which introduces the possibility of caching the instances. The documentation
says that it's defaulted to no, but even if i change our routes from
beanRef("classNameAsString","methodNameAsString") to
beanRef("classNameAsString","methodNameAsString", false) the instances of
the bean still get cached.

Could someone please check if my assumptions are correct and also has the
same behavior(then I think there is a bug)?


kind regards,
Christoph



--
View this message in context: http://camel.465427.n5.nabble.com/beanRef-is-caching-instances-in-camel-2-13-0-unwanted-behavior-tp5751335.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: beanRef is caching instances in camel 2.13.0 - unwanted behavior

Posted by cgiera <ch...@mic-cust.com>.
It is not the change of https://issues.apache.org/jira/browse/CAMEL-6725
which is causing the problems, it's the change of
https://issues.apache.org/jira/browse/CAMEL-6724.

I've changed the Registry.getBean() method to the old version and tested
some of our routes again.
Now the beans get not cached anymore.

Should I create an issue for that?

kind regards,
Christoph



--
View this message in context: http://camel.465427.n5.nabble.com/beanRef-is-caching-instances-in-camel-2-13-0-unwanted-behavior-tp5751335p5751345.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: beanRef is caching instances in camel 2.13.0 - unwanted behavior

Posted by cgiera <ch...@mic-cust.com>.
Ticket is created: https://issues.apache.org/jira/browse/CAMEL-7452

kind regards,
Christoph



--
View this message in context: http://camel.465427.n5.nabble.com/beanRef-is-caching-instances-in-camel-2-13-0-unwanted-behavior-tp5751335p5751400.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: beanRef is caching instances in camel 2.13.0 - unwanted behavior

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, May 21, 2014 at 8:46 AM, cgiera <ch...@mic-cust.com> wrote:
> We also tried
>
> bean(Myclass.class, "myMethod");
> bean(new Myclass(), "myMethod");
> beanRef(Myclass.class.getName(), "myMethod", false);
>
> They all don't work, the instance is everytime the same.
>
> Just for my understanding, I thought beanRef(...) will create a new instance
> and bean(...) will create a "singleton". This assumption is not 100% correct
> by me, or?
>
> I'll log a jira ticket.
> I'll also try to apply a patch, but here I need short help:
> As mentioned some posts above, if I change the RegistryBean.getBean() method
> back to the version before CAMEL-6724 everything works fine again.
> Do you think this is the place where the bug exists? If so, I'll investigate
> and try to get the new version running.
>

No the bean holder should be different that holds a reference to the
class type, that way it becomes a prototype. And maybe the cache
option needs to decide that too, so you can still refer to a type and
have the instance created once and cached.


> kind regards,
> Christoph
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/beanRef-is-caching-instances-in-camel-2-13-0-unwanted-behavior-tp5751335p5751398.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
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/

Re: beanRef is caching instances in camel 2.13.0 - unwanted behavior

Posted by cgiera <ch...@mic-cust.com>.
We also tried

bean(Myclass.class, "myMethod");
bean(new Myclass(), "myMethod");
beanRef(Myclass.class.getName(), "myMethod", false);

They all don't work, the instance is everytime the same.

Just for my understanding, I thought beanRef(...) will create a new instance
and bean(...) will create a "singleton". This assumption is not 100% correct
by me, or?

I'll log a jira ticket.
I'll also try to apply a patch, but here I need short help:
As mentioned some posts above, if I change the RegistryBean.getBean() method
back to the version before CAMEL-6724 everything works fine again. 
Do you think this is the place where the bug exists? If so, I'll investigate
and try to get the new version running.

kind regards,
Christoph



--
View this message in context: http://camel.465427.n5.nabble.com/beanRef-is-caching-instances-in-camel-2-13-0-unwanted-behavior-tp5751335p5751398.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: beanRef is caching instances in camel 2.13.0 - unwanted behavior

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, May 21, 2014 at 8:22 AM, cgiera <ch...@mic-cust.com> wrote:
> Yes, we use beanRef(MyBean.class.getName(), "myMethodName") in all our
> routes.
> The bean is not configured via spring and until 2.11.0 a new instance of it
> was created for each camel message.  In 2.13.0 the same instance is used for
> each camel message.
>
> Short answer: Yes :)
>

Yeah sounds like a bug, if you have cache=false, then it should do a
new lookup, and because the beanRef is a class. Though you should
ideally use

.bean(MyClass.class, "myMethod", false);

Though we dont have the cache=false method in the dsl.

Fell free to log a JIRA ticket

> kind regards,
> Christoph
>
>
> Claus Ibsen-2 wrote
>> Hi
>>
>> And your beanRef you refer to is a FQN class name (not a bean id in a
>> spring xml file or something) and you want a new instance of that FQN
>> class to be created each time (eg prototype scoped) and therefore want
>> cache disabled?
>>
>> And what you see in Camel 2.13.x is that its no longer prototype scoped?
>>
>> Is that correct?
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/beanRef-is-caching-instances-in-camel-2-13-0-unwanted-behavior-tp5751335p5751395.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
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/

Re: beanRef is caching instances in camel 2.13.0 - unwanted behavior

Posted by cgiera <ch...@mic-cust.com>.
Yes, we use beanRef(MyBean.class.getName(), "myMethodName") in all our
routes.
The bean is not configured via spring and until 2.11.0 a new instance of it
was created for each camel message.  In 2.13.0 the same instance is used for
each camel message.

Short answer: Yes :)

kind regards,
Christoph


Claus Ibsen-2 wrote
> Hi
> 
> And your beanRef you refer to is a FQN class name (not a bean id in a
> spring xml file or something) and you want a new instance of that FQN
> class to be created each time (eg prototype scoped) and therefore want
> cache disabled?
> 
> And what you see in Camel 2.13.x is that its no longer prototype scoped?
> 
> Is that correct?





--
View this message in context: http://camel.465427.n5.nabble.com/beanRef-is-caching-instances-in-camel-2-13-0-unwanted-behavior-tp5751335p5751395.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: beanRef is caching instances in camel 2.13.0 - unwanted behavior

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

And your beanRef you refer to is a FQN class name (not a bean id in a
spring xml file or something) and you want a new instance of that FQN
class to be created each time (eg prototype scoped) and therefore want
cache disabled?

And what you see in Camel 2.13.x is that its no longer prototype scoped?

Is that correct?

On Tue, May 20, 2014 at 10:49 AM, cgiera <ch...@mic-cust.com> wrote:
> Hello,
>
> I've upgraded our application from camel 2.11.0 to camel 2.13.0.
> First all looked fine, but now we are facing huge problems with all our
> processes.
>
> All our routes are caching the instances of our beans now, so we have a lot
> of unwanted behavior in our application.
>
> I've found an improvement point in jira
> https://issues.apache.org/jira/browse/CAMEL-6725
> which introduces the possibility of caching the instances. The documentation
> says that it's defaulted to no, but even if i change our routes from
> beanRef("classNameAsString","methodNameAsString") to
> beanRef("classNameAsString","methodNameAsString", false) the instances of
> the bean still get cached.
>
> Could someone please check if my assumptions are correct and also has the
> same behavior(then I think there is a bug)?
>
>
> kind regards,
> Christoph
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/beanRef-is-caching-instances-in-camel-2-13-0-unwanted-behavior-tp5751335.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
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/