I know this question is quite old, but now I am facing the same problem in 2015, and this thread does not offer me a solution.
I came up with a special bean processor with CountDownLatch, which I calculate after loading the application. Thus, the messages will be idle until the application starts working fully and works for me.
@Log4j class BootstrapLatchProcessor implements Processor { private final CountDownLatch latch = new CountDownLatch(1) @Override void process(Exchange exchange) throws Exception { if(latch.count > 0){ log.info "waiting for bootstrapped @ ${exchange.fromEndpoint}" latch.await() } exchange.out = exchange.in } public void setBootstrapped(){ latch.countDown() } }
Then use it as a bean in your application and call the setBootstrapped method in your Bootstrap.groovy
Then, in your RouteBuilder, you place the processor between your endpoint and the destination for all routes that you expect messages to be before the application starts:
from("activemq:a.in ").processRef('bootstrapProcessor').to("bean:handlerService?method=handle")
codewandler
source share