camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: LoggingErrorHandler doesn't take effect when producer creation failed
Date Sun, 15 Aug 2010 07:07:23 GMT
Hi

The Camel error handler is for message when they fails.

The mina component will fail on startup if it can't get a connection
to that remote site.

You can set lazySessionCreation=true to let it only connect on demand.
Then it will fail when a message is being send to it, and the logging
error handler should take action.


On Sat, Aug 14, 2010 at 8:13 PM, yedingding <yedingding@gmail.com> wrote:
>
> Hey.
>
> I'm using java 1.6, camel 2.4 and activemq 5.3.2. I meet a problem with
> loggingErrorHandler. I thought it will handler all the exceptions but now it
> fails when I tried to start the context and then it quit.
>
> The codes are:
>
>   context.addRoutes(new RouteBuilder() {
>      public void configure() {
>        errorHandler(loggingErrorHandler("IM Queue"));
>
>        from("active-mq:queue:im_queue")
>            .process(new Processor() {
>              public void process(Exchange exchange) throws Exception {
>                System.out.println("RECV: "
>                          + exchange.getIn().getBody(String.class));
>              }
>
> }).to("mina://tcp://127.0.0.1:5679?lazySessionCreation=false&sync=false&textline=true");
>      }
>    });
>
> So when 5679 port is not open, it raises the exception below and then
> terminated.
>
> Exception in thread "main" org.apache.camel.FailedToCreateProducerException:
> Failed to create Producer for endpoint:
> Endpoint[mina://tcp://127.0.0.1:5679?lazySessionCreation=false&sync=false&textline=true].
> Reason: org.apache.mina.common.RuntimeIOException: Failed to get the
> session.
>        at
> org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:362)
>        at
> org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:93)
>        at
> org.apache.camel.impl.ProducerCache.startProducer(ProducerCache.java:124)
>        at org.apache.camel.processor.SendProcessor.doStart(SendProcessor.java:144)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
>        at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:53)
>        at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:64)
>        at
> org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:77)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
>        at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:53)
>        at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:64)
>        at
> org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:77)
>        at
> org.apache.camel.processor.interceptor.TraceInterceptor.doStart(TraceInterceptor.java:423)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
>        at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:53)
>        at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:64)
>        at
> org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:77)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
>        at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:53)
>        at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:64)
>        at
> org.apache.camel.processor.DefaultChannel.doStart(DefaultChannel.java:143)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
>        at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:53)
>        at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:64)
>        at org.apache.camel.processor.TryProcessor.doStart(TryProcessor.java:172)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
>        at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:53)
>        at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:64)
>        at
> org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:77)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
>        at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:53)
>        at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:64)
>        at
> org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:77)
>        at
> org.apache.camel.processor.interceptor.TraceInterceptor.doStart(TraceInterceptor.java:423)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
>        at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:53)
>        at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:64)
>        at
> org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:77)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
>        at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:53)
>        at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:64)
>        at
> org.apache.camel.processor.DefaultChannel.doStart(DefaultChannel.java:143)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
>        at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:78)
>        at
> org.apache.camel.processor.MulticastProcessor.doStart(MulticastProcessor.java:571)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
>        at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:53)
>        at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:64)
>        at
> org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:77)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
>        at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:53)
>        at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:64)
>        at
> org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:77)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
>        at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:53)
>        at
> org.apache.camel.impl.RouteService.startChildService(RouteService.java:221)
>        at org.apache.camel.impl.RouteService.doStart(RouteService.java:150)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
>        at
> org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:1328)
>        at
> org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:1256)
>        at
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:952)
> Caused by: org.apache.mina.common.RuntimeIOException: Failed to get the
> session.
>        at
> org.apache.mina.common.support.DefaultConnectFuture.getSession(DefaultConnectFuture.java:63)
>        at
> org.apache.camel.component.mina.MinaProducer.openConnection(MinaProducer.java:207)
>        at
> org.apache.camel.component.mina.MinaProducer.doStart(MinaProducer.java:168)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
>        at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:53)
>        at
> org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:360)
>        ... 62 more
> Caused by: java.net.ConnectException: Connection refused
>        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
>        at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:574)
>        at
> org.apache.mina.transport.socket.nio.SocketConnector.processSessions(SocketConnector.java:293)
>        at
> org.apache.mina.transport.socket.nio.SocketConnector.access$800(SocketConnector.java:53)
>        at
> org.apache.mina.transport.socket.nio.SocketConnector$Worker.run(SocketConnector.java:383)
>        at
> org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>        at java.lang.Thread.run(Thread.java:637)
>
>
> Thanks for the help.
> --
> View this message in context: http://camel.465427.n5.nabble.com/LoggingErrorHandler-doesn-t-take-effect-when-producer-creation-failed-tp2635377p2635377.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message