You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dougly <dm...@gmail.com> on 2008/12/11 01:08:18 UTC

Configure Route in Spring Context

Hi riders,

I have a couple of properties in my RouteBuilder class that needed to be
initialized using Spring application context file.

public class MailRouteBuilder extends RouteBuilder
{

    private static MailConfigure mailConfig;
    private static IEmailMessageProcessor messageProcessor; 
...
}

then in my Spring context file I have this

<camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
    <package>com.lyfam.component.mail</package>
  </camelContext>
    
  <bean id="mailRoute" class="com.lyfam.component.mail.MailRouteBuilder">
  	<property name="mailConfig" ref="mailConfigure" />
  	<property name="messageProcessor" ref="messageProcessor" />
  </bean>

Spring will try to create 2 instances of this MailRouteBuilder: one in the
camel context initialization and the other for the bean "mailRoute".
Obviously, this is not what I want.
Can I reuse/instruct camelContext to use the existing bean after it is
configured. In this case I need the camel context to use my "mailRoute"
bean.

Thank you guys,
Doug
-- 
View this message in context: http://www.nabble.com/Configure-Route-in-Spring-Context-tp20946948s22882p20946948.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Configure Route in Spring Context

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

Yeah this nifty feature should at least be configurable so Camel just
doesn't start whatever it finds as RouteBuilder in the classpath.

We have a ticket in JIRA for improving this configuration in spring
xml, Jonathan created it.


On Thu, Dec 11, 2008 at 6:17 PM, Adrian Trenaman <tr...@progress.com> wrote:
> Heya,
>
> Actually, I prefer to create my routes explicitly in the spring file and
> then use routeBuilderRef. This allows me to inject configuration values into
> the route before the configure() method is called. If you use the more
> dynamic package approach then the routes are created using a default
> constructor so you can't configure em'! Unless some can think of a neat way
> to do it that I've missed?
>
> /Ade
>
> On 11 Dec 2008, at 17:44, Carlus Henry wrote:
>
>> Hey...
>>
>> I had a similar requirement, and I discovered that you don't even have to
>> specify the routeBuilder as a reference point.  In other words, by the
>> mere
>> fact that you defined an object that is a RouteBuilder in your spring
>> file,
>> it will automagically be added as a valid route within the Camel Context.
>>
>> I thought that this was a pretty nifty feature.
>>
>> Later.
>>
>> On Wed, Dec 10, 2008 at 9:52 PM, Willem Jiang
>> <wi...@gmail.com>wrote:
>>
>>> Hi Doug
>>>
>>> Thanks for pointing out the issue.
>>> I just update the wiki page[1] for it .
>>>
>>> [1] http://cwiki.apache.org/confluence/display/CAMEL/Spring
>>>
>>> Willem
>>>
>>>
>>> dougly wrote:
>>>>
>>>> Hi William,
>>>> Thanks for creating the JIRA.
>>>> But I just looked at the xsd schema for camel context and discovered
>>>> that
>>>> camelContext can take a reference to the route builder bean! I did
>>>> follow
>>>> that and it works fine. Here's how:
>>>>
>>>> <camelContext id='' xmlns="..">
>>>>  <routeBuilderRef ref="myBuilder" />
>>>> </camelContext>
>>>>
>>>> <bean id="myBuilder" class="..."></bean>
>>>>
>>>> I will update the JIRA with this info.
>>>>
>>>> Thanks and regards,
>>>>
>>>> Doug
>>>>
>>>>
>>>> willem.jiang wrote:
>>>>>
>>>>> It's an interesting requirement.
>>>>> Basically camel will search <package> to lookup the builder class and
>>>>> instantiate it, and you build up a MailRouteBuilder yourself in Spring
>>>>> configuration by injecting some properties.
>>>>>
>>>>> I think we could add new feature to let <camelContext> consumer the
>>>>> builder instance at same time.
>>>>>
>>>>> Here is the JIRA[1] that I just created according to your request.
>>>>>
>>>>> [1]https://issues.apache.org/activemq/browse/CAMEL-1179
>>>>>
>>>>> Willem
>>>>>
>>>>> dougly wrote:
>>>>>>
>>>>>> Hi riders,
>>>>>>
>>>>>> I have a couple of properties in my RouteBuilder class that needed to
>>>
>>> be
>>>>>>
>>>>>> initialized using Spring application context file.
>>>>>>
>>>>>> public class MailRouteBuilder extends RouteBuilder
>>>>>> {
>>>>>>
>>>>>>   private static MailConfigure mailConfig;
>>>>>>   private static IEmailMessageProcessor messageProcessor;
>>>>>> ...
>>>>>> }
>>>>>>
>>>>>> then in my Spring context file I have this
>>>>>>
>>>>>> <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>   <package>com.lyfam.component.mail</package>
>>>>>>  </camelContext>
>>>>>>
>>>>>>  <bean id="mailRoute"
>>>
>>> class="com.lyfam.component.mail.MailRouteBuilder">
>>>>>>
>>>>>>   <property name="mailConfig" ref="mailConfigure" />
>>>>>>   <property name="messageProcessor" ref="messageProcessor" />
>>>>>>  </bean>
>>>>>>
>>>>>> Spring will try to create 2 instances of this MailRouteBuilder: one in
>>>>>> the
>>>>>> camel context initialization and the other for the bean "mailRoute".
>>>>>> Obviously, this is not what I want.
>>>>>> Can I reuse/instruct camelContext to use the existing bean after it is
>>>>>> configured. In this case I need the camel context to use my
>>>>>> "mailRoute"
>>>>>> bean.
>>>>>>
>>>>>> Thank you guys,
>>>>>> Doug
>>>>>
>>>>>
>>>>
>>>
>>> Carlus Henry
>
> ---
> Adrian Trenaman, Consultant Fellow, PS - Opensource Center of Competence
> Progress Software Corp
> Shelbourne Road, Dublin 4, Ireland
> ---
> +353-1-637-2659 (Office)
> +353-1-637-2882 (Fax)
> +353-86-6051026 (Mobile)
>  adrian.trenaman (Skype)
> ----
> Blog: http://trenaman.blogspot.com
>
>
>
>
>
>
>
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: Configure Route in Spring Context

Posted by Adrian Trenaman <tr...@progress.com>.
Ah, I get you now - i misread something in your original email. Very  
nice feature indeed. So, no need for routeBuilderRef or package  
elements in the camel context: just declare your bean and away you go.  
Very nice!

/Ade

On 11 Dec 2008, at 18:24, Carlus Henry wrote:

> I think that the dynamic approach still allows you to do what you are
> explaining.  Here is my example:
>
>    <bean id="camel"
> class="org.apache.camel.spring.CamelContextFactoryBean"/>
>
>    <bean id="tibco"  
> class="org.apache.camel.component.jms.JmsComponent">
>        <property name="connectionFactory"  
> ref="jmsQueueConnectionFactory"/>
>        <property name="transacted" ref="true"/>
>        <property name="transactionManager" ref="transactionManager"/>
>    </bean>
>
>    <bean id="incrementRetry"
> class="com.acme.integration.process.IncrementRetryField"/>
>
>    <bean id="retryLogicRoute"
> class="com.acme.integration.routes.RetryLogicRoute">
>        <property name="mainQueueName"
> value="tibco:$acme{jms.queue.name.consume}"/>
>        <property name="retryQueueName"
> value="tibco:$acme{jms.queue.name.publish}"/>
>        <property name="errorQueueName"
> value="tibco:$acme{jms.queue.name.error}"/>
>        <property name="enableTracer"  
> value="$acme{enable.route.tracing}"/>
>    </bean>
>
> This builds the route as a spring bean first, with the associated  
> properties
> for configuration purposes....but still will be dynamically added to  
> the
> camel context.
>
>
>
>
> On Thu, Dec 11, 2008 at 12:17 PM, Adrian Trenaman <trenaman@progress.com 
> >wrote:
>
>> Heya,
>>
>> Actually, I prefer to create my routes explicitly in the spring  
>> file and
>> then use routeBuilderRef. This allows me to inject configuration  
>> values into
>> the route before the configure() method is called. If you use the  
>> more
>> dynamic package approach then the routes are created using a default
>> constructor so you can't configure em'! Unless some can think of a  
>> neat way
>> to do it that I've missed?
>>
>> /Ade
>>
>>
>> On 11 Dec 2008, at 17:44, Carlus Henry wrote:
>>
>> Hey...
>>>
>>> I had a similar requirement, and I discovered that you don't even  
>>> have to
>>> specify the routeBuilder as a reference point.  In other words, by  
>>> the
>>> mere
>>> fact that you defined an object that is a RouteBuilder in your  
>>> spring
>>> file,
>>> it will automagically be added as a valid route within the Camel  
>>> Context.
>>>
>>> I thought that this was a pretty nifty feature.
>>>
>>> Later.
>>>
>>> On Wed, Dec 10, 2008 at 9:52 PM, Willem Jiang  
>>> <willem.jiang@gmail.com
>>>> wrote:
>>>
>>> Hi Doug
>>>>
>>>> Thanks for pointing out the issue.
>>>> I just update the wiki page[1] for it .
>>>>
>>>> [1] http://cwiki.apache.org/confluence/display/CAMEL/Spring
>>>>
>>>> Willem
>>>>
>>>>
>>>> dougly wrote:
>>>>
>>>>> Hi William,
>>>>> Thanks for creating the JIRA.
>>>>> But I just looked at the xsd schema for camel context and  
>>>>> discovered
>>>>> that
>>>>> camelContext can take a reference to the route builder bean! I did
>>>>> follow
>>>>> that and it works fine. Here's how:
>>>>>
>>>>> <camelContext id='' xmlns="..">
>>>>> <routeBuilderRef ref="myBuilder" />
>>>>> </camelContext>
>>>>>
>>>>> <bean id="myBuilder" class="..."></bean>
>>>>>
>>>>> I will update the JIRA with this info.
>>>>>
>>>>> Thanks and regards,
>>>>>
>>>>> Doug
>>>>>
>>>>>
>>>>> willem.jiang wrote:
>>>>>
>>>>>> It's an interesting requirement.
>>>>>> Basically camel will search <package> to lookup the builder  
>>>>>> class and
>>>>>> instantiate it, and you build up a MailRouteBuilder yourself in  
>>>>>> Spring
>>>>>> configuration by injecting some properties.
>>>>>>
>>>>>> I think we could add new feature to let <camelContext> consumer  
>>>>>> the
>>>>>> builder instance at same time.
>>>>>>
>>>>>> Here is the JIRA[1] that I just created according to your  
>>>>>> request.
>>>>>>
>>>>>> [1]https://issues.apache.org/activemq/browse/CAMEL-1179
>>>>>>
>>>>>> Willem
>>>>>>
>>>>>> dougly wrote:
>>>>>>
>>>>>>> Hi riders,
>>>>>>>
>>>>>>> I have a couple of properties in my RouteBuilder class that  
>>>>>>> needed to
>>>>>>>
>>>>>> be
>>>>
>>>>> initialized using Spring application context file.
>>>>>>>
>>>>>>> public class MailRouteBuilder extends RouteBuilder
>>>>>>> {
>>>>>>>
>>>>>>>  private static MailConfigure mailConfig;
>>>>>>>  private static IEmailMessageProcessor messageProcessor;
>>>>>>> ...
>>>>>>> }
>>>>>>>
>>>>>>> then in my Spring context file I have this
>>>>>>>
>>>>>>> <camelContext xmlns="http://activemq.apache.org/camel/schema/spring 
>>>>>>> ">
>>>>>>>  <package>com.lyfam.component.mail</package>
>>>>>>> </camelContext>
>>>>>>>
>>>>>>> <bean id="mailRoute"
>>>>>>>
>>>>>> class="com.lyfam.component.mail.MailRouteBuilder">
>>>>
>>>>>  <property name="mailConfig" ref="mailConfigure" />
>>>>>>>  <property name="messageProcessor" ref="messageProcessor" />
>>>>>>> </bean>
>>>>>>>
>>>>>>> Spring will try to create 2 instances of this  
>>>>>>> MailRouteBuilder: one in
>>>>>>> the
>>>>>>> camel context initialization and the other for the bean  
>>>>>>> "mailRoute".
>>>>>>> Obviously, this is not what I want.
>>>>>>> Can I reuse/instruct camelContext to use the existing bean  
>>>>>>> after it is
>>>>>>> configured. In this case I need the camel context to use my
>>>>>>> "mailRoute"
>>>>>>> bean.
>>>>>>>
>>>>>>> Thank you guys,
>>>>>>> Doug
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>> Carlus Henry
>>>>
>>>
>> ---
>> Adrian Trenaman, Consultant Fellow, PS - Opensource Center of  
>> Competence
>> Progress Software Corp
>> Shelbourne Road, Dublin 4, Ireland
>> ---
>> +353-1-637-2659 (Office)
>> +353-1-637-2882 (Fax)
>> +353-86-6051026 (Mobile)
>> adrian.trenaman (Skype)
>> ----
>> Blog: http://trenaman.blogspot.com
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
>
> -- 
> Carlus Henry

---
Adrian Trenaman, Consultant Fellow, PS - Opensource Center of Competence
Progress Software Corp
Shelbourne Road, Dublin 4, Ireland
---
+353-1-637-2659 (Office)
+353-1-637-2882 (Fax)
+353-86-6051026 (Mobile)
  adrian.trenaman (Skype)
----
Blog: http://trenaman.blogspot.com









Re: Configure Route in Spring Context

Posted by Carlus Henry <ca...@sagetech-llc.com>.
I think that the dynamic approach still allows you to do what you are
explaining.  Here is my example:

    <bean id="camel"
class="org.apache.camel.spring.CamelContextFactoryBean"/>

    <bean id="tibco" class="org.apache.camel.component.jms.JmsComponent">
        <property name="connectionFactory" ref="jmsQueueConnectionFactory"/>
        <property name="transacted" ref="true"/>
        <property name="transactionManager" ref="transactionManager"/>
    </bean>

    <bean id="incrementRetry"
class="com.acme.integration.process.IncrementRetryField"/>

    <bean id="retryLogicRoute"
class="com.acme.integration.routes.RetryLogicRoute">
        <property name="mainQueueName"
value="tibco:$acme{jms.queue.name.consume}"/>
        <property name="retryQueueName"
value="tibco:$acme{jms.queue.name.publish}"/>
        <property name="errorQueueName"
value="tibco:$acme{jms.queue.name.error}"/>
        <property name="enableTracer" value="$acme{enable.route.tracing}"/>
    </bean>

This builds the route as a spring bean first, with the associated properties
for configuration purposes....but still will be dynamically added to the
camel context.




On Thu, Dec 11, 2008 at 12:17 PM, Adrian Trenaman <tr...@progress.com>wrote:

> Heya,
>
> Actually, I prefer to create my routes explicitly in the spring file and
> then use routeBuilderRef. This allows me to inject configuration values into
> the route before the configure() method is called. If you use the more
> dynamic package approach then the routes are created using a default
> constructor so you can't configure em'! Unless some can think of a neat way
> to do it that I've missed?
>
> /Ade
>
>
> On 11 Dec 2008, at 17:44, Carlus Henry wrote:
>
>  Hey...
>>
>> I had a similar requirement, and I discovered that you don't even have to
>> specify the routeBuilder as a reference point.  In other words, by the
>> mere
>> fact that you defined an object that is a RouteBuilder in your spring
>> file,
>> it will automagically be added as a valid route within the Camel Context.
>>
>> I thought that this was a pretty nifty feature.
>>
>> Later.
>>
>> On Wed, Dec 10, 2008 at 9:52 PM, Willem Jiang <willem.jiang@gmail.com
>> >wrote:
>>
>>  Hi Doug
>>>
>>> Thanks for pointing out the issue.
>>> I just update the wiki page[1] for it .
>>>
>>> [1] http://cwiki.apache.org/confluence/display/CAMEL/Spring
>>>
>>> Willem
>>>
>>>
>>> dougly wrote:
>>>
>>>> Hi William,
>>>> Thanks for creating the JIRA.
>>>> But I just looked at the xsd schema for camel context and discovered
>>>> that
>>>> camelContext can take a reference to the route builder bean! I did
>>>> follow
>>>> that and it works fine. Here's how:
>>>>
>>>> <camelContext id='' xmlns="..">
>>>>  <routeBuilderRef ref="myBuilder" />
>>>> </camelContext>
>>>>
>>>> <bean id="myBuilder" class="..."></bean>
>>>>
>>>> I will update the JIRA with this info.
>>>>
>>>> Thanks and regards,
>>>>
>>>> Doug
>>>>
>>>>
>>>> willem.jiang wrote:
>>>>
>>>>> It's an interesting requirement.
>>>>> Basically camel will search <package> to lookup the builder class and
>>>>> instantiate it, and you build up a MailRouteBuilder yourself in Spring
>>>>> configuration by injecting some properties.
>>>>>
>>>>> I think we could add new feature to let <camelContext> consumer the
>>>>> builder instance at same time.
>>>>>
>>>>> Here is the JIRA[1] that I just created according to your request.
>>>>>
>>>>> [1]https://issues.apache.org/activemq/browse/CAMEL-1179
>>>>>
>>>>> Willem
>>>>>
>>>>> dougly wrote:
>>>>>
>>>>>> Hi riders,
>>>>>>
>>>>>> I have a couple of properties in my RouteBuilder class that needed to
>>>>>>
>>>>> be
>>>
>>>> initialized using Spring application context file.
>>>>>>
>>>>>> public class MailRouteBuilder extends RouteBuilder
>>>>>> {
>>>>>>
>>>>>>   private static MailConfigure mailConfig;
>>>>>>   private static IEmailMessageProcessor messageProcessor;
>>>>>> ...
>>>>>> }
>>>>>>
>>>>>> then in my Spring context file I have this
>>>>>>
>>>>>> <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
>>>>>>   <package>com.lyfam.component.mail</package>
>>>>>>  </camelContext>
>>>>>>
>>>>>>  <bean id="mailRoute"
>>>>>>
>>>>> class="com.lyfam.component.mail.MailRouteBuilder">
>>>
>>>>   <property name="mailConfig" ref="mailConfigure" />
>>>>>>   <property name="messageProcessor" ref="messageProcessor" />
>>>>>>  </bean>
>>>>>>
>>>>>> Spring will try to create 2 instances of this MailRouteBuilder: one in
>>>>>> the
>>>>>> camel context initialization and the other for the bean "mailRoute".
>>>>>> Obviously, this is not what I want.
>>>>>> Can I reuse/instruct camelContext to use the existing bean after it is
>>>>>> configured. In this case I need the camel context to use my
>>>>>> "mailRoute"
>>>>>> bean.
>>>>>>
>>>>>> Thank you guys,
>>>>>> Doug
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>> Carlus Henry
>>>
>>
> ---
> Adrian Trenaman, Consultant Fellow, PS - Opensource Center of Competence
> Progress Software Corp
> Shelbourne Road, Dublin 4, Ireland
> ---
> +353-1-637-2659 (Office)
> +353-1-637-2882 (Fax)
> +353-86-6051026 (Mobile)
>  adrian.trenaman (Skype)
> ----
> Blog: http://trenaman.blogspot.com
>
>
>
>
>
>
>
>
>


-- 
Carlus Henry

Re: Configure Route in Spring Context

Posted by Adrian Trenaman <tr...@progress.com>.
Heya,

Actually, I prefer to create my routes explicitly in the spring file  
and then use routeBuilderRef. This allows me to inject configuration  
values into the route before the configure() method is called. If you  
use the more dynamic package approach then the routes are created  
using a default constructor so you can't configure em'! Unless some  
can think of a neat way to do it that I've missed?

/Ade

On 11 Dec 2008, at 17:44, Carlus Henry wrote:

> Hey...
>
> I had a similar requirement, and I discovered that you don't even  
> have to
> specify the routeBuilder as a reference point.  In other words, by  
> the mere
> fact that you defined an object that is a RouteBuilder in your  
> spring file,
> it will automagically be added as a valid route within the Camel  
> Context.
>
> I thought that this was a pretty nifty feature.
>
> Later.
>
> On Wed, Dec 10, 2008 at 9:52 PM, Willem Jiang  
> <wi...@gmail.com>wrote:
>
>> Hi Doug
>>
>> Thanks for pointing out the issue.
>> I just update the wiki page[1] for it .
>>
>> [1] http://cwiki.apache.org/confluence/display/CAMEL/Spring
>>
>> Willem
>>
>>
>> dougly wrote:
>>> Hi William,
>>> Thanks for creating the JIRA.
>>> But I just looked at the xsd schema for camel context and  
>>> discovered that
>>> camelContext can take a reference to the route builder bean! I did  
>>> follow
>>> that and it works fine. Here's how:
>>>
>>> <camelContext id='' xmlns="..">
>>>   <routeBuilderRef ref="myBuilder" />
>>> </camelContext>
>>>
>>> <bean id="myBuilder" class="..."></bean>
>>>
>>> I will update the JIRA with this info.
>>>
>>> Thanks and regards,
>>>
>>> Doug
>>>
>>>
>>> willem.jiang wrote:
>>>> It's an interesting requirement.
>>>> Basically camel will search <package> to lookup the builder class  
>>>> and
>>>> instantiate it, and you build up a MailRouteBuilder yourself in  
>>>> Spring
>>>> configuration by injecting some properties.
>>>>
>>>> I think we could add new feature to let <camelContext> consumer the
>>>> builder instance at same time.
>>>>
>>>> Here is the JIRA[1] that I just created according to your request.
>>>>
>>>> [1]https://issues.apache.org/activemq/browse/CAMEL-1179
>>>>
>>>> Willem
>>>>
>>>> dougly wrote:
>>>>> Hi riders,
>>>>>
>>>>> I have a couple of properties in my RouteBuilder class that  
>>>>> needed to
>> be
>>>>> initialized using Spring application context file.
>>>>>
>>>>> public class MailRouteBuilder extends RouteBuilder
>>>>> {
>>>>>
>>>>>    private static MailConfigure mailConfig;
>>>>>    private static IEmailMessageProcessor messageProcessor;
>>>>> ...
>>>>> }
>>>>>
>>>>> then in my Spring context file I have this
>>>>>
>>>>> <camelContext xmlns="http://activemq.apache.org/camel/schema/spring 
>>>>> ">
>>>>>    <package>com.lyfam.component.mail</package>
>>>>>  </camelContext>
>>>>>
>>>>>  <bean id="mailRoute"
>> class="com.lyfam.component.mail.MailRouteBuilder">
>>>>>    <property name="mailConfig" ref="mailConfigure" />
>>>>>    <property name="messageProcessor" ref="messageProcessor" />
>>>>>  </bean>
>>>>>
>>>>> Spring will try to create 2 instances of this MailRouteBuilder:  
>>>>> one in
>>>>> the
>>>>> camel context initialization and the other for the bean  
>>>>> "mailRoute".
>>>>> Obviously, this is not what I want.
>>>>> Can I reuse/instruct camelContext to use the existing bean after  
>>>>> it is
>>>>> configured. In this case I need the camel context to use my  
>>>>> "mailRoute"
>>>>> bean.
>>>>>
>>>>> Thank you guys,
>>>>> Doug
>>>>
>>>>
>>>
>>
>> Carlus Henry

---
Adrian Trenaman, Consultant Fellow, PS - Opensource Center of Competence
Progress Software Corp
Shelbourne Road, Dublin 4, Ireland
---
+353-1-637-2659 (Office)
+353-1-637-2882 (Fax)
+353-86-6051026 (Mobile)
  adrian.trenaman (Skype)
----
Blog: http://trenaman.blogspot.com









Re: Configure Route in Spring Context

Posted by Carlus Henry <ca...@sagetech-llc.com>.
Hey...

I had a similar requirement, and I discovered that you don't even have to
specify the routeBuilder as a reference point.  In other words, by the mere
fact that you defined an object that is a RouteBuilder in your spring file,
it will automagically be added as a valid route within the Camel Context.

I thought that this was a pretty nifty feature.

Later.

On Wed, Dec 10, 2008 at 9:52 PM, Willem Jiang <wi...@gmail.com>wrote:

> Hi Doug
>
> Thanks for pointing out the issue.
> I just update the wiki page[1] for it .
>
> [1] http://cwiki.apache.org/confluence/display/CAMEL/Spring
>
> Willem
>
>
> dougly wrote:
> > Hi William,
> > Thanks for creating the JIRA.
> > But I just looked at the xsd schema for camel context and discovered that
> > camelContext can take a reference to the route builder bean! I did follow
> > that and it works fine. Here's how:
> >
> > <camelContext id='' xmlns="..">
> >    <routeBuilderRef ref="myBuilder" />
> > </camelContext>
> >
> > <bean id="myBuilder" class="..."></bean>
> >
> > I will update the JIRA with this info.
> >
> > Thanks and regards,
> >
> > Doug
> >
> >
> > willem.jiang wrote:
> >> It's an interesting requirement.
> >> Basically camel will search <package> to lookup the builder class and
> >> instantiate it, and you build up a MailRouteBuilder yourself in Spring
> >> configuration by injecting some properties.
> >>
> >> I think we could add new feature to let <camelContext> consumer the
> >> builder instance at same time.
> >>
> >> Here is the JIRA[1] that I just created according to your request.
> >>
> >> [1]https://issues.apache.org/activemq/browse/CAMEL-1179
> >>
> >> Willem
> >>
> >> dougly wrote:
> >>> Hi riders,
> >>>
> >>> I have a couple of properties in my RouteBuilder class that needed to
> be
> >>> initialized using Spring application context file.
> >>>
> >>> public class MailRouteBuilder extends RouteBuilder
> >>> {
> >>>
> >>>     private static MailConfigure mailConfig;
> >>>     private static IEmailMessageProcessor messageProcessor;
> >>> ...
> >>> }
> >>>
> >>> then in my Spring context file I have this
> >>>
> >>> <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
> >>>     <package>com.lyfam.component.mail</package>
> >>>   </camelContext>
> >>>
> >>>   <bean id="mailRoute"
> class="com.lyfam.component.mail.MailRouteBuilder">
> >>>     <property name="mailConfig" ref="mailConfigure" />
> >>>     <property name="messageProcessor" ref="messageProcessor" />
> >>>   </bean>
> >>>
> >>> Spring will try to create 2 instances of this MailRouteBuilder: one in
> >>> the
> >>> camel context initialization and the other for the bean "mailRoute".
> >>> Obviously, this is not what I want.
> >>> Can I reuse/instruct camelContext to use the existing bean after it is
> >>> configured. In this case I need the camel context to use my "mailRoute"
> >>> bean.
> >>>
> >>> Thank you guys,
> >>> Doug
> >>
> >>
> >
>
> Carlus Henry

Re: Configure Route in Spring Context

Posted by Willem Jiang <wi...@gmail.com>.
Hi Doug

Thanks for pointing out the issue.
I just update the wiki page[1] for it .

[1] http://cwiki.apache.org/confluence/display/CAMEL/Spring

Willem


dougly wrote:
> Hi William,
> Thanks for creating the JIRA.
> But I just looked at the xsd schema for camel context and discovered that
> camelContext can take a reference to the route builder bean! I did follow
> that and it works fine. Here's how:
> 
> <camelContext id='' xmlns="..">
>    <routeBuilderRef ref="myBuilder" />
> </camelContext>
> 
> <bean id="myBuilder" class="..."></bean>
> 
> I will update the JIRA with this info.
> 
> Thanks and regards,
> 
> Doug
> 
> 
> willem.jiang wrote:
>> It's an interesting requirement.
>> Basically camel will search <package> to lookup the builder class and
>> instantiate it, and you build up a MailRouteBuilder yourself in Spring
>> configuration by injecting some properties.
>>
>> I think we could add new feature to let <camelContext> consumer the
>> builder instance at same time.
>>
>> Here is the JIRA[1] that I just created according to your request.
>>
>> [1]https://issues.apache.org/activemq/browse/CAMEL-1179
>>
>> Willem
>>
>> dougly wrote:
>>> Hi riders,
>>>
>>> I have a couple of properties in my RouteBuilder class that needed to be
>>> initialized using Spring application context file.
>>>
>>> public class MailRouteBuilder extends RouteBuilder
>>> {
>>>
>>>     private static MailConfigure mailConfig;
>>>     private static IEmailMessageProcessor messageProcessor; 
>>> ...
>>> }
>>>
>>> then in my Spring context file I have this
>>>
>>> <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
>>>     <package>com.lyfam.component.mail</package>
>>>   </camelContext>
>>>     
>>>   <bean id="mailRoute" class="com.lyfam.component.mail.MailRouteBuilder">
>>>   	<property name="mailConfig" ref="mailConfigure" />
>>>   	<property name="messageProcessor" ref="messageProcessor" />
>>>   </bean>
>>>
>>> Spring will try to create 2 instances of this MailRouteBuilder: one in
>>> the
>>> camel context initialization and the other for the bean "mailRoute".
>>> Obviously, this is not what I want.
>>> Can I reuse/instruct camelContext to use the existing bean after it is
>>> configured. In this case I need the camel context to use my "mailRoute"
>>> bean.
>>>
>>> Thank you guys,
>>> Doug
>>
>>
> 


Re: Configure Route in Spring Context

Posted by dougly <dm...@gmail.com>.
Hi William,
Thanks for creating the JIRA.
But I just looked at the xsd schema for camel context and discovered that
camelContext can take a reference to the route builder bean! I did follow
that and it works fine. Here's how:

<camelContext id='' xmlns="..">
   <routeBuilderRef ref="myBuilder" />
</camelContext>

<bean id="myBuilder" class="..."></bean>

I will update the JIRA with this info.

Thanks and regards,

Doug


willem.jiang wrote:
> 
> It's an interesting requirement.
> Basically camel will search <package> to lookup the builder class and
> instantiate it, and you build up a MailRouteBuilder yourself in Spring
> configuration by injecting some properties.
> 
> I think we could add new feature to let <camelContext> consumer the
> builder instance at same time.
> 
> Here is the JIRA[1] that I just created according to your request.
> 
> [1]https://issues.apache.org/activemq/browse/CAMEL-1179
> 
> Willem
> 
> dougly wrote:
>> Hi riders,
>> 
>> I have a couple of properties in my RouteBuilder class that needed to be
>> initialized using Spring application context file.
>> 
>> public class MailRouteBuilder extends RouteBuilder
>> {
>> 
>>     private static MailConfigure mailConfig;
>>     private static IEmailMessageProcessor messageProcessor; 
>> ...
>> }
>> 
>> then in my Spring context file I have this
>> 
>> <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
>>     <package>com.lyfam.component.mail</package>
>>   </camelContext>
>>     
>>   <bean id="mailRoute" class="com.lyfam.component.mail.MailRouteBuilder">
>>   	<property name="mailConfig" ref="mailConfigure" />
>>   	<property name="messageProcessor" ref="messageProcessor" />
>>   </bean>
>> 
>> Spring will try to create 2 instances of this MailRouteBuilder: one in
>> the
>> camel context initialization and the other for the bean "mailRoute".
>> Obviously, this is not what I want.
>> Can I reuse/instruct camelContext to use the existing bean after it is
>> configured. In this case I need the camel context to use my "mailRoute"
>> bean.
>> 
>> Thank you guys,
>> Doug
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Configure-Route-in-Spring-Context-tp20946948s22882p20947945.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Configure Route in Spring Context

Posted by Willem Jiang <wi...@gmail.com>.
It's an interesting requirement.
Basically camel will search <package> to lookup the builder class and
instantiate it, and you build up a MailRouteBuilder yourself in Spring
configuration by injecting some properties.

I think we could add new feature to let <camelContext> consumer the
builder instance at same time.

Here is the JIRA[1] that I just created according to your request.

[1]https://issues.apache.org/activemq/browse/CAMEL-1179

Willem

dougly wrote:
> Hi riders,
> 
> I have a couple of properties in my RouteBuilder class that needed to be
> initialized using Spring application context file.
> 
> public class MailRouteBuilder extends RouteBuilder
> {
> 
>     private static MailConfigure mailConfig;
>     private static IEmailMessageProcessor messageProcessor; 
> ...
> }
> 
> then in my Spring context file I have this
> 
> <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
>     <package>com.lyfam.component.mail</package>
>   </camelContext>
>     
>   <bean id="mailRoute" class="com.lyfam.component.mail.MailRouteBuilder">
>   	<property name="mailConfig" ref="mailConfigure" />
>   	<property name="messageProcessor" ref="messageProcessor" />
>   </bean>
> 
> Spring will try to create 2 instances of this MailRouteBuilder: one in the
> camel context initialization and the other for the bean "mailRoute".
> Obviously, this is not what I want.
> Can I reuse/instruct camelContext to use the existing bean after it is
> configured. In this case I need the camel context to use my "mailRoute"
> bean.
> 
> Thank you guys,
> Doug