Announcement Announcement Module
Collapse
No announcement yet.
MessagingGatewaySupport logging on Exception Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MessagingGatewaySupport logging on Exception

    I have written a REST Provider service using Spring Integration,

    - I am utilizing exception-type-router along with http-inbound-gateway to set return HTTP Status Code
    (e.g) an EntityNotFound Exception is mapped to return 404, IllegalArgument is mapped to return 400 etc.

    Everything is working fine except that, when the incoming message is processed by Service Activator, the MessagingGatewaySupport.doSendAndRecieve method which catches the exception while evaluating an expression logs the whole stack, this raises false alarms while scanning through the log files.

    for a give configuration like this:

    Code:
    <int:service-activator id="customerByEmailForHeadActivator"
    		input-channel="incomingCustomerByEmailforHead"  
    		expression="@customerManagementGateway.isCustomerAvailableByEmailId(payload) == true ? '' : ''"
    		output-channel="outgoing" requires-reply="true" />
    Although I will be handling the exception thrown using a exception-type-router, the Exception is logged in the following code:

    MessagingGatewaySupport.java [lines : 222 - 242]

    Code:
    try {
    			if (shouldConvert) {
    				reply = this.messagingTemplate.convertSendAndReceive(this.requestChannel, object, this.historyWritingPostProcessor);
    				if (reply instanceof Throwable) {
    					error = (Throwable) reply;
    				}
    			}
    			else {
    				Message<?> requestMessage = (object instanceof Message<?>)
    						? (Message<?>) object : this.requestMapper.toMessage(object);
    				requestMessage = this.historyWritingPostProcessor.postProcessMessage(requestMessage);
    				reply = this.messagingTemplate.sendAndReceive(this.requestChannel, requestMessage);
    				if (reply instanceof ErrorMessage) {
    					error = ((ErrorMessage) reply).getPayload();
    				}
    			}
    		}
    		catch (Exception e) {
    			logger.warn("failure occurred in gateway sendAndReceive", e);
    			error = e;
    		}
    Is it really necessary to log this exception along with whole stack trace at warn level ?

    I understand that not all systems would handle exceptions the way I handled, but since there is an default exception channel already in place,I think it would be better to log the exception through an interceptor there than at the MessagingGatewaySupport.

    please validate my understanding and opinion, so that I can think about raising a JIRA for this.

  • #2
    Hi Mark/Vasanth,

    I am also facing the same issue while using the gateway interacting with MDB.
    In my application I wanted to log the error message using error channel. But I am getting below error with stack trace in my console . My logger and error channel is getting execued properly, but only issue is the stack trace, which is coming with below warning set in MessagingGatewaySupport class.
    Below is the message
    Code:
    GatewayProxyF W org.springframework.integration.gateway.MessagingGatewaySupport doSendAndReceive failure occurred in gateway sendAndReceive org.springframework.integration.MessageHandlingException: com.hsbc.mpfbpm.integration.util.MPFBPMException:
    at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:76)
    	at org.springframework.integration.handler.ServiceActivatingHandler.handleRequestMessage(ServiceActivatingHandler.java:64)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:98)
    	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
    	at org.springframework.integration.handler.MessageHandlerChain$1.send(MessageHandlerChain.java:154)
    	at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
    	at org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:149)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendMessage(AbstractReplyProducingMessageHandler.java:176)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendReplyMessage(AbstractReplyProducingMessageHandler.java:160)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.produceReply(AbstractReplyProducingMessageHandler.java:125)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleResult(AbstractReplyProducingMessageHandler.java:119)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:101)
    	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
    	at org.springframework.integration.handler.MessageHandlerChain.handleMessageInternal(MessageHandlerChain.java:137)
    	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:110)
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97)
    	at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:61)
    	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:288)
    	at org.springframework.integration.core.MessagingTemplate.doSendAndReceive(MessagingTemplate.java:318)
    	at org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:239)
    	at org.springframework.integration.core.MessagingTemplate.convertSendAndReceive(MessagingTemplate.java:274)
    	at org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:224)
    	at org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceive(MessagingGatewaySupport.java:203)
    	at org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(GatewayProxyFactoryBean.java:300)
    	at org.springframework.integration.gateway.GatewayProxyFactoryBean.doInvoke(GatewayProxyFactoryBean.java:269)
    	at org.springframework.integration.gateway.GatewayProxyFactoryBean.invoke(GatewayProxyFactoryBean.java:260)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    	at $Proxy28.createBPMWorkItem(Unknown Source)
    	at com.hsbc.mpfbpm.integration.jms.listener.MPFMDBListener$1.doInJms(MPFMDBListener.java:142)
    	at com.hsbc.esf.jms.templates.MessengerSessionCallback.doInJms(MessengerSessionCallback.java:43)
    	at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:466)
    	at com.hsbc.esf.jms.templates.ESJmsTemplate.execute(ESJmsTemplate.java:49)
    	at com.hsbc.mpfbpm.integration.jms.listener.MPFMDBListener.processMessage(MPFMDBListener.java:109)
    	at com.hsbc.esf.jms.async.templates.EsMessageListener.onMessage(EsMessageListener.java:96)
    	at com.hsbc.esf.jms.async.impl.EsMessageDrivenBean.onMessage(EsMessageDrivenBean.java:107)
    	at com.ibm.ejs.jms.listener.MDBWrapper$PriviledgedOnMessage.run(MDBWrapper.java:302)
    	at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:63)
    	at com.ibm.ejs.jms.listener.MDBWrapper.callOnMessage(MDBWrapper.java:271)
    	at com.ibm.ejs.jms.listener.MDBWrapper.onMessage(MDBWrapper.java:240)
    	at com.ibm.mq.jms.MQSession$FacadeMessageListener.onMessage(MQSession.java:147)
    	at com.ibm.msg.client.jms.internal.JmsSessionImpl.run(JmsSessionImpl.java:2557)
    	at com.ibm.mq.jms.MQSession.run(MQSession.java:860)
    	at com.ibm.ejs.jms.JMSSessionHandle.run(JMSSessionHandle.java:975)
    	at com.ibm.ejs.jms.listener.ServerSession.connectionConsumerOnMessage(ServerSession.java:900)
    	at com.ibm.ejs.jms.listener.ServerSession.onMessage(ServerSession.java:665)
    	at com.ibm.ejs.jms.listener.ServerSession.dispatch(ServerSession.java:632)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    	at java.lang.reflect.Method.invoke(Method.java:599)
    	at com.ibm.ejs.jms.listener.ServerSessionDispatcher.dispatch(ServerSessionDispatcher.java:37)
    	at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:96)
    	at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:132)
    	at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:496)
    	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)
    Caused by: com.hsbc.mpfbpm.integration.util.MPFBPMException: INVALID_MESSAGE	at com.hsbc.mpfbpm.integration.transformer.RequestFL2POJO.process(RequestFL2POJO.java:280)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    	at java.lang.reflect.Method.invoke(Method.java:599)
    	at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:69)
    	at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:83)
    	at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)
    	at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
    	at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:102)
    	at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:126)
    ... 58 more
    My code is as below :
    Code:
    	<int:channel id="errorChannel"/>
    
    
    	<int:gateway id="workItemService"
    		service-interface="com.hsbc.mpfbpm.integration.service.WorkItemService"
    		default-request-channel="mpfBpmNotificationChannel"
    		default-reply-channel="jmsOutChannel" error-channel="errorChannel">
    		<int:method name="createBPMWorkItem" request-channel="mpfBpmNotificationChannel"
    			reply-channel="jmsOutChannel" >
    		</int:method>
    	</int:gateway>
    	
    	
    	<int:chain id="chain" input-channel="mpfBpmNotificationChannel"
    		output-channel="wsInChannel">
    
    		<int:service-activator method="receiveMessage"
    			ref="ismMessageCreator">
    		</int:service-activator>
    
    		<int:service-activator method="process">
    			<bean class="com.hsbc.mpfbpm.integration.transformer.RequestFL2POJO">
    				<property name="mappingLocation" value="classpath:payloadMapping.xml" />
    			</bean>
    		</int:service-activator>
    
    		<int:header-enricher>
    			<int:header name="springintegration_ws_soapAction" value="${MPF.BPM.WSDL.URL.SoapAction}" />
    		</int:header-enricher>
    		<ws:outbound-gateway uri="${MPF.BPM.WSDL.URI}"
    			marshaller="processWorkItemCastorMarshaller" unmarshaller="processWorkItemCastorMarshaller">
    		</ws:outbound-gateway>
    		
    	</int:chain>
    	
    
    	<int:chain input-channel="wsInChannel" output-channel="jmsOutChannel">
    		<int:service-activator method="process">
    			<bean class="com.hsbc.mpfbpm.integration.transformer.ResultPOJO2FL">
    			</bean>
    		</int:service-activator>
    
    		<int:service-activator method="createMessage"
    			ref="ismMessageCreator">
    		</int:service-activator>
    	</int:chain>
    
    
    	<bean id="processWorkItemCastorMarshaller" class="org.springframework.oxm.castor.CastorMarshaller">
    		<property name="mappingLocation"
    			value="classpath:mpf-bpm-wsdl-Mapping.xml" />
    		<property name="suppressNamespaces" value="true" />
    		
    	</bean>
    	
    	<int:service-activator input-channel="errorChannel"
    		output-channel="wsInChannel" method="process" ref="errorHandler">
    	</int:service-activator>
    	
    	<bean id= "errorHandler" class = "com.hsbc.mpfbpm.integration.transformer.ErrorHandler">
    		<property name="msgCodeMapper" ref="msgCodeMapper" />
    	</bean>
    Please advise .

    Comment


    • #3
      Hi Prabhabati,

      I think the problem is valid enough, now I know that since at least somebody other than me is also facing the same issue. I will wait for another day to check if Mark/Oleg replies, else I will try raising a JIRA directly.

      Thanks.

      Comment


      • #4
        I say raise the JIRA now. We are discussing it and regardless of the outcome the JIRA is where such outcome will be documented.

        Comment


        • #5
          Hi Oleg,

          I have created a JIRA (INT-2474) for this.

          Thanks,

          Comment


          • #6
            Prabhabati - please vote for the JIRA-2474 if you find it relevant

            Comment


            • #7
              Hi Vasant,
              Could you please tell me how to vote. I am not getting any submit/vote button or link

              Comment


              • #8
                Hi I have voted for this after creating an account for JIRA request

                Comment

                Working...
                X