camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpbarto <>
Subject Re: Camel Integration Advice Needed
Date Mon, 24 Jun 2013 12:56:11 GMT
Final Solution:

I think I've found the solution I was looking for in the form of the XML
'routes' tag as mentioned previously.  

In addition to the traditional camel-context.xml I've also created two
additional XML files (subscribe-template.xml and publish-template.xml).  An
example follows:

<?xml version="1.0" encoding="UTF-8"?>
<routes xmlns="">
    <route id="foo-$topic">
        <from uri="rabbitmq://cml.topic:$topic"/>
        <to uri="foo://$topic"/>

In Java code, when I want to bind one component create a subscription I
would execute the following:

    public void subscribe(final String topic) throws Exception {
        if (! subscribedConsumerRoutes.containsKey(topic)) {
            List<Route> routes = new ArrayList<Route>();

            InputStream istream =
            String template = IOUtils.toString(istream,
"UTF-8").replace("$topic", topic);
            istream = IOUtils.toInputStream(template, "UTF-8");
            RoutesDefinition routesDef =

            for (RouteDefinition route : routesDef.getRoutes()) {
            subscribedConsumerRoutes.put(topic, routes);

The question now becomes how to modify an existing route to add new
'consumers' to the route.  For example if a route looks like:

<from uri="rabbitmq://cml.topic:a.b.c"/>
  <to uri="mock:a"/>
  <to uri="mock:b"/>

How does one modify it to:
<from uri="rabbitmq://cml.topic:a.b.c"/>
  <to uri="mock:a"/>
  <to uri="mock:b"/>
  <to uri="mock:c"/>

I can't find a way to get a reference to a route's multicast service so how
to best do this... perhaps with a DynamicRouter?

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message