Hi,

I resolved my problem by static synchronised inner class in producer:

public class MyProducer extends DefaultProducer {

    private static final Logger LOGGER =
LoggerFactory.getLogger(MyProducer.class);

    public void process(Exchange exchange) throws Exception {
        // Test synchronized static method 
        Safe.doSafe(exchange);
    }

        @Override
    public boolean isSingleton() {
        return super.isSingleton();
    }

    private static class Safe {
        public static synchronized void doSafe(Exchange exchange){
            for (int i = 0; i < 10; i++) {
                LOGGER.info(exchange.getIn().getBody() + " :: " + i);
                try {
                    Thread.sleep(500);
                } catch (Exception e) {
                    LOGGER.info(e.getMessage());
                }
            }
        }
    }
}



--
View this message in context: 
http://camel.465427.n5.nabble.com/Component-singleton-for-all-routes-tp5755446p5755484.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to