camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: Best way to retrieve a ProducerTemplate created in a camel bundle (OSGI)
Date Tue, 29 Jun 2010 13:53:01 GMT
Charles Moulliard wrote:
> There is no @Endpoint(ref="camelTemplate") annotation.
> 
> If I use the following syntax -->  @Produce(context="camelTemplate"), it works

The CamelPostProcessor will not handle this injection, as they are using 
different camel context, so you don't get the exception.

But the the template is not injected, and you can't use it to send message.

Willem
----------------------------------
Apache Camel, Apache CXF committer
Open SOA http://www.fusesource.com
Blog http://willemjiang.blogspot.com
Tiwtter http://twitter.com/willemjiang

> 
> KR,
> 
> Charles Moulliard
> 
> Senior Enterprise Architect (J2EE, .NET, SOA)
> Apache Camel - ServiceMix Committer
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Blog : http://cmoulliard.blogspot.com |  Twitter : http://twitter.com/cmoulliard
> Linkedin : http://www.linkedin.com/in/charlesmoulliard | Skype: cmoulliard
> 
> 
> 
> On Tue, Jun 29, 2010 at 3:21 PM, Willem Jiang <willem.jiang@gmail.com> wrote:
>> Charles Moulliard wrote:
>>> If I try to use annotation in the class requesting the Producer
>>>
>>>    @Produce(ref="camelTemplate")
>>>    private ProducerTemplate producerTemplate;
>>>
>>> and
>>>
>>> Camel Spring XML file
>>>
>>>        <!-- add route in camel context -->
>>>        <camelContext id="camelAlarmManager"
>>> xmlns="http://camel.apache.org/schema/spring">
>>>                <template id="camelTemplate" />
>>>        </camelContext>
>>>
>>> I get the following error :
>>>
>>> Caused by: java.lang.IllegalArgumentException: registry entry called
>>> camelTemplate of type org.apache.camel.Endpoint must be specified
>>>        at
>>> org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:244)
>>>        at
>>> org.apache.camel.util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:123)
>>>        at
>>> org.apache.camel.util.CamelContextHelper.getEndpointInjection(CamelContextHelper.java:138)
>>>        at
>>> org.apache.camel.impl.CamelPostProcessorHelper.getEndpointInjection(CamelPostProcessorHelper.java:125)
>>>        at
>>> org.apache.camel.impl.CamelPostProcessorHelper.createInjectionProducerTemplate(CamelPostProcessorHelper.java:167)
>>>        at
>>> org.apache.camel.impl.CamelPostProcessorHelper.getInjectionValue(CamelPostProcessorHelper.java:134)
>>>        at
>>> org.apache.camel.spring.CamelBeanPostProcessor.injectField(CamelBeanPostProcessor.java:215)
>>>
>>> What is wrong ?
>> Can you check if your annotation has other kind of annotation like
>> @Endpoint(ref="camelTemplate")?
>>
>> From the stack trace it looks like your class plan to inject a endpoint with
>> the name of camelTemplate.
>>
>> Willem
>>
>>
>>> KR,
>>>
>>>
>>> Charles Moulliard
>>>
>>> Senior Enterprise Architect (J2EE, .NET, SOA)
>>> Apache Camel - ServiceMix Committer
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>> Blog : http://cmoulliard.blogspot.com |  Twitter :
>>> http://twitter.com/cmoulliard
>>> Linkedin : http://www.linkedin.com/in/charlesmoulliard | Skype: cmoulliard
>>>
>>>
>>>
>>> On Tue, Jun 29, 2010 at 2:36 PM, Willem Jiang <willem.jiang@gmail.com>
>>> wrote:
>>>> I think we could export the CamelContext as the service, then use
>>>> camelContext.getRegistry().lookup("producerTemplate") to get the
>>>> template.
>>>>
>>>> Or we could think about export the producerTemplate as a service, than
>>>> other
>>>> bundle has a way to access certain camel context.
>>>>
>>>> Willem
>>>> ----------------------------------
>>>> Apache Camel, Apache CXF committer
>>>> Open SOA http://www.fusesource.com
>>>> Blog http://willemjiang.blogspot.com
>>>> Tiwtter http://twitter.com/willemjiang
>>>>
>>>> Christian Schneider wrote:
>>>>>  Probably not directly but we could publish a service that serves the
>>>>> context. I am not sure if serving the context is a good idea though as
>>>>> it
>>>>> promotes an
>>>>> ugly style. It is like directly accessing a spring context. We should
>>>>> give
>>>>> this some thoughts before starting. But Charles could already do this
in
>>>>> his
>>>>> project for the mean
>>>>> time.
>>>>>
>>>>> Greetings
>>>>>
>>>>> Christian
>>>>>
>>>>> Am 29.06.2010 08:00, schrieb Charles Moulliard:
>>>>>> Can we export a camelContext (from one bundle) by exposing it as
a
>>>>>> OSGI service using<osgi:reference>  ?
>>>>>>
>>>>>>
>>>>>> On Tue, Jun 29, 2010 at 1:56 AM, Willem Jiang<willem.jiang@gmail.com>
>>>>>>  wrote:
>>>>>>> Hi Charles,
>>>>>>>
>>>>>>> Both solutions are OK if you can get the SpringCamelContext for
your
>>>>>>> bundle
>>>>>>> utility.
>>>>>>> And the option 1 is easy to understand :)
>>>>>>>
>>>>>>> Willem
>>>>>>> ----------------------------------
>>>>>>> Apache Camel, Apache CXF committer
>>>>>>> Open SOA http://www.fusesource.com
>>>>>>> Blog http://willemjiang.blogspot.com
>>>>>>> Tiwtter http://twitter.com/willemjiang
>>>>>>>
>>>>>>> Charles Moulliard wrote:
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I have two bundles, one playing the role of an utility package
and
>>>>>>>> another where the camel context instantiates a Camel
>>>>>>>> ProducerTemplate.
>>>>>>>> What is the best way to retrieve the ProducerTemplate from
my bundle
>>>>>>>> utility :
>>>>>>>>
>>>>>>>> 1) using SpringCamelContext -->  SpringCamelContext camel
=
>>>>>>>> (SpringCamelContext) ac.getBean("producerTemplate");
>>>>>>>> 2) using @ProducerTemplate + ref to the bean object -->
>>>>>>>> @ProducerTemplate(ref="producerTemplate");
>>>>>>>> 3) ...
>>>>>>>>
>>>>>>>> Kind regards,
>>>>>>>>
>>>>>>>> Charles Moulliard
>>>>>>>>
>>>>>>>> Senior Enterprise Architect (J2EE, .NET, SOA)
>>>>>>>> Apache Camel - ServiceMix Committer
>>>>>>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>>>>> Blog : http://cmoulliard.blogspot.com |  Twitter :
>>>>>>>> http://twitter.com/cmoulliard
>>>>>>>> Linkedin : http://www.linkedin.com/in/charlesmoulliard |
Skype:
>>>>>>>> cmoulliard
>>>>>>>>
>>
> 


Mime
View raw message