[ 
https://issues.apache.org/jira/browse/CAMEL-3563?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12984710#action_12984710
 ] 

james strachan commented on CAMEL-3563:
---------------------------------------

@Hadrian

Right now any bean in the Spring context which is convertable to a Component or 
Endpoint can be used directly in Camel, making a new URI scheme on the fly. 
This has been there for 3 years and is a great feature.  This is how you can do 
things like:

{code}
<bean id="mqSeries" class="org.apache.camel.jms.JmsComponent">
...

<bean id="tibco" class="org.apache.camel.jms.JmsComponent">
...
{code}

So you can take a generic component (JMS) and make specific configured 
instances; which then act like a separate URI scheme.

Then in code you can refer to **mqSeries:SomeQueue** and **tibco:AnotherQueue**

Are you proposing we go back in time 3 years and avoid doing such a thing 
because you could possibly hide one of the standard URI schemes? Hiding URI 
schemes is another great feature - it lets you stub out middleware in test 
cases with mock endpoints by just adding beans to your context but reusing a 
route definition as is.


So for this specific issue,  I'm proposing we add a CamelContextComponent which 
takes a CamelContext in the constructor which just exposes its endpoints. Then 
any endpoint can be prefixed by the ID of the camelContext in which its defined 
and hey presto - in a nice neat URI naming scheme - we get an easy way to route 
between CamelContext instances.

I'm not suggesting making any changes to how Camel URIs work (they've been 
great for years).


If you really want an explicit URI prefix to make URIs extra long and verbose, 
we could also add a "camelContext:" URI scheme which just takes the next name 
on the path and looks up the CamelContext in the Spring context and then uses 
the same CamelContextComponent I mention above.

In this case both: "camelContext:foo:direct:bar" and "foo:direct:bar" would 
work.

Though the genie was let out of the bottle 3 years ago with respect to being 
able to hide the default URI scheme implementations. Overriding the mapping of 
URI scheme name to an implementation is actually a good thing

> CamelContext should act like a Component (i.e. a TypeConverter of 
> CamelContext -> CamelContextComponent)
> --------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-3563
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3563
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: james strachan
>             Fix For: 2.6.0
>
>
> Imagine you have a camelContext.xml for production use (e.g. you're creating 
> an OSGi bundle with a camelContext.xml) but you want to create an integration 
> test case that tests out your route.
> So you want to create a new Camel XML file, testCamel.xml which includes the 
> camelContext.xml and interacts with it. You now have 2 camelContexts. The 
> test route needs to be able to refer to any endpoints inside the other 
> camelContext.xml.
> CamelContext has an ID (by default camelContext IIRC).
> so if we have 
> camelContext.xml
> {code}
> <camelContext id="prod" ...>
>   <route> 
>     <from uri="direct:foo">
>      ...
> {code}
> testCamelContext.xml
> {code}
> <camelContext id="test" ...>
>   <route> 
>     <from uri="direct:start">
>     <to uri="prod:direct:foo"/>
>    </route>
>   <route> 
>     <from uri="prod:seda:bar">
>     <to uri="mock:results"/>
>    </route>
> {code}
> i.e. in the test case we are routing from our local CamelContext into the 
> production camel context's "direct:start" endpoint and consuming from its 
> "seda:bar" endpoint.
> i.e. we use "prod" as a name, look it up in the IoC context (just like any 
> other Component), but if its a CamelContext we (via TypeConverters) turn it 
> into a Component that resolves the rest of the name

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to