Maybe the recipientList pattern is a solution for you in order to make your route dynamic.

Write the bean(s) you would like to call in the exchange header and that's it :)

Example:

MockEndpoint mockEndpoint = context.getEndpoint("mock:end", MockEndpoint.class);
assertNotNull(mockEndpoint);
mockEndpoint.expectedMessageCount(1);
context.addRoutes(new SpringRouteBuilder() { @Override
 public void configure() throws Exception {
from("direct:startTest")
    .recipientList(header("destinations"), ",");
}
});
// destinations is the header variable name context.createProducerTemplate().sendBodyAndHeader("direct:startTest", "testbody", "destinations", "bean:myBean?method=collect,bean:yourBean?method=collect,mock:end");
mockEndpoint.assertIsSatisfied(2000);

In this case it doesn't matter wheter the beans implements an interface or not. Just send the bean (and method if wished) you would like to call as a header variable. The beans must be registered in spring's application context in your case or referenced by osgi reference tag like your description before.

Hope this helps...

Sebastian



klausb schrieb:
Now I'm puzzled.

Did you say, that a bean is identified by its interface only?

How can I setup a route that uses different beans, where all beans implement
the same interface?

klaus.

Reply via email to