Hi,
If I want to consumer from a queue using PollingConsumerTemplate and
move the messages to another queue, can I wrap this in a transaction
given that there is no actual camel route?
I'm using pollingConsumerTemplate as I want to control when/if I
consume, but maybe there is an alternative way.
Code looks a little like this so far..
int max = 10;
while (true) {
log.info("consuming..");
int inprogressQty =
inprogressEndpoint.getExchanges().size();
if (inprogressQty < max) {
log.info("There are {} items inprogress",
inprogressQty);
Exchange exchange = consumer.receive(1000);
if (exchange != null) {
Object o = exchange.getIn().getBody();
log.info("Got message: {}", o);
producerTemplate.send(inprogressEndpoint, exchange);
} else {
log.info("No message");
}
} else {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace(); //To change body of
catch statement use File | Settings | File Templates.
}
}
}
Thanks, Tom