Hello
I'm not sure if this is by design or me having a understanding problem. When I setup a transformer listening to messages from a publish-subscribe-channel, aren't exceptions supposed to be propagated to the "errorChannel" as described in the reference manual?
Currently that doesn't seem to be the case.
I'm getting the following stack trace when I throw a exception deliberately in my transformer:
Code:Exception in thread "main" org.springframework.integration.transformer.MessageTransformationException: org.springframework.integration.MessageHandlingException: java.lang.NullPointerException: test at org.springframework.integration.transformer.MessageTransformingHandler.handleRequestMessage(MessageTransformingHandler.java:71) at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:102) at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:77) at org.springframework.integration.dispatcher.BroadcastingDispatcher.invokeHandler(BroadcastingDispatcher.java:121) at org.springframework.integration.dispatcher.BroadcastingDispatcher.dispatch(BroadcastingDispatcher.java:112) at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:44) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157) at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128) at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:374) at org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:219) at org.springframework.integration.aop.MessagePublishingInterceptor.publishMessage(MessagePublishingInterceptor.java:147) at org.springframework.integration.aop.MessagePublishingInterceptor.invoke(MessagePublishingInterceptor.java:116) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621) at com.komdat.adwords.springframework.ReportingServiceFacade$$EnhancerByCGLIB$$cc1b41da.requestAndPublishReport(<generated>) at example.GetReport.getKeywordReport(GetKeywordReport.java:67) at example.GetReport.main(GetKeywordReport.java:46) Caused by: org.springframework.integration.MessageHandlingException: java.lang.NullPointerException: test at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:76) at org.springframework.integration.transformer.AbstractMessageProcessingTransformer.transform(AbstractMessageProcessingTransformer.java:56) at org.springframework.integration.transformer.MessageTransformingHandler.handleRequestMessage(MessageTransformingHandler.java:65) ... 16 more
Currently the only solution I could come up with was to programatically create a error message and send it directly to the error channel. However, as the transformer is required to return a value I still need to throw the exception to stop message propagation which causes the stack trace shown above.
Code:@Autowired @Qualifier("errorChannel") private PublishSubscribeChannel errorChannel; public String transform(Report report) { ... Exception e = new Exception("test"); errorChannel.send(new ErrorMessage(e)); throw e; }


Reply With Quote