Announcement Announcement Module
Collapse
No announcement yet.
Unclear message set for MessageRejectedException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unclear message set for MessageRejectedException

    Hi folks,

    I'm using an
    Code:
    <int:filter throw-exception-on-rejection="true"><bean ... /></int:filter>
    to filter out messages. When the exception is thrown, the stack trace and Exception message make it very difficult to tell which MessageFilter it was that rejected the message. As you will see below, when using the filter component the componentName is not set. Apparently the fallback is beanName, but that is not set either.

    I'm not sure what the most elegant solution would be.

    Code:
    org.springframework.integration.MessageRejectedException: MessageFilter 'null' rejected Message
    	at org.springframework.integration.filter.MessageFilter.handleRequestMessage(MessageFilter.java:110) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:134) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.handler.MessageHandlerChain.handleMessageInternal(MessageHandlerChain.java:137) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:115) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:102) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:149) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendMessage(AbstractReplyProducingMessageHandler.java:216) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendReplyMessage(AbstractReplyProducingMessageHandler.java:200) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.produceReply(AbstractReplyProducingMessageHandler.java:165) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleResult(AbstractReplyProducingMessageHandler.java:159) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:141) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:115) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:102) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:149) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.core.MessagingTemplate.convertAndSend(MessagingTemplate.java:189) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.gateway.MessagingGatewaySupport.send(MessagingGatewaySupport.java:183) ~[spring-integration-core-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.jms.ChannelPublishingJmsMessageListener$GatewayDelegate.send(ChannelPublishingJmsMessageListener.java:423) ~[spring-integration-jms-2.2.0.RELEASE.jar:na]
    	at org.springframework.integration.jms.ChannelPublishingJmsMessageListener.onMessage(ChannelPublishingJmsMessageListener.java:277) ~[spring-integration-jms-2.2.0.RELEASE.jar:na]
    	at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:537) ~[spring-jms-3.1.3.RELEASE.jar:3.1.3.RELEASE]
    	at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:497) ~[spring-jms-3.1.3.RELEASE.jar:3.1.3.RELEASE]
    	at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:468) ~[spring-jms-3.1.3.RELEASE.jar:3.1.3.RELEASE]
    	at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:326) [spring-jms-3.1.3.RELEASE.jar:3.1.3.RELEASE]
    	at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:244) [spring-jms-3.1.3.RELEASE.jar:3.1.3.RELEASE]
    	at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1071) [spring-jms-3.1.3.RELEASE.jar:3.1.3.RELEASE]
    	at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1063) [spring-jms-3.1.3.RELEASE.jar:3.1.3.RELEASE]
    	at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:960) [spring-jms-3.1.3.RELEASE.jar:3.1.3.RELEASE]
    	at java.lang.Thread.run(Thread.java:662) [na:1.6.0_26]

  • #2
    You can provide the "id" attribute on the filter element.

    HTH,
    Mark

    Comment


    • #3
      Of course, sorry!

      Comment


      • #4
        Actually, this isn't supported in 2.2.0.RELEASE and the schema validation throws an error on startup.

        Comment


        • #5
          I just ran a test and it works fine for me...

          Code:
          <filter input-channel="input" id="foo" throw-exception-on-rejection="true"
          		ref="testBean"
          		method="acceptStringWithMoreThanThreeChars"
          		output-channel="output"/>
          
          
          
          
          public class TestBean {
          
          	public boolean acceptStringWithMoreThanThreeChars(String s) {
          		return false;
          	}
          
          }
          
          
          
          
          
          org.springframework.integration.MessageRejectedException: MessageFilter 'foo' rejected Message
          	at org.springframework.integration.filter.MessageFilter.handleRequestMessage(MessageFilter.java:110)
          	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:134)
          	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
          	at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:115)
          	at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:102)
          	at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
          	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
          	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128)
          	at org.springframework.integration.filter.FilterContextTests.methodInvokingFilterRejects(FilterContextTests.java:42)
          	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          	at java.lang.reflect.Method.invoke(Method.java:597)
          	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
          	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
          	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
          	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
          	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
          	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
          	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
          	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
          	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
          	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
          	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
          	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
          	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
          	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
          	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
          	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
          	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
          	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
          	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

          Comment


          • #6
            Note: the "id" goes on the <filter/> not the <bean/>.

            Comment


            • #7
              Tried both, does it work for you when the filter is a child of a chain?
              Last edited by nickspacek; Jan 16th, 2013, 02:11 PM.

              Comment


              • #8
                Yup....

                Code:
                	<int:filter input-channel="input" id="foo" throw-exception-on-rejection="true"
                			method="acceptStringWithMoreThanThreeChars"
                			output-channel="output">
                		<bean class="org.springframework.integration.filter.TestBean"/>
                	</int:filter>
                
                
                org.springframework.integration.MessageRejectedException: MessageFilter 'foo' rejected Message
                	at org.springframework.integration.filter.MessageFilter.handleRequestMessage(MessageFilter.java:110)
                	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:134)
                	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
                	at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:115)
                	at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:102)
                	at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
                	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
                	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128)
                	at org.springframework.integration.filter.FilterContextTests.methodInvokingFilterRejects(FilterContextTests.java:42)
                	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                	at java.lang.reflect.Method.invoke(Method.java:597)
                	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
                	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
                	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
                	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
                	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
                	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
                	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
                	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
                	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
                	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
                	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
                	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
                	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
                	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
                	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
                	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
                	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
                	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
                	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

                Can you show your current config and the stack trace from the parse error?

                Comment


                • #9
                  @nickspacek pointed out to me that he meant <filter/> within a <chain/> and, no, an id is not allowed in that case. (Chains are black boxes after all).

                  However, if you give the <chain/> an id, the filter can be implied...

                  Code:
                  org.springframework.integration.MessageRejectedException: MessageFilter 'fooChain.handler#0' rejected Message
                  	at org.springframework.integration.filter.MessageFilter.handleRequestMessage(MessageFilter.java:110)
                  	at ...
                  where ...handler#0 is the first element in the chain, ..#1 the second, etc, etc.

                  Hope that helps.

                  Comment


                  • #10
                    Oh, and as a general note, we generally recommend giving all (top level) elements ids - it makes it much easier to identify components using JMX (VisualVM, JConsole) as well as in Spring Insight.

                    Comment


                    • #11
                      Originally posted by Gary Russell View Post
                      ...no, an id is not allowed in that case. (Chains are black boxes after all).
                      Sorry it took so long for me to articulate the issue!

                      Hmm, so in terms of exception logging the chain ID solution is the best that can be currently done it seems. It's helpful, but doesn't seem ideal to me. Though it might be very low priority, is there any hope for enhancing the exception message?

                      Would it be appropriate for the filter bean to throw its own exception rather than relying on the throw-exception-on-rejection attribute?

                      On second thought, I guess the current message is probably fine.

                      Comment


                      • #12
                        The problem is that the beans within a chain are not first class beans (from the application context perspective); even if we gave them ids, the beanName would not be automatically populated; we'd have to add code. We added the ...handler#n stuff to provide some context in a Spring Insight trace and so getting it in the exception in this context was "free". In fact, even if we populated the id, currently, the chain would overwrite it with this value.

                        Given that there's a reasonable (albeit not perfect) solution, you are right, it would likely not get high priority but feel free to open a JIRA if you feel strongly.

                        Yes, the filter could throw its own exception, but it will be wrapped (become the cause of) a MessageHandlingException.

                        Comment

                        Working...
                        X