You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Thiago Souza <tc...@gmail.com> on 2010/07/27 05:58:05 UTC

Visibility between camel contexts

Hi,

      In a standalone spring application context the following is perfectly
fine:


  	<c:camelContext id="endpoints">
		<c:endpoint id="source" uri="file://source" />
		<c:endpoint id="target" uri="file://target" />
	</c:camelContext>
	
  	<c:camelContext id="routes">
		<c:route>
			<c:from ref="source" />
			<c:to ref="target" />
		</c:route>
	</c:camelContext>


       That is, the configured camelContexts can see each other. Is it
possible to achieve this in Karaf?  (i.e. "endpoints" goes in a xml and
"routes" goes in another one)

        I've tried with no success, the xml containing "routes" can not see
the endpoints defined in "endpoints" (in another xml)

Regards,
Thiago Souza

-- 
View this message in context: http://camel.465427.n5.nabble.com/Visibility-between-camel-contexts-tp2255423p2255423.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Visibility between camel contexts

Posted by Thiago Souza <tc...@gmail.com>.
Why it is a bad practice?

On Tue, Jul 27, 2010 at 3:19 AM, Claus Ibsen-2 [via Camel] <
ml-node+2255481-1502974992-15243@n5.nabble.com<ml...@n5.nabble.com>
> wrote:

> On Tue, Jul 27, 2010 at 5:58 AM, Thiago Souza <[hidden email]<http://user/SendEmail.jtp?type=node&node=2255481&i=0>>
> wrote:
>
> >
> > Hi,
> >
> >      In a standalone spring application context the following is
> perfectly
> > fine:
> >
> >
> >        <c:camelContext id="endpoints">
> >                <c:endpoint id="source" uri="file://source" />
> >                <c:endpoint id="target" uri="file://target" />
> >        </c:camelContext>
> >
> >        <c:camelContext id="routes">
> >                <c:route>
> >                        <c:from ref="source" />
> >                        <c:to ref="target" />
> >                </c:route>
> >        </c:camelContext>
> >
> >
> >       That is, the configured camelContexts can see each other. Is it
> > possible to achieve this in Karaf?  (i.e. "endpoints" goes in a xml and
> > "routes" goes in another one)
> >
> >        I've tried with no success, the xml containing "routes" can not
> see
> > the endpoints defined in "endpoints" (in another xml)
> >
>
> It's bad practice to use endpoints define in another CamelContext. As
> Adrian said the CamelContext should be isolated.
> The reason why the <endpoint> appears to work is because of Spring.
> It's spring factory bean which creates the endpoint and add's to it's
> ApplicationContext.
> And hence why you can lookup the endpoint from another CamelContext.
> Because it lookup in the shared Spring ApplicationContext.
>
> Maybe we should enforce Camel to only accept endpoints created by itself.
>
>
> > Regards,
> > Thiago Souza
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Visibility-between-camel-contexts-tp2255423p2255423.html<http://camel.465427.n5.nabble.com/Visibility-between-camel-contexts-tp2255423p2255423.html?by-user=t>
> > 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<http://fusesource.com?by-user=t>
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
>
> ------------------------------
>  View message @
> http://camel.465427.n5.nabble.com/Visibility-between-camel-contexts-tp2255423p2255481.html
> To unsubscribe from Visibility between camel contexts, click here< (link removed) =>.
>
>
>

-- 
View this message in context: http://camel.465427.n5.nabble.com/Visibility-between-camel-contexts-tp2255423p2256182.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Visibility between camel contexts

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jul 27, 2010 at 11:50 AM, Willem Jiang <wi...@gmail.com> wrote:
>
> Claus Ibsen wrote:
>>
>> On Tue, Jul 27, 2010 at 5:58 AM, Thiago Souza <tc...@gmail.com>
>> wrote:
>>>
>>> Hi,
>>>
>>>     In a standalone spring application context the following is perfectly
>>> fine:
>>>
>>>
>>>       <c:camelContext id="endpoints">
>>>               <c:endpoint id="source" uri="file://source" />
>>>               <c:endpoint id="target" uri="file://target" />
>>>       </c:camelContext>
>>>
>>>       <c:camelContext id="routes">
>>>               <c:route>
>>>                       <c:from ref="source" />
>>>                       <c:to ref="target" />
>>>               </c:route>
>>>       </c:camelContext>
>>>
>>>
>>>      That is, the configured camelContexts can see each other. Is it
>>> possible to achieve this in Karaf?  (i.e. "endpoints" goes in a xml and
>>> "routes" goes in another one)
>>>
>>>       I've tried with no success, the xml containing "routes" can not see
>>> the endpoints defined in "endpoints" (in another xml)
>>>
>>
>> It's bad practice to use endpoints define in another CamelContext. As
>> Adrian said the CamelContext should be isolated.
>> The reason why the <endpoint> appears to work is because of Spring.
>> It's spring factory bean which creates the endpoint and add's to it's
>> ApplicationContext.
>> And hence why you can lookup the endpoint from another CamelContext.
>> Because it lookup in the shared Spring ApplicationContext.
>>
>> Maybe we should enforce Camel to only accept endpoints created by itself.
>>
> Every cxf endpoint should have reference of camel context.
> We could let camel context check if the endpoint is in the same camel
> context when it setups the route definition.
>

I created a ticket to track this issue
https://issues.apache.org/activemq/browse/CAMEL-2998

Endpoints can be created/used from most _everywhere_ and from dynamic
EIP patterns.
So the check should most likely be in a central area such as
DefaultCamelContext which performs the lookup.



> Willem
>>
>>> Regards,
>>> Thiago Souza
>>>
>>> --
>>> View this message in context:
>>> http://camel.465427.n5.nabble.com/Visibility-between-camel-contexts-tp2255423p2255423.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: Visibility between camel contexts

Posted by Willem Jiang <wi...@gmail.com>.
Claus Ibsen wrote:
> On Tue, Jul 27, 2010 at 5:58 AM, Thiago Souza <tc...@gmail.com> wrote:
>> Hi,
>>
>>      In a standalone spring application context the following is perfectly
>> fine:
>>
>>
>>        <c:camelContext id="endpoints">
>>                <c:endpoint id="source" uri="file://source" />
>>                <c:endpoint id="target" uri="file://target" />
>>        </c:camelContext>
>>
>>        <c:camelContext id="routes">
>>                <c:route>
>>                        <c:from ref="source" />
>>                        <c:to ref="target" />
>>                </c:route>
>>        </c:camelContext>
>>
>>
>>       That is, the configured camelContexts can see each other. Is it
>> possible to achieve this in Karaf?  (i.e. "endpoints" goes in a xml and
>> "routes" goes in another one)
>>
>>        I've tried with no success, the xml containing "routes" can not see
>> the endpoints defined in "endpoints" (in another xml)
>>
> 
> It's bad practice to use endpoints define in another CamelContext. As
> Adrian said the CamelContext should be isolated.
> The reason why the <endpoint> appears to work is because of Spring.
> It's spring factory bean which creates the endpoint and add's to it's
> ApplicationContext.
> And hence why you can lookup the endpoint from another CamelContext.
> Because it lookup in the shared Spring ApplicationContext.
> 
> Maybe we should enforce Camel to only accept endpoints created by itself.
> 
Every cxf endpoint should have reference of camel context.
We could let camel context check if the endpoint is in the same camel 
context when it setups the route definition.

Willem
> 
>> Regards,
>> Thiago Souza
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Visibility-between-camel-contexts-tp2255423p2255423.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
> 
> 
> 


Re: Visibility between camel contexts

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jul 27, 2010 at 5:58 AM, Thiago Souza <tc...@gmail.com> wrote:
>
> Hi,
>
>      In a standalone spring application context the following is perfectly
> fine:
>
>
>        <c:camelContext id="endpoints">
>                <c:endpoint id="source" uri="file://source" />
>                <c:endpoint id="target" uri="file://target" />
>        </c:camelContext>
>
>        <c:camelContext id="routes">
>                <c:route>
>                        <c:from ref="source" />
>                        <c:to ref="target" />
>                </c:route>
>        </c:camelContext>
>
>
>       That is, the configured camelContexts can see each other. Is it
> possible to achieve this in Karaf?  (i.e. "endpoints" goes in a xml and
> "routes" goes in another one)
>
>        I've tried with no success, the xml containing "routes" can not see
> the endpoints defined in "endpoints" (in another xml)
>

It's bad practice to use endpoints define in another CamelContext. As
Adrian said the CamelContext should be isolated.
The reason why the <endpoint> appears to work is because of Spring.
It's spring factory bean which creates the endpoint and add's to it's
ApplicationContext.
And hence why you can lookup the endpoint from another CamelContext.
Because it lookup in the shared Spring ApplicationContext.

Maybe we should enforce Camel to only accept endpoints created by itself.


> Regards,
> Thiago Souza
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Visibility-between-camel-contexts-tp2255423p2255423.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: Visibility between camel contexts

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jul 27, 2010 at 2:41 PM, Thiago Souza <tc...@gmail.com> wrote:
>
> Hi,
>
>    My current understanding is that components should be  considered as
> isolated from each other. And Camel context is just the way to organize and
> configure routes.
>
>    The problem is that camel context modularization support is not good
> enough. For example, in this case, by separating endpoints and routes in xml
> files I could use a different endpoint configuration set for test and
> production environment and still keeping the same routing xml.
>

See chapter 6 in the Camel in Action book which covers how to do this.
6.1.6 Unit testing in multiple environments



>    For this specific situation I guess I could use RouteContextRef or even
> Java DSL but that's not what I want. What I am really looking for is a way
> to make dynamic xml configuration contributions to existing camel context
> instances.
>
> Regards,
> Thiago Souza
>
> On Jul 27, 2010 3:02 AM, "Adrian Trenaman-2 [via Camel]" <
> ml-node+2255475-1717021524-15243@n5.nabble.com<ml...@n5.nabble.com>>
> wrote:
> In general, Camel contexts should be considered as isolated from each other
> (this is by design!). To communicate between Camel contexts, consider using
> the VM or JMS transports.
>
> Right now, what you're trying to do by separating the endpoints from the
> routes won't work - as you have found out! Is there a reason why you're
> separating the two?
>
> Cheers,
> Ade
>
> http://fusesource.com <http://fusesource.com?by-user=t>
>
> ----- Original Message -----
> From: Thiago Souza <[hidden
> email]<http://user/SendEmail.jtp?type=node&node=2255475&i=0>>
>
> To: [hidden email]
> <http://user/SendEmail.jtp?type=node&node=2255475&i=1> <[hidden
> email] <http://user/SendEmail.jtp?type=node&node=2255475&i=2>>
> Sent: Mon Jul 26 23:58:05 2010
> Subject: Visibility between camel contexts
>
>
> Hi,
>
>      In a standalone spring application context the following is perfectly
> fine:
>
>
>  <c:camelContext id="endpoints">
>                <c:endpoint id="source" uri="file://source" />
>                <c:endpoint id="target" uri="file://target" />
>        </c:camelContext>
>
>  <c:camelContext id="routes">
>                <c:route>
>                        <c:from ref="source" />
>                        <c:to ref="target" />
>                </c:route>
>        </c:camelContext>
>
>
>       That is, the configured camelContexts can see each other. Is it
> possible to achieve this in Karaf?  (i.e. "endpoints" goes in a xml and
> "routes" goes in another one)
>
>        I've tried with no success, the xml containing "routes" can not see
> the endpoints defined in "endpoints" (in another xml)
>
> Regards,
> Thiago Souza
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Visibility-between-camel-contexts-tp2255423p2255423.html<http://camel.465427.n5.nabble.com/Visibility-between-camel-contexts-tp2255423p2255423.html?by-user=t>
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
> ------------------------------
>  View message @
> http://camel.465427.n5.nabble.com/Visibility-between-camel-contexts-tp2255423p2255475.html
> To unsubscribe from Visibility between camel contexts, click
> here< (link removed) =>.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Visibility-between-camel-contexts-tp2255423p2255766.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: Visibility between camel contexts

Posted by Thiago Souza <tc...@gmail.com>.
Hi,

    My current understanding is that components should be  considered as
isolated from each other. And Camel context is just the way to organize and
configure routes.

    The problem is that camel context modularization support is not good
enough. For example, in this case, by separating endpoints and routes in xml
files I could use a different endpoint configuration set for test and
production environment and still keeping the same routing xml.

    For this specific situation I guess I could use RouteContextRef or even
Java DSL but that's not what I want. What I am really looking for is a way
to make dynamic xml configuration contributions to existing camel context
instances.

Regards,
Thiago Souza

On Jul 27, 2010 3:02 AM, "Adrian Trenaman-2 [via Camel]" <
ml-node+2255475-1717021524-15243@n5.nabble.com<ml...@n5.nabble.com>>
wrote:
In general, Camel contexts should be considered as isolated from each other
(this is by design!). To communicate between Camel contexts, consider using
the VM or JMS transports.

Right now, what you're trying to do by separating the endpoints from the
routes won't work - as you have found out! Is there a reason why you're
separating the two?

Cheers,
Ade

http://fusesource.com <http://fusesource.com?by-user=t>

----- Original Message -----
From: Thiago Souza <[hidden
email]<http://user/SendEmail.jtp?type=node&node=2255475&i=0>>

To: [hidden email]
<http://user/SendEmail.jtp?type=node&node=2255475&i=1> <[hidden
email] <http://user/SendEmail.jtp?type=node&node=2255475&i=2>>
Sent: Mon Jul 26 23:58:05 2010
Subject: Visibility between camel contexts


Hi,

      In a standalone spring application context the following is perfectly
fine:


  <c:camelContext id="endpoints">
                <c:endpoint id="source" uri="file://source" />
                <c:endpoint id="target" uri="file://target" />
        </c:camelContext>

  <c:camelContext id="routes">
                <c:route>
                        <c:from ref="source" />
                        <c:to ref="target" />
                </c:route>
        </c:camelContext>


       That is, the configured camelContexts can see each other. Is it
possible to achieve this in Karaf?  (i.e. "endpoints" goes in a xml and
"routes" goes in another one)

        I've tried with no success, the xml containing "routes" can not see
the endpoints defined in "endpoints" (in another xml)

Regards,
Thiago Souza

-- 
View this message in context:
http://camel.465427.n5.nabble.com/Visibility-between-camel-contexts-tp2255423p2255423.html<http://camel.465427.n5.nabble.com/Visibility-between-camel-contexts-tp2255423p2255423.html?by-user=t>
Sent from the Camel - Users mailing list archive at Nabble.com.


------------------------------
 View message @
http://camel.465427.n5.nabble.com/Visibility-between-camel-contexts-tp2255423p2255475.html
To unsubscribe from Visibility between camel contexts, click
here< (link removed) =>.

-- 
View this message in context: http://camel.465427.n5.nabble.com/Visibility-between-camel-contexts-tp2255423p2255766.html
Sent from the Camel - Users mailing list archive at Nabble.com.