Hi,

I want to implement a custom AsyncProcessor so I can have more control on a
custom Netty channel. Is the following pattern recommended?

@Override
        public boolean process(Exchange exchange, AsyncCallback callback) {
                try {
                        //Do whatever sync preparations and async invocations, 
set the exchange
result and signal back

                        // continue routing asynchronously
                        return false;

                } catch (Exception e) {
                        //If an excepction was thrown synchronously, handle it 
here, do not throw
it
                        exchange.setException(e);
                        callback.done(true);
                        return true;
                }
        }

CamelInternalProcessor has this code:

            // ----------------------------------------------------------
            // CAMEL END USER - DEBUG ME HERE +++ START +++
            // ----------------------------------------------------------
            try {
                processor.process(exchange);
            } catch (Throwable e) {
                exchange.setException(e);
            }
            // ----------------------------------------------------------
            // CAMEL END USER - DEBUG ME HERE +++ END +++
            // ----------------------------------------------------------

            // ----------------------------------------------------------
            // CAMEL END USER - DEBUG ME HERE +++ START +++
            // ----------------------------------------------------------
            if (LOG.isTraceEnabled()) {
                LOG.trace("Processing exchange for exchangeId: {} -> {}",
exchange.getExchangeId(), exchange);
            }
            boolean sync = processor.process(exchange, async);
            // ----------------------------------------------------------
            // CAMEL END USER - DEBUG ME HERE +++ END +++
            // ----------------------------------------------------------

In the synchronous version, it uses a try catch. Why does this
implementation not use a try-catch in the asynchronous version?

Thanks!

By the way, I've been posting a lot these days, thanks for your help! I
really appreciate it. I'm having a hard time to use Eclipse on Camel source
code projects. As soon as I could get over it, I would like to contribute.
Thanks!



--
View this message in context: 
http://camel.465427.n5.nabble.com/AsyncProcessor-implementation-patterns-tp5739773.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to