I have tried and completely failed to use the camel spring container.
I see where it can do two things:
1) create a context which instantiates RouteBuilders in a given package:
<bean id="camel" class="org.apache.camel.spring.CamelContextFactoryBean">
<property name="packages" value="org.apache.camel.spring.example"/>
</bean>
I can't even guess what the need for that is, unless it's just a shortcut
for declaring those RouteBuilders in the xml.
2) create RouteBuilders in xml:
<routeBuilder id="buildSimpleRoute"
xmlns="http://activemq.apache.org/camel/schema/camel-1.0.xsd">
<route>
<from uri="queue:a"/>
<to uri="queue:b"/>
</route>
</routeBuilder>
That seems more useful, since I can get the routes and add them to a
CamelContext, like this:
container = new DefaultCamelContext();
//or: container = SpringCamelContext.springCamelContext(ctx);
Map<String, RouteBuilder> map = ctx.getBeansOfType(RouteBuilder.class);
Iterator<RouteBuilder> iter = map.values().iterator();
List<Route> routes = new ArrayList<Route>();
while(iter.hasNext()) {
RouteBuilder builder = iter.next();
try {
routes.addAll(builder.getRouteList());
} catch (Exception e) {
log.error(e);
}
}
container.addRoutes(routes);
container.start();
The problem is, the routes don't work.
I f I pass a message in, it doesn't go anywhere:
Endpoint<Exchange> endpoint = container.getEndpoint("queue:a");
Exchange exchange = endpoint.createExchange();
Message m = exchange.getIn();
m.setBody("testing");
Producer<Exchange> producer = endpoint.createProducer();
producer.process(exchange);
So something is missing, probably in my understanding of how the
camel-spring component is supposed to work.
--
View this message in context:
http://www.nabble.com/-camel--using-camel-spring-container-tf3663875s2354.html#a10237598
Sent from the ActiveMQ - User mailing list archive at Nabble.com.