You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "james.z.zhou" <ja...@hotmail.com> on 2013/02/20 16:20:27 UTC

Why I cannot run multiple CamelContext simultaneously?

Hi:

The story is, I have two camelContexts defined in two XML files, say
camel-context1.xml and camel-context2.xml and I imported them to a main.xml,
the main.xml looks like:

...
<import spring-DB.xml>
<import spring-PROCESSOR.xml>
<import spring-camel-context1.xml>
<import spring-camel-context2.xml>
</beans>

DB.xml contains DB-related bean definitions, like jpaComponent and
PROCESSOR.xml contains the processor bean definitions.

In the Main class, I newed a Camel.Spring.Main instance:

Main main = new Main();

main.setApplicationContextUri("config/main.xml");
main.enableHangupSupport();
main.run();

In the log file, I can see all the xml files imported in main.xml are loaded
successfully. However, only the camelContext in camel-context1 starts
working, the camelContext in camel-context2 is not working. If I move
<import spring-camel-context2.xml> above <import spring-camel-context1.xml>,
then the camelContext in camel-context2 starts working, the camelContext in
camel-context1 is not working.

BTW, I am using the jar version: 2.10.0

Do you guys have any idea please?

thanks

james



--
View this message in context: http://camel.465427.n5.nabble.com/Why-I-cannot-run-multiple-CamelContext-simultaneously-tp5727877.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Why I cannot run multiple CamelContext simultaneously?

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Feb 25, 2013 at 6:17 AM, Willem jiang <wi...@gmail.com> wrote:
> Hi,
>
> It looks like a bug of Camel. Do you mind to fill a JIRA[1] for it?
>
> [1]http://issues.apache.org/jira/browse/CAMEL
>

That is too soon to tell. The user needs to provide more details what
happens, for example if there is any exceptions or other kind of
messages form the logs etc.

And if he can put together a small sample that reproduces the issue.

And as always he should tell us which Camel version and Spring version
he uses. And what OS and JDK is sometimes also good information to
know. And he should try upgrading to a newer release as well.



> --
> Willem Jiang
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Web: http://www.fusesource.com | http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
>           http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
> Twitter: willemjiang
> Weibo: 姜宁willem
>
>
>
>
>
> On Saturday, February 23, 2013 at 11:04 PM, james.z.zhou wrote:
>
>> Hi DOLECEK:
>>
>> Thank you very much for your reply!
>>
>> I tired with your suggestion, I EXPLICITLY set unique ids for the
>> camelContext, it is till NOT working. what I did is like this:
>>
>> <camelContext xmlns="http://camel.apache.org/schema/spring" id="camelONE" >
>> <camelContext xmlns="http://camel.apache.org/schema/spring" id="camelTWO" >
>>
>> I start jconsle and I found only the first *Hit*-"camelONE" shown up under
>> context.
>>
>> I tired another thing, the routeContext. I took
>> http://camel.apache.org/how-do-i-import-routes-from-other-xml-files.html as
>> the reference and the result made me even more confused.
>>
>> I have three routes, I put two in a routeContext and one in another
>> routeContext. I set explicitly the unique IDs to both the routeContexts and
>> routes:
>>
>> <beans xmlns="http://www.springframework.org/schema/beans"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="
>> http://www.springframework.org/schema/beans
>> http://www.springframework.org/schema/beans/spring-beans.xsd
>> http://camel.apache.org/schema/spring
>> http://camel.apache.org/schema/spring/camel-spring.xsd
>> ">
>>
>> <routeContext id="oneCtx" xmlns="http://camel.apache.org/schema/spring">
>> <route id="jpaRoute">
>> <from
>> uri="jpa:com.xxx.xxx.xxx.xxx (http://com.xxx.xxx.xxx.xxx)?consumer.nameQuery=xxx&amp;consumer.delay=500"/>
>> <process=&quot;myProcessor&quot;>
>> <filter>
>> ...
>> <to uri="jpa:com.xxx.xxx.xxx.xxx (http://com.xxx.xxx.xxx.xxx)"/>
>> </filter>
>> </route>
>>
>> <route id="tibcoRoute"> -- I am using TibRV version 8.3
>> <from uri="tibco:listen?service=xxxx&amp;network=;xxx.xxx.xx.xxx (http://xxx.xxx.xx.xxx)
>> ..."/>
>> <process=&quot;myProcessor&quot;>
>> <filter>
>> ...
>> <to uri="jpa:com.xxx.xxx.xxx.xxx (http://com.xxx.xxx.xxx.xxx)"/>
>> </filter>
>> </route>
>> </routeContext>
>> </beans>
>>
>> another routeContext:
>>
>> <routeContext id="twoCtx" xmlns="http://camel.apache.org/schema/spring">
>> <route id="anoterTibcoRoute">
>> <from uri="tibco:listen?service=xxxx&amp;network=;xxx.xxx.xx.xxx (http://xxx.xxx.xx.xxx)
>> ..."/>
>> <process=&quot;myProcessor&quot;>
>> <filter>
>> ...
>> <to uri="tibco:listen?service=xxxx&amp;network=;xxx.xxx.xx.xxx (http://xxx.xxx.xx.xxx)
>> ..."/>
>> </filter>
>> </route>
>> </routeContext>
>> </beans>
>>
>> The two routeContexts defined in two xml files, say routeContext1.xml and
>> routeContext2.xml. Then I added them into a camelContext:
>>
>> <import resource="routeContext1.xml"/>
>> <import resource="routeContext2.xml"/>
>>
>> <camelContext xmlns="http://camel.apache.org/schema/spring">
>> <routeContextRef ref="oneCtx"/>
>> <routeContextRef ref="twoCtx"/>
>> ...
>>
>> After I start the appication, I can see all the three routes listed under
>> "Route", however, only the last *hit* route in the last *hit* routeContext,
>> <route id="anoterTibcoRoute"> in this case, start doing job. If I change the
>> order of the two routeContexts in the camelContext, put <routeContextRef
>> ref="twoCtx"/> above <routeContextRef ref="oneCtx"/>, only <route
>> id="tibcoRoute"> start doing job.
>>
>> Then I removed <routeContextRef ref="twoCtx"/> from the camelContext & just
>> kept <routeContextRef ref="oneCtx"/> in, I saw two routes in the jconsole
>> but only <route id="tibcoRoute"> start doing job, also the last *hit* one in
>> the routeContext.
>>
>> Then, I tried with one last senario, still kept one routeContext:
>> <routeContextRef ref="oneCtx"/> in the camelContext, and added one route:
>> <route id="test">
>> <from uri="file://inputdir" />
>> <to uri="file://outputdir" />
>> </route>
>>
>> The first time I removed <route id="tibcoRoute">, kept <route id="test">
>> and <route id="jpaRoute">, both of them are working perfectly, the second
>> time I removed <route id="jpaRoute">, kept <route id="test"> and <route
>> id="tibcoRoute">, also working perfectly for both. So this proves
>> routeContext does support multiple routes run simultaneously. Another thing
>> I want to mention out is if I put <route id="jpaRoute"> and <route
>> id="tibcoRoute"> directly in a camelContext, both of them are working well,
>> simultaneously.
>>
>> Conclusion, does camel support both TibcoRV & jpa endpoints in ONE
>> routeContext? Anyother ideas about for my case, why multiple camelContext
>> cannot run simultaneously? namespace issue? conflict somewhere?
>>
>> thanks
>>
>> james
>>
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Why-I-cannot-run-multiple-CamelContext-simultaneously-tp5727877p5728055.html
>> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).
>
>
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Why I cannot run multiple CamelContext simultaneously?

Posted by Willem jiang <wi...@gmail.com>.
Hi,

It looks like a bug of Camel. Do you mind to fill a JIRA[1] for it?

[1]http://issues.apache.org/jira/browse/CAMEL  

--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Saturday, February 23, 2013 at 11:04 PM, james.z.zhou wrote:

> Hi DOLECEK:
>  
> Thank you very much for your reply!  
>  
> I tired with your suggestion, I EXPLICITLY set unique ids for the
> camelContext, it is till NOT working. what I did is like this:
>  
> <camelContext xmlns="http://camel.apache.org/schema/spring" id="camelONE" >
> <camelContext xmlns="http://camel.apache.org/schema/spring" id="camelTWO" >
>  
> I start jconsle and I found only the first *Hit*-"camelONE" shown up under
> context.
>  
> I tired another thing, the routeContext. I took
> http://camel.apache.org/how-do-i-import-routes-from-other-xml-files.html as
> the reference and the result made me even more confused.
>  
> I have three routes, I put two in a routeContext and one in another
> routeContext. I set explicitly the unique IDs to both the routeContexts and
> routes:
>  
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
> http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd
> ">
>  
> <routeContext id="oneCtx" xmlns="http://camel.apache.org/schema/spring">
> <route id="jpaRoute">
> <from
> uri="jpa:com.xxx.xxx.xxx.xxx (http://com.xxx.xxx.xxx.xxx)?consumer.nameQuery=xxx&amp;consumer.delay=500"/>
> <process=&quot;myProcessor&quot;>
> <filter>
> ...
> <to uri="jpa:com.xxx.xxx.xxx.xxx (http://com.xxx.xxx.xxx.xxx)"/>
> </filter>  
> </route>
>  
> <route id="tibcoRoute"> -- I am using TibRV version 8.3
> <from uri="tibco:listen?service=xxxx&amp;network=;xxx.xxx.xx.xxx (http://xxx.xxx.xx.xxx)
> ..."/>
> <process=&quot;myProcessor&quot;>
> <filter>
> ...
> <to uri="jpa:com.xxx.xxx.xxx.xxx (http://com.xxx.xxx.xxx.xxx)"/>
> </filter>  
> </route>
> </routeContext>
> </beans>
>  
> another routeContext:
>  
> <routeContext id="twoCtx" xmlns="http://camel.apache.org/schema/spring">
> <route id="anoterTibcoRoute">
> <from uri="tibco:listen?service=xxxx&amp;network=;xxx.xxx.xx.xxx (http://xxx.xxx.xx.xxx)
> ..."/>
> <process=&quot;myProcessor&quot;>
> <filter>
> ...
> <to uri="tibco:listen?service=xxxx&amp;network=;xxx.xxx.xx.xxx (http://xxx.xxx.xx.xxx)
> ..."/>
> </filter>  
> </route>
> </routeContext>
> </beans>
>  
> The two routeContexts defined in two xml files, say routeContext1.xml and
> routeContext2.xml. Then I added them into a camelContext:
>  
> <import resource="routeContext1.xml"/>
> <import resource="routeContext2.xml"/>
>  
> <camelContext xmlns="http://camel.apache.org/schema/spring">
> <routeContextRef ref="oneCtx"/>
> <routeContextRef ref="twoCtx"/>
> ...
>  
> After I start the appication, I can see all the three routes listed under
> "Route", however, only the last *hit* route in the last *hit* routeContext,  
> <route id="anoterTibcoRoute"> in this case, start doing job. If I change the
> order of the two routeContexts in the camelContext, put <routeContextRef
> ref="twoCtx"/> above <routeContextRef ref="oneCtx"/>, only <route
> id="tibcoRoute"> start doing job.
>  
> Then I removed <routeContextRef ref="twoCtx"/> from the camelContext & just
> kept <routeContextRef ref="oneCtx"/> in, I saw two routes in the jconsole
> but only <route id="tibcoRoute"> start doing job, also the last *hit* one in
> the routeContext.
>  
> Then, I tried with one last senario, still kept one routeContext:
> <routeContextRef ref="oneCtx"/> in the camelContext, and added one route:
> <route id="test">
> <from uri="file://inputdir" />
> <to uri="file://outputdir" />
> </route>
>  
> The first time I removed <route id="tibcoRoute">, kept <route id="test">
> and <route id="jpaRoute">, both of them are working perfectly, the second
> time I removed <route id="jpaRoute">, kept <route id="test"> and <route
> id="tibcoRoute">, also working perfectly for both. So this proves
> routeContext does support multiple routes run simultaneously. Another thing
> I want to mention out is if I put <route id="jpaRoute"> and <route
> id="tibcoRoute"> directly in a camelContext, both of them are working well,
> simultaneously.  
>  
> Conclusion, does camel support both TibcoRV & jpa endpoints in ONE
> routeContext? Anyother ideas about for my case, why multiple camelContext
> cannot run simultaneously? namespace issue? conflict somewhere?
>  
> thanks
>  
> james
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Why-I-cannot-run-multiple-CamelContext-simultaneously-tp5727877p5728055.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




RE: Why I cannot run multiple CamelContext simultaneously?

Posted by "james.z.zhou" <ja...@hotmail.com>.
Hi DOLECEK:

Thank you very much for your reply! 

I tired with your suggestion, I EXPLICITLY set unique ids for the
camelContext, it is till NOT working. what I did is like this:

<camelContext xmlns="http://camel.apache.org/schema/spring" id="camelONE" >
<camelContext xmlns="http://camel.apache.org/schema/spring" id="camelTWO" >

I start jconsle and I found only the first *Hit*-"camelONE" shown up under
context.

I tired another thing, the routeContext. I took
http://camel.apache.org/how-do-i-import-routes-from-other-xml-files.html as
the reference and the result made me even more confused.

I have three routes, I put two in a routeContext and one in another
routeContext. I set explicitly the unique IDs to both the routeContexts and
routes:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
    ">

<routeContext id="oneCtx" xmlns="http://camel.apache.org/schema/spring">
        <route id="jpaRoute">
            <from
uri="jpa:com.xxx.xxx.xxx.xxx?consumer.nameQuery=xxx&amp;consumer.delay=500"/>
            <process=&quot;myProcessor&quot;>
            <filter>
            ...
            <to uri="jpa:com.xxx.xxx.xxx.xxx"/>
            </filter>            
        </route>

        <route id="tibcoRoute"> -- I am using TibRV version 8.3
            <from uri="tibco:listen?service=xxxx&amp;network=;xxx.xxx.xx.xxx
..."/>
            <process=&quot;myProcessor&quot;>
            <filter>
            ...
            <to uri="jpa:com.xxx.xxx.xxx.xxx"/>
            </filter>            
        </route>
</routeContext>
</beans>

another routeContext:

<routeContext id="twoCtx" xmlns="http://camel.apache.org/schema/spring">
        <route id="anoterTibcoRoute">
            <from uri="tibco:listen?service=xxxx&amp;network=;xxx.xxx.xx.xxx
..."/>
            <process=&quot;myProcessor&quot;>
            <filter>
            ...
            <to uri="tibco:listen?service=xxxx&amp;network=;xxx.xxx.xx.xxx
..."/>
            </filter>            
        </route>
</routeContext>
</beans>

The two routeContexts defined in two xml files, say routeContext1.xml and
routeContext2.xml. Then I added them into a camelContext:

<import resource="routeContext1.xml"/>
<import resource="routeContext2.xml"/>

<camelContext xmlns="http://camel.apache.org/schema/spring">
<routeContextRef ref="oneCtx"/>
<routeContextRef ref="twoCtx"/>
...

After I start the appication, I can see all the three routes listed under
"Route", however, only the last *hit* route in the last *hit* routeContext, 
<route id="anoterTibcoRoute"> in this case, start doing job. If I change the
order of the two routeContexts in the camelContext, put <routeContextRef
ref="twoCtx"/> above <routeContextRef ref="oneCtx"/>, only <route
id="tibcoRoute"> start doing job.

Then I removed <routeContextRef ref="twoCtx"/> from the camelContext & just
kept <routeContextRef ref="oneCtx"/> in, I saw two routes in the jconsole
but only <route id="tibcoRoute"> start doing job, also the last *hit* one in
the routeContext.

Then, I tried with one last senario, still kept one routeContext:
<routeContextRef ref="oneCtx"/> in the camelContext, and added one route:
<route id="test">
<from uri="file://inputdir" />
<to uri="file://outputdir" />
</route>

The first time I removed  <route id="tibcoRoute">, kept <route id="test">
and <route id="jpaRoute">, both of them are working perfectly, the second
time I removed <route id="jpaRoute">, kept <route id="test"> and <route
id="tibcoRoute">, also working perfectly for both. So this proves
routeContext does support multiple routes run simultaneously. Another thing
I want to mention out is if I put <route id="jpaRoute"> and <route
id="tibcoRoute"> directly in a camelContext, both of them are working well,
simultaneously. 

Conclusion, does camel support both TibcoRV & jpa endpoints in ONE
routeContext? Anyother ideas about for my case, why multiple camelContext
cannot run simultaneously? namespace issue? conflict somewhere?

thanks

james




--
View this message in context: http://camel.465427.n5.nabble.com/Why-I-cannot-run-multiple-CamelContext-simultaneously-tp5727877p5728055.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Why I cannot run multiple CamelContext simultaneously?

Posted by DOLECEK Ales <Al...@nextiraone.eu>.
Should work. Did you EXPLICITLY specified context IDs?
If you have more than one context you can't rely on the default since all context would get same - and that is not possible.

Ales

-----Original Message-----
From: james.z.zhou [mailto:james.z.zhou@hotmail.com] 
Sent: Wednesday, February 20, 2013 4:20 PM
To: users@camel.apache.org
Subject: Why I cannot run multiple CamelContext simultaneously?

Hi:

The story is, I have two camelContexts defined in two XML files, say camel-context1.xml and camel-context2.xml and I imported them to a main.xml, the main.xml looks like:

...
<import spring-DB.xml>
<import spring-PROCESSOR.xml>
<import spring-camel-context1.xml>
<import spring-camel-context2.xml>
</beans>

DB.xml contains DB-related bean definitions, like jpaComponent and PROCESSOR.xml contains the processor bean definitions.

In the Main class, I newed a Camel.Spring.Main instance:

Main main = new Main();

main.setApplicationContextUri("config/main.xml");
main.enableHangupSupport();
main.run();

In the log file, I can see all the xml files imported in main.xml are loaded successfully. However, only the camelContext in camel-context1 starts working, the camelContext in camel-context2 is not working. If I move <import spring-camel-context2.xml> above <import spring-camel-context1.xml>, then the camelContext in camel-context2 starts working, the camelContext in
camel-context1 is not working.

BTW, I am using the jar version: 2.10.0

Do you guys have any idea please?

thanks

james



--
View this message in context: http://camel.465427.n5.nabble.com/Why-I-cannot-run-multiple-CamelContext-simultaneously-tp5727877.html
Sent from the Camel - Users mailing list archive at Nabble.com.