On Wed, Nov 30, 2011 at 5:06 PM, Tom Howe <[email protected]> wrote:
> 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.
>

You would need to wrap the code in a transaction yourself. And control
the begin / commit.




> 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



-- 
Claus Ibsen
-----------------
FuseSource
Email: [email protected]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to