On Fri, Jul 26, 2013 at 7:22 PM, Gershaw, Geoffrey
<geoffrey.gers...@credit-suisse.com> wrote:
> So you can refer to consumerTemplate from outside the camel context?
>

Yes, and likewise if you set an id on <camelContext> you can also
refer to it outside. From spring point of view its just like any other
 <bean id="..." class="..."/>


> Geoffrey A Gershaw
> Credit eTrading Development
> +1 919 994 6412 (*102 6412)
>
>
> -----Original Message-----
> From: Christian Müller [mailto:christian.muel...@gmail.com]
> Sent: Friday, July 26, 2013 11:51 AM
> To: users@camel.apache.org
> Subject: Re: Spring Config. Referencing a bean created in a route
>
> I prefer this one:
>
> <bean id="myBean" class="xxx.MyBean">
>   <property name="consumerTemplate" ref="consumerTemplate"/>
> </bean>
>
> <camel:camelContext xmlns="http://camel.apache.org/schema/spring";>
>   <camel:consumerTemplate id="consumerTemplate" />
>
>   <camel:route id="autoexec-messageHandler">
>     <camel:from uri="timer://start?repeatCount=1"/>
>     <camel:to uri="bean://myBean">
>   </camel:route>
> </camel:camelContext>
>
> Best,
> Christian
> -----------------
>
> Software Integration Specialist
>
> Apache Camel committer: https://camel.apache.org/team
> V.P. Apache Camel: https://www.apache.org/foundation/
> Apache Member: https://www.apache.org/foundation/members.html
>
> https://www.linkedin.com/pub/christian-mueller/11/551/642
>
>
> On Fri, Jul 26, 2013 at 3:38 PM, Gershaw, Geoffrey <
> geoffrey.gers...@credit-suisse.com> wrote:
>
>> Hello All,
>>
>>
>>
>> I am trying to use the pollingConsumer. You need to inject the
>> consumerTemplate into your bean. I figured that since consumerTemplate
>> is defined within the camel context, I need to define my bean within the
>> context.
>>
>>
>>
>> When I do this, I can't reference this bean using bean ref... . Any
>> ideas?
>>
>>
>>
>> Thanks
>>
>>
>>
>>
>>
>>        <camel:camelContext xmlns="http://camel.apache.org/schema/spring";
>> >
>>
>>
>>
>>               <camel:consumerTemplate id="consumerTemplate" />
>>
>>
>>
>>               <camel:route id="autoexec-messageHandler">
>>
>>                      <camel:from uri="timer://start?repeatCount=1"/>
>>
>>
>>
>>                      <camel:bean
>> beanType="com.cs.algo.autoexecution.camelinterface.ConsumerTemplateBean"
>>
>>
>>                            method="setConsumer(${ref:consumerTemplate})"
>> id="thisConsumer" />
>>
>>
>>
>>                      <camel:bean ref="thisConsumer">
>>
>>
>>
>>               </camel:route>
>>
>>
>>
>>
>>
>>        </camel:camelContext>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> 09:32:10 [main] INFO  com.cs.algo.autoexecution.AutoExecutionMain -
>> Starting AutoExecution...
>>
>> 09:32:10 [main] INFO  com.cs.algo.autoexecution.AutoExecutionMain -
>> Spring context initialized.
>>
>> 09:32:10 [main] INFO  com.cs.algo.autoexecution.AutoExecutionMain -
>> Starting Camel...
>>
>> [main] INFO org.apache.camel.main.MainSupport - Apache Camel 2.11.0
>> starting
>>
>> 09:32:14 [main] INFO
>> com.cs.algo.autoexecution.camelinterface.MessageFactory - Setting up
>> login request algoautoexec
>>
>> [main] INFO org.apache.camel.spring.SpringCamelContext - Apache Camel
>> 2.11.0 (CamelContext: camel-1) is starting
>>
>> [main] INFO org.apache.camel.management.ManagementStrategyFactory - JMX
>> enabled.
>>
>> [main] INFO org.apache.camel.impl.converter.DefaultTypeConverter -
>> Loaded 177 type converters
>>
>> [main] WARN org.apache.camel.util.ObjectHelper - Cannot find class:
>> thisConsumer
>>
>> [main] INFO org.apache.camel.spring.SpringCamelContext - Apache Camel
>> 2.11.0 (CamelContext: camel-1) is shutting down
>>
>> [main] INFO org.apache.camel.spring.SpringCamelContext - Uptime 0.902
>> seconds
>>
>> [main] INFO org.apache.camel.spring.SpringCamelContext - Apache Camel
>> 2.11.0 (CamelContext: camel-1) is shutdown in 0.002 seconds
>>
>> [main] INFO org.apache.camel.main.MainSupport - Apache Camel 2.11.0
>> stopping
>>
>> 09:32:16 [main] ERROR com.cs.algo.autoexecution.AutoExecutionMain -
>> org.apache.camel.RuntimeCamelException:
>> org.apache.camel.FailedToCreateRouteException: Failed to create route
>> autoexec-messageHandler at: >>> Bean[ref:thisConsumer] <<< in route:
>> Route(autoexec-messageHandler)[[From[timer://start?repeatCou... because
>> of No bean could be found in the registry for: thisConsumer
>>
>>
>>
>>
>>
>> Geoffrey A Gershaw
>>
>> CREDIT SUISSE
>>
>> Information Technology | Credit eTrading Development, KFVB 525
>>
>> 7033 Louis Stephens Drive | 27560 Research Triangle Park | United States
>>
>> Phone +1 919 994 6412
>>
>> geoffrey.gers...@credit-suisse.com | www.credit-suisse.com
>> <http://www.credit-suisse.com/>
>>
>>
>>
>>
>>
>>
>> ===============================================================================
>> Please access the attached hyperlink for an important electronic
>> communications disclaimer:
>> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
>>
>> ===============================================================================
>>
>>
>
>
> ===============================================================================
> Please access the attached hyperlink for an important electronic 
> communications disclaimer:
> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
> ===============================================================================
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to