As Claus responded you may already use properties as you proposed.
Still I think it may be a good idea to use a direct endpoint instead and
keep the activemq config in a routebuilder.
This allows you to better seperate your business logic from the camel stuff.
Like:
@Consumer("direct:somename")
public void onWhatever(String whatever) {
...
}
public class MyRouteBuilder extends RouteBuilder {
public void configure() {
from("activmeq:queue:${queueName}?concurrentConsumers=${concurrentConsumers}")
.to("direct:somename");
}
}
What I also saw is something like:
@Consumer("${myEndpoint}")
public void onWhatever(String whatever) {
...
}
This way you can move the endpoint config to the property file. This
allows you to for example use different endpoints for test and prod. So
you my consume from a file or direct endpoint in test and only use the
queue in production.
Best regards
Christian
Am 08.01.2011 10:59, schrieb Dan Checkoway:
I'm generally a huge fan of annotation-driven stuff. Here's one example
where my hands are tied, and I can't use annotations to do what I want to
do. Let's say I have this:
@Consume(uri="activmeq:queue:whatever?concurrentConsumers=10")
public void onWhatever(String whatever) {
...
}
Now let's say I want the queue name ("stuff") and the # of
concurrentConsumers to be configurable via a properties file. Up until now,
I've resorted to setting up the route manually with stuff like:
public class MyRouteBuilder extends RouteBuilder {
@Value("${queueName}")
String queueName;
@Value("${concurrentConsumers}")
int concurrentConsumers;
public void configure() {
from("activemq:queue:" + queueName + "?concurrentConsumers=" +
concurrentConsumers)
.to(myWhateverBean, "onWhatever");
}
}
Can anybody suggest an alternative way of using "dynamic" URIs with
annotation-based POJOs? I would love, for example, to be able to do
something like this:
@Consume(uri="activmeq:queue:${queueName}?concurrentConsumers=${concurrentConsumers}")
public void onWhatever(String whatever) {
...
}
Is this possible already and I just managed to miss it? :-) If not, is
something like that in the works?
Thanks,
Dan
--
----
http://www.liquid-reality.de