You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by selezovikj <se...@gmail.com> on 2008/10/22 13:38:12 UTC

Multiple Camel Routes in Spring

How can I define multiple routes in Spring ? 
Logically, they should be in the same context and I just define different
<route> elements: 

<camelContext id="camel"
		xmlns="http://activemq.apache.org/camel/schema/spring">
		<route>
			<from uri="jms:topic:LoggingTopic"/>
			<to uri="bean:msgParser"/>
		</route>
              <route>
                        <from uri="bean:msgParser"/>
                        <to uri="bean:otherBean"/>
              </route>
</camelContext>

I know that in this case I don't need two separate routes, since I am only
pipelining.
In the Java DSL I would do the camel routing like this: 

from("ms:topic:LoggingTopic").to("bean:msgParser");

Then I have another <from> element:

from("bean:msgParser").to("bean:otherBean");
	
What would be the equivalent configuration in Spring ?

-- 
View this message in context: http://www.nabble.com/Multiple-Camel-Routes-in-Spring-tp20108937s22882p20108937.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Multiple Camel Routes in Spring

Posted by selezovikj <se...@gmail.com>.
Works perfectly now. 
Thank you very much. 



Claus Ibsen wrote:
> 
> Hi
> 
> I don't think you can poll beans as such, you should link the two routes
> using direct or seda endpoints:
> 
> 		<route>
> 			<from uri="jms:topic:LoggingTopic"/>
> 			<to uri="bean:msgParser"/>
> 			<to uri="bean:otherBean"/> 
>                   <to uri="seda:foo"/>
> 		</route>
> 
>         <route>
>             <from uri="seda:foo"/>
>             <to uri="bean:otherBean"/>
>             <choice>
>             ...
> 
> 
> However you can use annotations to poll beans with the @MessageDriven but
> then it's kinda lost in the route and you need to send the exchange from
> the java code. 
> 
> 
> 
> Med venlig hilsen
>  
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
> 
> -----Original Message-----
> From: selezovikj [mailto:semir.elezovic@gmail.com] 
> Sent: 22. oktober 2008 13:58
> To: camel-user@activemq.apache.org
> Subject: Re: Multiple Camel Routes in Spring
> 
> 
> I mentioned in my post that I know that I do not need two separate routes. 
> I need to know how to define multiple routes, multiple <from>s. 
> 
> My message will be pipelined through a couple of beans and then when I
> come
> to a certain bean I want to do content based routing. I want once the
> object
> is processed in the "otherBean", the outgoing object that it will send to
> be
> sent to the method "contentRouting" of the "contentRouter" bean, and if
> that
> method return true, the object to be forwarded to "filterCCBean",
> otherwise
> to the "log4jBean".
> The following configuration doesn't work:
> 
> <camelContext id="camel"
> 		xmlns="http://activemq.apache.org/camel/schema/spring">
> 		<route>
> 			<from uri="jms:topic:LoggingTopic"/>
> 			<to uri="bean:msgParser"/>
> 			<to uri="bean:otherBean"/> 
> 		</route>
> 	</camelContext>
> 	
> 	<camelContext id="camel2"
>         xmlns="http://activemq.apache.org/camel/schema/spring">
>         <route>
>             <from uri="bean:otherBean"/>
>             <choice>
>                 <when>
>                     <methodCall bean="contentRouter"
> method="contentRouting"/>
>                     <to uri="bean:filterCCBean"/>
>                 </when>
>                 <otherwise>
>                     <to uri="bean:log4jBean"/>
>                 </otherwise>
>             </choice>
>         </route>
>     </camelContext>
> 
> 
> 
> 
> janstey wrote:
>> 
>> The first bit of Spring you showed is correct. If you just want to do
>> some
>> pipelining though, its simpler to avoid the 2nd from
>> 
>> <camelContext id="camel"
>>                xmlns="http://activemq.apache.org/camel/schema/spring">
>>               <route>
>>                        <from uri="jms:topic:LoggingTopic"/>
>>                        <to uri="bean:msgParser"/>
>>                        <to uri="bean:otherBean"/>
>>              </route>
>> </camelContext>
>> 
>> On Wed, Oct 22, 2008 at 9:08 AM, selezovikj
>> <se...@gmail.com>wrote:
>> 
>>>
>>> How can I define multiple routes in Spring ?
>>> Logically, they should be in the same context and I just define
>>> different
>>> <route> elements:
>>>
>>> <camelContext id="camel"
>>>                xmlns="http://activemq.apache.org/camel/schema/spring">
>>>                <route>
>>>                        <from uri="jms:topic:LoggingTopic"/>
>>>                        <to uri="bean:msgParser"/>
>>>                </route>
>>>              <route>
>>>                        <from uri="bean:msgParser"/>
>>>                        <to uri="bean:otherBean"/>
>>>              </route>
>>> </camelContext>
>>>
>>> I know that in this case I don't need two separate routes, since I am
>>> only
>>> pipelining.
>>> In the Java DSL I would do the camel routing like this:
>>>
>>> from("ms:topic:LoggingTopic").to("bean:msgParser");
>>>
>>> Then I have another <from> element:
>>>
>>> from("bean:msgParser").to("bean:otherBean");
>>>
>>> What would be the equivalent configuration in Spring ?
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Multiple-Camel-Routes-in-Spring-tp20108937s22882p20108937.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>> 
>> 
>> -- 
>> Cheers,
>> Jon
>> 
>> http://janstey.blogspot.com/
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Multiple-Camel-Routes-in-Spring-tp20108937s22882p20109212.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Multiple-Camel-Routes-in-Spring-tp20108937s22882p20109576.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: Multiple Camel Routes in Spring

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

I don't think you can poll beans as such, you should link the two routes using direct or seda endpoints:

		<route>
			<from uri="jms:topic:LoggingTopic"/>
			<to uri="bean:msgParser"/>
			<to uri="bean:otherBean"/> 
                  <to uri="seda:foo"/>
		</route>

        <route>
            <from uri="seda:foo"/>
            <to uri="bean:otherBean"/>
            <choice>
            ...


However you can use annotations to poll beans with the @MessageDriven but then it's kinda lost in the route and you need to send the exchange from the java code. 



Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: selezovikj [mailto:semir.elezovic@gmail.com] 
Sent: 22. oktober 2008 13:58
To: camel-user@activemq.apache.org
Subject: Re: Multiple Camel Routes in Spring


I mentioned in my post that I know that I do not need two separate routes. 
I need to know how to define multiple routes, multiple <from>s. 

My message will be pipelined through a couple of beans and then when I come
to a certain bean I want to do content based routing. I want once the object
is processed in the "otherBean", the outgoing object that it will send to be
sent to the method "contentRouting" of the "contentRouter" bean, and if that
method return true, the object to be forwarded to "filterCCBean", otherwise
to the "log4jBean".
The following configuration doesn't work:

<camelContext id="camel"
		xmlns="http://activemq.apache.org/camel/schema/spring">
		<route>
			<from uri="jms:topic:LoggingTopic"/>
			<to uri="bean:msgParser"/>
			<to uri="bean:otherBean"/> 
		</route>
	</camelContext>
	
	<camelContext id="camel2"
        xmlns="http://activemq.apache.org/camel/schema/spring">
        <route>
            <from uri="bean:otherBean"/>
            <choice>
                <when>
                    <methodCall bean="contentRouter"
method="contentRouting"/>
                    <to uri="bean:filterCCBean"/>
                </when>
                <otherwise>
                    <to uri="bean:log4jBean"/>
                </otherwise>
            </choice>
        </route>
    </camelContext>




janstey wrote:
> 
> The first bit of Spring you showed is correct. If you just want to do some
> pipelining though, its simpler to avoid the 2nd from
> 
> <camelContext id="camel"
>                xmlns="http://activemq.apache.org/camel/schema/spring">
>               <route>
>                        <from uri="jms:topic:LoggingTopic"/>
>                        <to uri="bean:msgParser"/>
>                        <to uri="bean:otherBean"/>
>              </route>
> </camelContext>
> 
> On Wed, Oct 22, 2008 at 9:08 AM, selezovikj
> <se...@gmail.com>wrote:
> 
>>
>> How can I define multiple routes in Spring ?
>> Logically, they should be in the same context and I just define different
>> <route> elements:
>>
>> <camelContext id="camel"
>>                xmlns="http://activemq.apache.org/camel/schema/spring">
>>                <route>
>>                        <from uri="jms:topic:LoggingTopic"/>
>>                        <to uri="bean:msgParser"/>
>>                </route>
>>              <route>
>>                        <from uri="bean:msgParser"/>
>>                        <to uri="bean:otherBean"/>
>>              </route>
>> </camelContext>
>>
>> I know that in this case I don't need two separate routes, since I am
>> only
>> pipelining.
>> In the Java DSL I would do the camel routing like this:
>>
>> from("ms:topic:LoggingTopic").to("bean:msgParser");
>>
>> Then I have another <from> element:
>>
>> from("bean:msgParser").to("bean:otherBean");
>>
>> What would be the equivalent configuration in Spring ?
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Multiple-Camel-Routes-in-Spring-tp20108937s22882p20108937.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Cheers,
> Jon
> 
> http://janstey.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/Multiple-Camel-Routes-in-Spring-tp20108937s22882p20109212.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Multiple Camel Routes in Spring

Posted by selezovikj <se...@gmail.com>.
I mentioned in my post that I know that I do not need two separate routes. 
I need to know how to define multiple routes, multiple <from>s. 

My message will be pipelined through a couple of beans and then when I come
to a certain bean I want to do content based routing. I want once the object
is processed in the "otherBean", the outgoing object that it will send to be
sent to the method "contentRouting" of the "contentRouter" bean, and if that
method return true, the object to be forwarded to "filterCCBean", otherwise
to the "log4jBean".
The following configuration doesn't work:

<camelContext id="camel"
		xmlns="http://activemq.apache.org/camel/schema/spring">
		<route>
			<from uri="jms:topic:LoggingTopic"/>
			<to uri="bean:msgParser"/>
			<to uri="bean:otherBean"/> 
		</route>
	</camelContext>
	
	<camelContext id="camel2"
        xmlns="http://activemq.apache.org/camel/schema/spring">
        <route>
            <from uri="bean:otherBean"/>
            <choice>
                <when>
                    <methodCall bean="contentRouter"
method="contentRouting"/>
                    <to uri="bean:filterCCBean"/>
                </when>
                <otherwise>
                    <to uri="bean:log4jBean"/>
                </otherwise>
            </choice>
        </route>
    </camelContext>




janstey wrote:
> 
> The first bit of Spring you showed is correct. If you just want to do some
> pipelining though, its simpler to avoid the 2nd from
> 
> <camelContext id="camel"
>                xmlns="http://activemq.apache.org/camel/schema/spring">
>               <route>
>                        <from uri="jms:topic:LoggingTopic"/>
>                        <to uri="bean:msgParser"/>
>                        <to uri="bean:otherBean"/>
>              </route>
> </camelContext>
> 
> On Wed, Oct 22, 2008 at 9:08 AM, selezovikj
> <se...@gmail.com>wrote:
> 
>>
>> How can I define multiple routes in Spring ?
>> Logically, they should be in the same context and I just define different
>> <route> elements:
>>
>> <camelContext id="camel"
>>                xmlns="http://activemq.apache.org/camel/schema/spring">
>>                <route>
>>                        <from uri="jms:topic:LoggingTopic"/>
>>                        <to uri="bean:msgParser"/>
>>                </route>
>>              <route>
>>                        <from uri="bean:msgParser"/>
>>                        <to uri="bean:otherBean"/>
>>              </route>
>> </camelContext>
>>
>> I know that in this case I don't need two separate routes, since I am
>> only
>> pipelining.
>> In the Java DSL I would do the camel routing like this:
>>
>> from("ms:topic:LoggingTopic").to("bean:msgParser");
>>
>> Then I have another <from> element:
>>
>> from("bean:msgParser").to("bean:otherBean");
>>
>> What would be the equivalent configuration in Spring ?
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Multiple-Camel-Routes-in-Spring-tp20108937s22882p20108937.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Cheers,
> Jon
> 
> http://janstey.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/Multiple-Camel-Routes-in-Spring-tp20108937s22882p20109212.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Multiple Camel Routes in Spring

Posted by Jon Anstey <ja...@gmail.com>.
The first bit of Spring you showed is correct. If you just want to do some
pipelining though, its simpler to avoid the 2nd from

<camelContext id="camel"
               xmlns="http://activemq.apache.org/camel/schema/spring">
              <route>
                       <from uri="jms:topic:LoggingTopic"/>
                       <to uri="bean:msgParser"/>
                       <to uri="bean:otherBean"/>
             </route>
</camelContext>

On Wed, Oct 22, 2008 at 9:08 AM, selezovikj <se...@gmail.com>wrote:

>
> How can I define multiple routes in Spring ?
> Logically, they should be in the same context and I just define different
> <route> elements:
>
> <camelContext id="camel"
>                xmlns="http://activemq.apache.org/camel/schema/spring">
>                <route>
>                        <from uri="jms:topic:LoggingTopic"/>
>                        <to uri="bean:msgParser"/>
>                </route>
>              <route>
>                        <from uri="bean:msgParser"/>
>                        <to uri="bean:otherBean"/>
>              </route>
> </camelContext>
>
> I know that in this case I don't need two separate routes, since I am only
> pipelining.
> In the Java DSL I would do the camel routing like this:
>
> from("ms:topic:LoggingTopic").to("bean:msgParser");
>
> Then I have another <from> element:
>
> from("bean:msgParser").to("bean:otherBean");
>
> What would be the equivalent configuration in Spring ?
>
> --
> View this message in context:
> http://www.nabble.com/Multiple-Camel-Routes-in-Spring-tp20108937s22882p20108937.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Jon

http://janstey.blogspot.com/