I tried to use AsyncProcessor in test scenario, expecting only one message to run through route, but seems like there are two of them.
in log
Test0
Test1
Why there are two messages?
from("quartz:test?trigger.repeatCount=1&trigger.repeatInterval=100").setBody(simple("Test"))
.process(new AsyncProcessor() {
private volatile int i;
public void process(Exchange exchange) throws Exception {
AsyncProcessorHelper.process(this, exchange);
}
public boolean process(final Exchange exchange, final AsyncCallback callback) {
new Thread(new Runnable() {
public void run() {
exchange.getOut().setBody(exchange.getIn().getBody(String.class) + (i++), String.class);
callback.done(false);
}
}).start();
return false;
}
})
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
org.slf4j.LoggerFactory.getLogger(Tests.class).info(exchange.getIn().getBody(String.class));
}
});
if you only want it to run once, then set
trigger.repeatCount=0