Announcement Announcement Module
Collapse
No announcement yet.
Handle wevservice Timeout in Spring integration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Handle wevservice Timeout in Spring integration

    Hi,

    I am using SpringIntegration and calling a webservice. My Application is deployed in WAS 7.0.It is working fine as long as the webservice sends response back.but if incase there is some timout occur in webservice after the request is made to webservice, the server gets hanged., with below error:
    Code:
    TimeoutManage I   WTRN0006W: Transaction 00000136581A4460000000030000000209EA42E83F47151C1457B1BF49B5622E03A56FFA00000136581A4460000000030000000209EA42E83F47151C1457B1BF49B5622E03A56FFA00000001 has timed out after 120 seconds.
    [3/28/12 15:01:38:214 HKT] 00000009 TimeoutManage I   WTRN0124I: When the timeout occurred the thread with which the transaction is, or was most recently, associated was Thread[MessageListenerThreadPool : 0,5,main]. The stack trace of this thread when the timeout occurred was: 
    	sun.misc.Unsafe.park(Native Method)
    	java.util.concurrent.locks.LockSupport.park(LockSupport.java:184)
    	java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:822)
    Can any one help me in this, how to handle the webservice timeout ? This is really very critical for my application.

    Below is my application context file code :
    Code:
    	<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>

  • #2
    Hello
    Try to use this one for your <ws:outbound-gateway>:
    HTML Code:
    <bean id="messageSender" class="org.springframework.ws.transport.http.CommonsHttpMessageSender"
    		  p:connectionTimeout="1000" p:readTimeout="60000"/>
    Here you'll have 1 sec for trying to connect and 1 min for waiting response.

    In another case now you are waiting response during transaction timeout - 2 mins.

    Any other questions?

    Artem Bilan

    Comment


    • #3
      Hi
      Thanks a lot for the response.
      I will try this one and will confirm, as my application depends on other system to be runnable (for webservice call).

      I have one more question, In case I have to call a https webservice, what should I use in message sender?

      Comment


      • #4
        In case I have to call a https webservice, what should I use in message sender
        for good - nothing!
        You should just configure SSL on your application server, where you'll put webservice sertificate.
        On the WAS you can do it though admin console via
        SSL certificate and key management > Key stores and certificates
        and receive his sertificate from URL.

        Comment


        • #5
          Hi,
          Could you please let me know,
          What is the xsd file and jar file used for namespace p:connectionTimeout and p:readTimeout. It is giving error as "The prefix 'p' for attribute p:connectionTimeout associated with an element type 'bean' is not bound".

          Thanks in advance

          Comment


          • #6
            It is giving error as "The prefix 'p' for attribute p:connectionTimeout
            This one:
            HTML Code:
            <beans xmlns="http://www.springframework.org/schema/beans"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xmlns:p="http://www.springframework.org/schema/p" ---HERE---
                   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
            http://static.springsource.org/sprin...ns-p-namespace

            Comment


            • #7
              Hi,
              The issu is still the same. the timeout is error is stil occuring.

              my code is :
              Code:
              	<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}" message-sender="messageSender"
              			marshaller="processWorkItemCastorMarshaller" unmarshaller="processWorkItemCastorMarshaller">
              		</ws:outbound-gateway>
              		
              	</int:chain>
              	
              		<bean id="messageSender" class="org.springframework.ws.transport.http.CommonsHttpMessageSender" 
              		  p:connectionTimeout="100" p:readTimeout="6000" />
              Code:
              [3/30/12 17:36:49:270 CST] 00000009 TimeoutManage I   WTRN0006W: Transaction 0000013662F50FA700000001000000016F3671EE29A9139E751E73E41CA7001A41546A990000013662F50FA700000001000000016F3671EE29A9139E751E73E41CA7001A41546A9900000001 has timed out after 120 seconds.
              [3/30/12 17:36:49:270 CST] 00000009 TimeoutManage I   WTRN0124I: When the timeout occurred the thread with which the transaction is, or was most recently, associated was Thread[MessageListenerThreadPool : 0,5,main]. The stack trace of this thread when the timeout occurred was: 
              	sun.misc.Unsafe.park(Native Method)
              	java.util.concurrent.locks.LockSupport.park(LockSupport.java:173)
              	java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:758)
              	java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:916)
              	java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1228)
              	java.util.concurrent.CountDownLatch.await(CountDownLatch.java:218)
              	org.springframework.integration.core.MessagingTemplate$TemporaryReplyChannel.receive(MessagingTemplate.java:378)
              	org.springframework.integration.core.MessagingTemplate$TemporaryReplyChannel.receive(MessagingTemplate.java:372)
              	org.springframework.integration.core.MessagingTemplate.doReceive(MessagingTemplate.java:301)
              	org.springframework.integration.core.MessagingTemplate.doSendAndReceive(MessagingTemplate.java:319)
              	org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:239)
              	org.springframework.integration.core.MessagingTemplate.convertSendAndReceive(MessagingTemplate.java:274)
              	org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:165)
              	org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceive(MessagingGatewaySupport.java:143)
              	org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(GatewayProxyFactoryBean.java:300)
              	org.springframework.integration.gateway.GatewayProxyFactoryBean.doInvoke(GatewayProxyFactoryBean.java:269)
              	org.springframework.integration.gateway.GatewayProxyFactoryBean.invoke(GatewayProxyFactoryBean.java:260)
              	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
              	org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
              	$Proxy28.createBPMWorkItem(Unknown Source)

              Comment


              • #8
                Show more stackTrace, please.
                I think the problem is is lying somewhere above, not in <ws:outbound-gateway>...

                Comment


                • #9
                  Hi,
                  Below is the full stack trace.
                  Code:
                  [3/30/12 18:20:58:017 CST] 0000000c WorkSpaceMana A   WKSP0500I: Workspace configuration consistency check is disabled.
                  [3/30/12 18:22:52:891 CST] 0000001d TimeoutManage I   WTRN0006W: Transaction 00000136631F3B0C00000004000000016F3671EE29A9139E751E73E41CA7001A41546A9900000136631F3B0C00000004000000016F3671EE29A9139E751E73E41CA7001A41546A9900000001 has timed out after 120 seconds.
                  [3/30/12 18:22:52:891 CST] 0000001d TimeoutManage I   WTRN0124I: When the timeout occurred the thread with which the transaction is, or was most recently, associated was Thread[MessageListenerThreadPool : 0,5,main]. The stack trace of this thread when the timeout occurred was: 
                  	sun.misc.Unsafe.park(Native Method)
                  	java.util.concurrent.locks.LockSupport.park(LockSupport.java:173)
                  	java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:758)
                  	java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:916)
                  	java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1228)
                  	java.util.concurrent.CountDownLatch.await(CountDownLatch.java:218)
                  	org.springframework.integration.core.MessagingTemplate$TemporaryReplyChannel.receive(MessagingTemplate.java:378)
                  	org.springframework.integration.core.MessagingTemplate$TemporaryReplyChannel.receive(MessagingTemplate.java:372)
                  	org.springframework.integration.core.MessagingTemplate.doReceive(MessagingTemplate.java:301)
                  	org.springframework.integration.core.MessagingTemplate.doSendAndReceive(MessagingTemplate.java:319)
                  	org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:239)
                  	org.springframework.integration.core.MessagingTemplate.convertSendAndReceive(MessagingTemplate.java:274)
                  	org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:165)
                  	org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceive(MessagingGatewaySupport.java:143)
                  	org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(GatewayProxyFactoryBean.java:300)
                  	org.springframework.integration.gateway.GatewayProxyFactoryBean.doInvoke(GatewayProxyFactoryBean.java:269)
                  	org.springframework.integration.gateway.GatewayProxyFactoryBean.invoke(GatewayProxyFactoryBean.java:260)
                  	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
                  	org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
                  	$Proxy28.createBPMWorkItem(Unknown Source)
                  	com.hsbc.mpfbpm.integration.jms.listener.MPFMDBListener$1.doInJms(MPFMDBListener.java:142)
                  	com.hsbc.esf.jms.templates.MessengerSessionCallback.doInJms(MessengerSessionCallback.java:43)
                  	org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:466)
                  	com.hsbc.esf.jms.templates.ESJmsTemplate.execute(ESJmsTemplate.java:49)
                  	com.hsbc.mpfbpm.integration.jms.listener.MPFMDBListener.processMessage(MPFMDBListener.java:109)
                  	com.hsbc.esf.jms.async.templates.EsMessageListener.onMessage(EsMessageListener.java:96)
                  	com.hsbc.esf.jms.async.impl.EsMessageDrivenBean.onMessage(EsMessageDrivenBean.java:107)
                  	com.ibm.ejs.jms.listener.MDBWrapper$PriviledgedOnMessage.run(MDBWrapper.java:302)
                  	com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:63)
                  	com.ibm.ejs.jms.listener.MDBWrapper.callOnMessage(MDBWrapper.java:271)
                  	com.ibm.ejs.jms.listener.MDBWrapper.onMessage(MDBWrapper.java:240)
                  	com.ibm.mq.jms.MQSession$FacadeMessageListener.onMessage(MQSession.java:147)
                  	com.ibm.msg.client.jms.internal.JmsSessionImpl.run(JmsSessionImpl.java:2557)
                  	com.ibm.mq.jms.MQSession.run(MQSession.java:860)
                  	com.ibm.ejs.jms.JMSSessionHandle.run(JMSSessionHandle.java:975)
                  	com.ibm.ejs.jms.listener.ServerSession.connectionConsumerOnMessage(ServerSession.java:900)
                  	com.ibm.ejs.jms.listener.ServerSession.onMessage(ServerSession.java:665)
                  	com.ibm.ejs.jms.listener.ServerSession.dispatch(ServerSession.java:632)
                  	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
                  	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
                  	java.lang.reflect.Method.invoke(Method.java:599)
                  	com.ibm.ejs.jms.listener.ServerSessionDispatcher.dispatch(ServerSessionDispatcher.java:37)
                  	com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:96)
                  	com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:132)
                  	com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:496)
                  	com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)

                  Comment


                  • #10
                    So, as I understand you invoke some Gateway:
                    $Proxy28.createBPMWorkItem(Unknown Source)
                    com.hsbc.mpfbpm.integration.jms.listener.MPFMDBLis tener$1.doInJms(MPFMDBListener.java:142)
                    And it is waiting reply in the:
                    org.springframework.integration.core.MessagingTemp late$TemporaryReplyChannel.receive(MessagingTempla te.java:378)
                    But your gateway message flow doesn't returnt anything.
                    Who sends message to the mpfBpmNotificationChannel? And who is subscribed to the wsInChannel ?

                    Comment


                    • #11
                      We need to see more of your configuration - for example what is wsInChannel wired to?

                      This thread is waiting in a messaging gateway for a response from the flow and no response appeared. It implies there is an asynch handoff someplace.

                      If you run with DEBUG logging for org.springframework.integration, you will see the messages progress through the channels and you should be able to quickly see what's going on.

                      Comment


                      • #12
                        Hi ,

                        In my application the input msgis coming from a MDB to gateway, from there the processing starts. Gateway keeps the msg in 'mpfBpmNotificationChannel' and the webservice put the response msg is 'wsInchannel' channel.
                        below is my complete context file.

                        Code:
                            <int:channel id="mpfBpmNotificationChannel">
                             <int:interceptors>
                                 <int:wire-tap channel="logger"/>
                             </int:interceptors>
                           </int:channel>
                        	
                        	<int:channel id="wsInChannel">
                        	     <int:interceptors>
                                 <int:wire-tap channel="logger"/>
                             	</int:interceptors>
                        	</int:channel>
                        
                        	<int:channel id="jmsOutChannel">
                        	     <int:interceptors>
                                 <int:wire-tap channel="logger"/>
                             	</int:interceptors>
                        	</int:channel>
                        
                        	
                        	<int:channel id="errorChannel"/>
                        
                        
                        	<int:gateway id="workItemService"
                        		service-interface="com.hsbc.mpfbpm.integration.service.WorkItemService"
                        		default-request-channel="mpfBpmNotificationChannel" default-reply-timeout="60000"
                        		default-reply-channel="jmsOutChannel" error-channel="errorChannel">
                        		<int:method name="createBPMWorkItem" request-channel="mpfBpmNotificationChannel" reply-timeout="60000"
                        			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}" message-sender="messageSender"
                        			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>
                        	
                        	
                        	<bean id="messageSender" class="org.springframework.ws.transport.http.CommonsHttpMessageSender" 
                        		  p:connectionTimeout="10000" p:readTimeout="60000" />
                        
                        <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>
                        	
                        	<bean id="msgCodeMapper"
                        		class="com.hsbc.mpfbpm.integration.util.DefaultMessageCodeMapper">
                        	</bean>

                        Comment


                        • #13
                          So, maybe some of your message handlers doesn't return anything?
                          In other words: return null, which isn't appropriate as message's payload. And it is signal for stopping message flow right now.

                          Comment


                          • #14
                            Yeah - that's probably the case because there's no aynch - as I said - run with DEBUG logging and you can trace messages through the flow.

                            Comment

                            Working...
                            X