You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ankelee <an...@gmail.com> on 2010/06/03 13:19:36 UTC

Direct-route not shared across contexts?

Hi

Is it possible to have direct endpoints that will not be shared across
different camelcontexts in the same JVM? So that each camel context has its
own instance of a direct route?
-- 
View this message in context: http://old.nabble.com/Direct-route-not-shared-across-contexts--tp28766143p28766143.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Direct-route not shared across contexts?

Posted by ankelee <an...@gmail.com>.
Hi

I created a ticket on this as a bug.
I created a sample where my issue is isolated based on Claus's test. and the
test can't even run because of the 2 consumer on one direct-exception

https://issues.apache.org/activemq/browse/CAMEL-2811

I can solve this by just loading two camel Main-classed and have the
contexts completely seperated. But I think it shouldn't be necessary.




ankelee wrote:
> 
> Hi
> 
> I think the problem lies in the way I import a routeContext in both my
> .xml files. The import is not done in the camelContext tag and therefore
> the two contexts might be sharing the routedefinition? Obviously this
> setup is the same as doing to imports of the same xml in a row which
> shouldn't really do anything.
> Can I somehow either do two instances of the imported route, or have an
> instance in a CamelContext or something?
> 
> regres-camelcontext.xml:
> 	<import resource="generic-edi-routes.xml" />
> 
> 	<!-- CamelContext definition -->
> 	<camelContext id="opsigContext"
> xmlns="http://camel.apache.org/schema/spring">
> 		<!-- Load properties -->
> 		<propertyPlaceholder id="properties"
> location="classpath:opsig.properties" /> ...
> 
> 
> opsig-camelcontext.xml:
> 	<import resource="generic-edi-routes.xml" />
> 
> 	<!-- CamelContext definition -->
> 	<camelContext id="opsigContext"
> xmlns="http://camel.apache.org/schema/spring">
> 		<!-- Load properties -->
> 		<propertyPlaceholder id="properties"
> location="classpath:opsig.properties" /> ...
> 
> 
> Also I can see that only the first context+route is working when doing it
> that way.
> 
> If I load the two contexts in completely seperate containers it works as
> intended:
> 
> 	public static void main(String[] args) throws Exception {
> 		Main camelMain = new Main();
> 		camelMain.setApplicationContextUri("regres-camelcontext.xml");
> 		camelMain.enableHangupSupport();
> 		camelMain.start();
> 		
> 		Main camelMain2 = new Main();
> 		camelMain2.setApplicationContextUri("opsig-camelcontext.xml");
> 		camelMain2.enableHangupSupport();
> 		camelMain2.start();
> 	}
> 
> 
> 
> 
> Claus Ibsen-2 wrote:
>> 
>> Hi
>> 
>> I have created unit tests in both pure Java and with Spring XML and
>> cannot reproduce any such behavior
>> http://svn.apache.org/viewvc?rev=951088&view=rev
>> 
>> Direct endpoints with same endpoint uri is not shared between multiple
>> CamelContext.
>> 
>> So double check on your end what you may do wrong or what you do
>> differently.
>> 
>> On Thu, Jun 3, 2010 at 4:20 PM, ankelee <an...@gmail.com> wrote:
>>>
>>> Hi
>>>
>>>
>>> Running on Windows in JVM 1.6.
>>>
>>> I'm just loading it into a Spring container in Java main:
>>>
>>> private static String fileRessource = "isuite-client-context.xml";
>>>
>>> ClassPathXmlApplicationContext x = new
>>> ClassPathXmlApplicationContext(fileRessource);
>>>
>>>
>>>
>>>
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> Hi
>>>>
>>>> Whats your runtime environment?
>>>> And how do you start your app?
>>>> Do you use OSGi or WAR etc?
>>>>
>>>>
>>>>
>>>>
>>>> On Thu, Jun 3, 2010 at 2:28 PM, ankelee <an...@gmail.com>
>>>> wrote:
>>>>>
>>>>> Perhaps I'm doing it wrong.
>>>>>
>>>>> I load a Spring context xml file that has two imports as such.
>>>>>
>>>>> <import resource="common-beans.xml"/>
>>>>> <import resource="first-camelcontext.xml"/>
>>>>> <import resource="second-camelcontext.xml"/>
>>>>>
>>>>> The two camelcontext.xml files obviously holds a <camelContext> tag
>>>>> each.
>>>>>
>>>>> Each of contexts loads a identical route that they create their own
>>>>> instance
>>>>> of. These are configured differently with properties. Then I get a
>>>>> "direct
>>>>> endpoint cannot have more than 1 active consumer" when I run them at
>>>>> the
>>>>> same time. Maybe I don't really have two camelcontexts or?
>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://old.nabble.com/Direct-route-not-shared-across-contexts--tp28766143p28766770.html
>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Claus Ibsen
>>>> Apache Camel Committer
>>>>
>>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>>> Open Source Integration: http://fusesource.com
>>>> Blog: http://davsclaus.blogspot.com/
>>>> Twitter: http://twitter.com/davsclaus
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Direct-route-not-shared-across-contexts--tp28766143p28768147.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>> 
>> 
>> 
>> -- 
>> Claus Ibsen
>> Apache Camel Committer
>> 
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Direct-route-not-shared-across-contexts--tp28766143p28881074.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Direct-route not shared across contexts?

Posted by ankelee <an...@gmail.com>.
Hi

I think the problem lies in the way I import a routeContext in both my .xml
files. The import is not done in the camelContext tag and therefore the two
contexts might be sharing the routedefinition? Obviously this setup is the
same as doing to imports of the same xml in a row which shouldn't really do
anything.
Can I somehow either do two instances of the imported route, or have an
instance in a CamelContext or something?

regres-camelcontext.xml:
	<import resource="generic-edi-routes.xml" />

	<!-- CamelContext definition -->
	<camelContext id="opsigContext"
xmlns="http://camel.apache.org/schema/spring">
		<!-- Load properties -->
		<propertyPlaceholder id="properties" location="classpath:opsig.properties"
/> ...


opsig-camelcontext.xml:
	<import resource="generic-edi-routes.xml" />

	<!-- CamelContext definition -->
	<camelContext id="opsigContext"
xmlns="http://camel.apache.org/schema/spring">
		<!-- Load properties -->
		<propertyPlaceholder id="properties" location="classpath:opsig.properties"
/> ...


Also I can see that only the first context+route is working when doing it
that way.

If I load the two contexts in completely seperate containers it works as
intended:

	public static void main(String[] args) throws Exception {
		Main camelMain = new Main();
		camelMain.setApplicationContextUri("regres-camelcontext.xml");
		camelMain.enableHangupSupport();
		camelMain.start();
		
		Main camelMain2 = new Main();
		camelMain2.setApplicationContextUri("opsig-camelcontext.xml");
		camelMain2.enableHangupSupport();
		camelMain2.start();
	}




Claus Ibsen-2 wrote:
> 
> Hi
> 
> I have created unit tests in both pure Java and with Spring XML and
> cannot reproduce any such behavior
> http://svn.apache.org/viewvc?rev=951088&view=rev
> 
> Direct endpoints with same endpoint uri is not shared between multiple
> CamelContext.
> 
> So double check on your end what you may do wrong or what you do
> differently.
> 
> On Thu, Jun 3, 2010 at 4:20 PM, ankelee <an...@gmail.com> wrote:
>>
>> Hi
>>
>>
>> Running on Windows in JVM 1.6.
>>
>> I'm just loading it into a Spring container in Java main:
>>
>> private static String fileRessource = "isuite-client-context.xml";
>>
>> ClassPathXmlApplicationContext x = new
>> ClassPathXmlApplicationContext(fileRessource);
>>
>>
>>
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> Hi
>>>
>>> Whats your runtime environment?
>>> And how do you start your app?
>>> Do you use OSGi or WAR etc?
>>>
>>>
>>>
>>>
>>> On Thu, Jun 3, 2010 at 2:28 PM, ankelee <an...@gmail.com> wrote:
>>>>
>>>> Perhaps I'm doing it wrong.
>>>>
>>>> I load a Spring context xml file that has two imports as such.
>>>>
>>>> <import resource="common-beans.xml"/>
>>>> <import resource="first-camelcontext.xml"/>
>>>> <import resource="second-camelcontext.xml"/>
>>>>
>>>> The two camelcontext.xml files obviously holds a <camelContext> tag
>>>> each.
>>>>
>>>> Each of contexts loads a identical route that they create their own
>>>> instance
>>>> of. These are configured differently with properties. Then I get a
>>>> "direct
>>>> endpoint cannot have more than 1 active consumer" when I run them at
>>>> the
>>>> same time. Maybe I don't really have two camelcontexts or?
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/Direct-route-not-shared-across-contexts--tp28766143p28766770.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Author of Camel in Action: http://www.manning.com/ibsen/
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Direct-route-not-shared-across-contexts--tp28766143p28768147.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://old.nabble.com/Direct-route-not-shared-across-contexts--tp28766143p28877793.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Direct-route not shared across contexts?

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

I have created unit tests in both pure Java and with Spring XML and
cannot reproduce any such behavior
http://svn.apache.org/viewvc?rev=951088&view=rev

Direct endpoints with same endpoint uri is not shared between multiple
CamelContext.

So double check on your end what you may do wrong or what you do differently.

On Thu, Jun 3, 2010 at 4:20 PM, ankelee <an...@gmail.com> wrote:
>
> Hi
>
>
> Running on Windows in JVM 1.6.
>
> I'm just loading it into a Spring container in Java main:
>
> private static String fileRessource = "isuite-client-context.xml";
>
> ClassPathXmlApplicationContext x = new
> ClassPathXmlApplicationContext(fileRessource);
>
>
>
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> Whats your runtime environment?
>> And how do you start your app?
>> Do you use OSGi or WAR etc?
>>
>>
>>
>>
>> On Thu, Jun 3, 2010 at 2:28 PM, ankelee <an...@gmail.com> wrote:
>>>
>>> Perhaps I'm doing it wrong.
>>>
>>> I load a Spring context xml file that has two imports as such.
>>>
>>> <import resource="common-beans.xml"/>
>>> <import resource="first-camelcontext.xml"/>
>>> <import resource="second-camelcontext.xml"/>
>>>
>>> The two camelcontext.xml files obviously holds a <camelContext> tag each.
>>>
>>> Each of contexts loads a identical route that they create their own
>>> instance
>>> of. These are configured differently with properties. Then I get a
>>> "direct
>>> endpoint cannot have more than 1 active consumer" when I run them at the
>>> same time. Maybe I don't really have two camelcontexts or?
>>>
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Direct-route-not-shared-across-contexts--tp28766143p28766770.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Direct-route-not-shared-across-contexts--tp28766143p28768147.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Direct-route not shared across contexts?

Posted by ankelee <an...@gmail.com>.
Hi


Running on Windows in JVM 1.6.

I'm just loading it into a Spring container in Java main:

private static String fileRessource = "isuite-client-context.xml"; 

ClassPathXmlApplicationContext x = new
ClassPathXmlApplicationContext(fileRessource);





Claus Ibsen-2 wrote:
> 
> Hi
> 
> Whats your runtime environment?
> And how do you start your app?
> Do you use OSGi or WAR etc?
> 
> 
> 
> 
> On Thu, Jun 3, 2010 at 2:28 PM, ankelee <an...@gmail.com> wrote:
>>
>> Perhaps I'm doing it wrong.
>>
>> I load a Spring context xml file that has two imports as such.
>>
>> <import resource="common-beans.xml"/>
>> <import resource="first-camelcontext.xml"/>
>> <import resource="second-camelcontext.xml"/>
>>
>> The two camelcontext.xml files obviously holds a <camelContext> tag each.
>>
>> Each of contexts loads a identical route that they create their own
>> instance
>> of. These are configured differently with properties. Then I get a
>> "direct
>> endpoint cannot have more than 1 active consumer" when I run them at the
>> same time. Maybe I don't really have two camelcontexts or?
>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Direct-route-not-shared-across-contexts--tp28766143p28766770.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://old.nabble.com/Direct-route-not-shared-across-contexts--tp28766143p28768147.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Direct-route not shared across contexts?

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

Whats your runtime environment?
And how do you start your app?
Do you use OSGi or WAR etc?




On Thu, Jun 3, 2010 at 2:28 PM, ankelee <an...@gmail.com> wrote:
>
> Perhaps I'm doing it wrong.
>
> I load a Spring context xml file that has two imports as such.
>
> <import resource="common-beans.xml"/>
> <import resource="first-camelcontext.xml"/>
> <import resource="second-camelcontext.xml"/>
>
> The two camelcontext.xml files obviously holds a <camelContext> tag each.
>
> Each of contexts loads a identical route that they create their own instance
> of. These are configured differently with properties. Then I get a "direct
> endpoint cannot have more than 1 active consumer" when I run them at the
> same time. Maybe I don't really have two camelcontexts or?
>
>
> --
> View this message in context: http://old.nabble.com/Direct-route-not-shared-across-contexts--tp28766143p28766770.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Direct-route not shared across contexts?

Posted by ankelee <an...@gmail.com>.
Perhaps I'm doing it wrong.

I load a Spring context xml file that has two imports as such.

<import resource="common-beans.xml"/>
<import resource="first-camelcontext.xml"/>
<import resource="second-camelcontext.xml"/>

The two camelcontext.xml files obviously holds a <camelContext> tag each.

Each of contexts loads a identical route that they create their own instance
of. These are configured differently with properties. Then I get a "direct
endpoint cannot have more than 1 active consumer" when I run them at the
same time. Maybe I don't really have two camelcontexts or?


-- 
View this message in context: http://old.nabble.com/Direct-route-not-shared-across-contexts--tp28766143p28766770.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Direct-route not shared across contexts?

Posted by Adrian Trenaman <tr...@progress.com>.
Yikes - Guillaume, you're right - I misfired on this one.

By default, each direct: endpoint should be 'isolated' within it's own 
camel context. So, if Andreas is experiencing something different, where 
direct: endpoints from different contexts are being shared 
'cross-context' then this would be a bug.

/Ade

On 03/06/2010 12:32, Guillaume Nodet wrote:
> I think Andreas is looking for exactly the opposite.
> I don't think the goal of the direct: component was that endpoints
> would be shared across camel context (as that's what vm: has been
> written for).
> So i'm kinda tempted to consider that a bug.
>
> On Thu, Jun 3, 2010 at 13:27, Adrian Trenaman<tr...@progress.com>  wrote:
>    
>> Fraid not!
>>
>> If you want to cross camel contexts in the same JVM, you could use the Camel
>> VM (http://camel.apache.org/vm.html) component to do this. Or, you can take
>> a look at using the NMR in SMX4 to achieve something similar.
>>
>> Hope that helps,
>> Ade.
>>
>> On 03/06/2010 12:19, ankelee wrote:
>>      
>>> Hi
>>>
>>> Is it possible to have direct endpoints that will not be shared across
>>> different camelcontexts in the same JVM? So that each camel context has
>>> its
>>> own instance of a direct route?
>>>
>>>        
>>      
>
>
>    

Re: Direct-route not shared across contexts?

Posted by Guillaume Nodet <gn...@gmail.com>.
I think Andreas is looking for exactly the opposite.
I don't think the goal of the direct: component was that endpoints
would be shared across camel context (as that's what vm: has been
written for).
So i'm kinda tempted to consider that a bug.

On Thu, Jun 3, 2010 at 13:27, Adrian Trenaman <tr...@progress.com> wrote:
> Fraid not!
>
> If you want to cross camel contexts in the same JVM, you could use the Camel
> VM (http://camel.apache.org/vm.html) component to do this. Or, you can take
> a look at using the NMR in SMX4 to achieve something similar.
>
> Hope that helps,
> Ade.
>
> On 03/06/2010 12:19, ankelee wrote:
>>
>> Hi
>>
>> Is it possible to have direct endpoints that will not be shared across
>> different camelcontexts in the same JVM? So that each camel context has
>> its
>> own instance of a direct route?
>>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Re: Direct-route not shared across contexts?

Posted by Adrian Trenaman <tr...@progress.com>.
Fraid not!

If you want to cross camel contexts in the same JVM, you could use the 
Camel VM (http://camel.apache.org/vm.html) component to do this. Or, you 
can take a look at using the NMR in SMX4 to achieve something similar.

Hope that helps,
Ade.

On 03/06/2010 12:19, ankelee wrote:
> Hi
>
> Is it possible to have direct endpoints that will not be shared across
> different camelcontexts in the same JVM? So that each camel context has its
> own instance of a direct route?
>