You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ariekenb <aa...@lmco.com> on 2009/06/24 20:50:22 UTC

@Consume creates multiple consumers when using multiple camel contexts

I just stumbled into an issue where using an @Consume annotation on a bean
ended up creating 2 consumers when that bean was deployed in an OSGi bundle
containing 2 camel contexts.

It appears 1 consumer is created for each @Consume annotation for each
context, even if the endpoint the @Consume references is only present in one
of the contexts.

This can cause not very obvious threading problems - a consumer might
unexpectedly receive messages in multiple threads if a new camel context is
added to the bundle.

I don't see any way to explicitly bind @Consume to a particular context. 
Has anyone ever considered adding an option to the annotation to specify a
context name?

Thanks,
Aaron
-- 
View this message in context: http://www.nabble.com/%40Consume-creates-multiple-consumers-when-using-multiple-camel-contexts-tp24190660p24190660.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: @Consume creates multiple consumers when using multiple camel contexts

Posted by Claus Ibsen <cl...@gmail.com>.
On Sun, Jun 28, 2009 at 11:29 PM, ariekenb<aa...@lmco.com> wrote:
>
> Thanks Claus for the fast investigation and fix!
>
> It looks like trunk is not building right now (the latest downloadable
> snapshot is from June 23).  I will try your fix when things are working
> again.

Hi

Damn the apache snapshot repo have an iusse. The maven metadata is
outdated, pointing to some old .jars instead of just -SNAPSHOT.

The fuse repo does not have this issue so if you are eager to test it
you can try it instead. Its just a matter of changing the <version> in
maven pom.xml and add a new repo location. See more at:
http://davsclaus.blogspot.com/2009/02/how-to-use-fuse-releases-when-you-cant.html

>
> Thanks again,
> Aaron
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>> I have commited a fix on camel trunk (eg 2.0)
>>
>> If possible could you test it in your environment? You can grap the source
>> and build or get a SNAPSHOT from a maven repo when its updated.
>> Details at Camel download page
>>
>>
>> On Thu, Jun 25, 2009 at 10:19 AM, Claus Ibsen <cl...@gmail.com>
>> wrote:
>>
>>> Hi
>>> I created a ticket to track this
>>> https://issues.apache.org/activemq/browse/CAMEL-1758
>>>
>>> And is currently working on implementing it.
>>>
>>> A new context attribute is added to the various annotations that
>>> allows you to specify a particular camel context id it should apply.
>>>
>>>
>>>
>>> On Thu, Jun 25, 2009 at 7:33 AM, Claus Ibsen <cl...@gmail.com>
>>> wrote:
>>> >
>>> >
>>> > On Wed, Jun 24, 2009 at 8:50 PM, ariekenb <aa...@lmco.com>
>>> wrote:
>>> >>
>>> >> I just stumbled into an issue where using an @Consume annotation on a
>>> bean
>>> >> ended up creating 2 consumers when that bean was deployed in an OSGi
>>> bundle
>>> >> containing 2 camel contexts.
>>> >>
>>> >> It appears 1 consumer is created for each @Consume annotation for each
>>> >> context, even if the endpoint the @Consume references is only present
>>> in
>>> one
>>> >> of the contexts.
>>> >
>>> > @Consume will create the endpoint if not already defined in the camel
>>> context.
>>> > And I assume @Consume is in some code that is shared between multiple
>>> camel contexts?
>>> > And that you have <package> to scan in the same classpaths in your
>>> camel
>>> context configurations?
>>> > If you set the <package> to use different classpaths then you can
>>> control
>>> which camel context
>>> > that looks into which packages.
>>> >
>>> >>
>>> >> This can cause not very obvious threading problems - a consumer might
>>> >> unexpectedly receive messages in multiple threads if a new camel
>>> context
>>> is
>>> >> added to the bundle.
>>> >>
>>> >> I don't see any way to explicitly bind @Consume to a particular
>>> context.
>>> >> Has anyone ever considered adding an option to the annotation to
>>> specify
>>> a
>>> >> context name?
>>> >
>>> > Yeah that could be a good idea to add some sort of qualifier or context
>>> option to limit
>>> > it a certain context. But an option like: context="camel-1" would do
>>> for
>>> now I think.
>>> >
>>> >>
>>> >> Thanks,
>>> >> Aaron
>>> >> --
>>> >> View this message in context:
>>> http://www.nabble.com/%40Consume-creates-multiple-consumers-when-using-multiple-camel-contexts-tp24190660p24190660.html
>>> >> Sent from the Camel - Users mailing list archive at Nabble.com.
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > Claus Ibsen
>>> > Apache Camel Committer
>>> >
>>> > Open Source Integration: http://fusesource.com
>>> > Blog: http://davsclaus.blogspot.com/
>>> > Twitter: http://twitter.com/davsclaus
>>> >
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://www.nabble.com/%40Consume-creates-multiple-consumers-when-using-multiple-camel-contexts-tp24190660p24245681.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: @Consume creates multiple consumers when using multiple camel contexts

Posted by ariekenb <aa...@lmco.com>.
Thanks Claus for the fast investigation and fix!

It looks like trunk is not building right now (the latest downloadable
snapshot is from June 23).  I will try your fix when things are working
again.

Thanks again,
Aaron


Claus Ibsen-2 wrote:
> 
> Hi
> I have commited a fix on camel trunk (eg 2.0)
> 
> If possible could you test it in your environment? You can grap the source
> and build or get a SNAPSHOT from a maven repo when its updated.
> Details at Camel download page
> 
> 
> On Thu, Jun 25, 2009 at 10:19 AM, Claus Ibsen <cl...@gmail.com>
> wrote:
> 
>> Hi
>> I created a ticket to track this
>> https://issues.apache.org/activemq/browse/CAMEL-1758
>>
>> And is currently working on implementing it.
>>
>> A new context attribute is added to the various annotations that
>> allows you to specify a particular camel context id it should apply.
>>
>>
>>
>> On Thu, Jun 25, 2009 at 7:33 AM, Claus Ibsen <cl...@gmail.com>
>> wrote:
>> >
>> >
>> > On Wed, Jun 24, 2009 at 8:50 PM, ariekenb <aa...@lmco.com>
>> wrote:
>> >>
>> >> I just stumbled into an issue where using an @Consume annotation on a
>> bean
>> >> ended up creating 2 consumers when that bean was deployed in an OSGi
>> bundle
>> >> containing 2 camel contexts.
>> >>
>> >> It appears 1 consumer is created for each @Consume annotation for each
>> >> context, even if the endpoint the @Consume references is only present
>> in
>> one
>> >> of the contexts.
>> >
>> > @Consume will create the endpoint if not already defined in the camel
>> context.
>> > And I assume @Consume is in some code that is shared between multiple
>> camel contexts?
>> > And that you have <package> to scan in the same classpaths in your
>> camel
>> context configurations?
>> > If you set the <package> to use different classpaths then you can
>> control
>> which camel context
>> > that looks into which packages.
>> >
>> >>
>> >> This can cause not very obvious threading problems - a consumer might
>> >> unexpectedly receive messages in multiple threads if a new camel
>> context
>> is
>> >> added to the bundle.
>> >>
>> >> I don't see any way to explicitly bind @Consume to a particular
>> context.
>> >> Has anyone ever considered adding an option to the annotation to
>> specify
>> a
>> >> context name?
>> >
>> > Yeah that could be a good idea to add some sort of qualifier or context
>> option to limit
>> > it a certain context. But an option like: context="camel-1" would do
>> for
>> now I think.
>> >
>> >>
>> >> Thanks,
>> >> Aaron
>> >> --
>> >> View this message in context:
>> http://www.nabble.com/%40Consume-creates-multiple-consumers-when-using-multiple-camel-contexts-tp24190660p24190660.html
>> >> Sent from the Camel - Users mailing list archive at Nabble.com.
>> >>
>> >
>> >
>> >
>> > --
>> > Claus Ibsen
>> > Apache Camel Committer
>> >
>> > Open Source Integration: http://fusesource.com
>> > Blog: http://davsclaus.blogspot.com/
>> > Twitter: http://twitter.com/davsclaus
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://www.nabble.com/%40Consume-creates-multiple-consumers-when-using-multiple-camel-contexts-tp24190660p24245681.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: @Consume creates multiple consumers when using multiple camel contexts

Posted by Claus Ibsen <cl...@gmail.com>.
Hi
I have commited a fix on camel trunk (eg 2.0)

If possible could you test it in your environment? You can grap the source
and build or get a SNAPSHOT from a maven repo when its updated.
Details at Camel download page


On Thu, Jun 25, 2009 at 10:19 AM, Claus Ibsen <cl...@gmail.com> wrote:

> Hi
> I created a ticket to track this
> https://issues.apache.org/activemq/browse/CAMEL-1758
>
> And is currently working on implementing it.
>
> A new context attribute is added to the various annotations that
> allows you to specify a particular camel context id it should apply.
>
>
>
> On Thu, Jun 25, 2009 at 7:33 AM, Claus Ibsen <cl...@gmail.com>
> wrote:
> >
> >
> > On Wed, Jun 24, 2009 at 8:50 PM, ariekenb <aa...@lmco.com>
> wrote:
> >>
> >> I just stumbled into an issue where using an @Consume annotation on a
> bean
> >> ended up creating 2 consumers when that bean was deployed in an OSGi
> bundle
> >> containing 2 camel contexts.
> >>
> >> It appears 1 consumer is created for each @Consume annotation for each
> >> context, even if the endpoint the @Consume references is only present in
> one
> >> of the contexts.
> >
> > @Consume will create the endpoint if not already defined in the camel
> context.
> > And I assume @Consume is in some code that is shared between multiple
> camel contexts?
> > And that you have <package> to scan in the same classpaths in your camel
> context configurations?
> > If you set the <package> to use different classpaths then you can control
> which camel context
> > that looks into which packages.
> >
> >>
> >> This can cause not very obvious threading problems - a consumer might
> >> unexpectedly receive messages in multiple threads if a new camel context
> is
> >> added to the bundle.
> >>
> >> I don't see any way to explicitly bind @Consume to a particular context.
> >> Has anyone ever considered adding an option to the annotation to specify
> a
> >> context name?
> >
> > Yeah that could be a good idea to add some sort of qualifier or context
> option to limit
> > it a certain context. But an option like: context="camel-1" would do for
> now I think.
> >
> >>
> >> Thanks,
> >> Aaron
> >> --
> >> View this message in context:
> http://www.nabble.com/%40Consume-creates-multiple-consumers-when-using-multiple-camel-contexts-tp24190660p24190660.html
> >> Sent from the Camel - Users mailing list archive at Nabble.com.
> >>
> >
> >
> >
> > --
> > Claus Ibsen
> > Apache Camel Committer
> >
> > Open Source Integration: http://fusesource.com
> > Blog: http://davsclaus.blogspot.com/
> > Twitter: http://twitter.com/davsclaus
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: @Consume creates multiple consumers when using multiple camel contexts

Posted by Claus Ibsen <cl...@gmail.com>.
Hi
I created a ticket to track this
https://issues.apache.org/activemq/browse/CAMEL-1758

And is currently working on implementing it.

A new context attribute is added to the various annotations that
allows you to specify a particular camel context id it should apply.



On Thu, Jun 25, 2009 at 7:33 AM, Claus Ibsen <cl...@gmail.com> wrote:
>
>
> On Wed, Jun 24, 2009 at 8:50 PM, ariekenb <aa...@lmco.com> wrote:
>>
>> I just stumbled into an issue where using an @Consume annotation on a bean
>> ended up creating 2 consumers when that bean was deployed in an OSGi bundle
>> containing 2 camel contexts.
>>
>> It appears 1 consumer is created for each @Consume annotation for each
>> context, even if the endpoint the @Consume references is only present in one
>> of the contexts.
>
> @Consume will create the endpoint if not already defined in the camel context.
> And I assume @Consume is in some code that is shared between multiple camel contexts?
> And that you have <package> to scan in the same classpaths in your camel context configurations?
> If you set the <package> to use different classpaths then you can control which camel context
> that looks into which packages.
>
>>
>> This can cause not very obvious threading problems - a consumer might
>> unexpectedly receive messages in multiple threads if a new camel context is
>> added to the bundle.
>>
>> I don't see any way to explicitly bind @Consume to a particular context.
>> Has anyone ever considered adding an option to the annotation to specify a
>> context name?
>
> Yeah that could be a good idea to add some sort of qualifier or context option to limit
> it a certain context. But an option like: context="camel-1" would do for now I think.
>
>>
>> Thanks,
>> Aaron
>> --
>> View this message in context: http://www.nabble.com/%40Consume-creates-multiple-consumers-when-using-multiple-camel-contexts-tp24190660p24190660.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



--
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: @Consume creates multiple consumers when using multiple camel contexts

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jun 24, 2009 at 8:50 PM, ariekenb <aa...@lmco.com>wrote:

>
> I just stumbled into an issue where using an @Consume annotation on a bean
> ended up creating 2 consumers when that bean was deployed in an OSGi bundle
> containing 2 camel contexts.
>
> It appears 1 consumer is created for each @Consume annotation for each
> context, even if the endpoint the @Consume references is only present in
> one
> of the contexts.


@Consume will create the endpoint if not already defined in the camel
context.

And I assume @Consume is in some code that is shared between multiple camel
contexts?
And that you have <package> to scan in the same classpaths in your camel
context configurations?

If you set the <package> to use different classpaths then you can control
which camel context
that looks into which packages.



>
>
> This can cause not very obvious threading problems - a consumer might
> unexpectedly receive messages in multiple threads if a new camel context is
> added to the bundle.
>
> I don't see any way to explicitly bind @Consume to a particular context.
> Has anyone ever considered adding an option to the annotation to specify a
> context name?
>

Yeah that could be a good idea to add some sort of qualifier or context
option to limit
it a certain context. But an option like: context="camel-1" would do for now
I think.



>
> Thanks,
> Aaron
> --
> View this message in context:
> http://www.nabble.com/%40Consume-creates-multiple-consumers-when-using-multiple-camel-contexts-tp24190660p24190660.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>


-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus