[jboss-user] [Remoting] - Problem with closing connection on client side

amar.trnka do-not-reply at jboss.com
Fri Dec 12 11:20:48 EST 2008


Hi,

I have two applications and they are published on two different JBoss servers. 
The first server (client):
-	Default server configuration - jboss-4.2.2.GA

Second server (server): 
-	Messaging server configuration - jboss-4.2.2.GA - with jboss-messaging-1.4.0.SP3 on it. 

Client sends messages to the server and application on messaging server puts all messages into the queue. 

Application code for connecting from client to server is:



  | private JndiTemplate jndiTemplate;
  | private JndiObjectFactoryBean jmsQueueConnectionFactory;
  | private JndiObjectFactoryBean queueDestination;
  | private SingleConnectionFactory connectionFactory;
  | private JmsTemplate jmsIngestionTemplate;
  | ...
  | 
  | Properties props = new Properties();
  | props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
  | props.setProperty("java.naming.provider.url", "jnp://tridesetsedam.atlantbh.com:1099");
  | props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
  | props.setProperty("java.naming.security.principal", "admin");
  | props.setProperty("java.naming.security.credentials", "admin");
  | 
  | jndiTemplate = new JndiTemplate();
  | jndiTemplate.setEnvironment(props);
  | 
  | jmsQueueConnectionFactory = new JndiObjectFactoryBean();
  | jmsQueueConnectionFactory.setJndiTemplate(jndiTemplate);
  | jmsQueueConnectionFactory.setJndiName("ConnectionFactory");
  | jmsQueueConnectionFactory.afterPropertiesSet();
  | 				
  | queueDestination = new JndiObjectFactoryBean();
  | queueDestination.setLookupOnStartup(true);
  | queueDestination.setJndiTemplate(jndiTemplate);
  | queueDestination.setJndiName("queue/LroPublishIngestionQueue");
  | queueDestination.afterPropertiesSet();
  | 				
  | connectionFactory = new SingleConnectionFactory();
  | connectionFactory.setTargetConnectionFactory((ConnectionFactory)jmsQueueConnectionFactory.getObject());
  | connectionFactory.initConnection();
  | 				
  | jmsIngestionTemplate = new JmsTemplate();		
  | jmsIngestionTemplate.setConnectionFactory((ConnectionFactory)connectionFactory);
  | jmsIngestionTemplate.setDefaultDestination((Destination)queueDestination.getObject());
  | jmsIngestionTemplate.setReceiveTimeout(30000);
  | 				
  | messageDispatcher.setJmsTemplate(jmsIngestionTemplate);
  | ...
  | 

Becouse I'm using SingleConnectionFactory I have next problem:
when both servers are up and running, and second messaging server shuts down, application on the default server throws exception: 


  | ERROR [Timer-4] socket.SocketClientInvoker (SocketClientInvoker.java:109)     - Got marshalling exception, exiting
  | java.io.IOException: Connection reset by peer: socket write error
  | 	at java.net.SocketOutputStream.socketWrite0(Native Method)
  | 	at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
  | 	at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
  | 	at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
  | 	at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
  | 	at java.io.DataOutputStream.flush(DataOutputStream.java:106)
  | 	at org.jboss.jms.wireformat.SerializedPacket.write(SerializedPacket.java:81)
  | 	at org.jboss.jms.wireformat.JMSWireFormat.write(JMSWireFormat.java:237)
  | 	at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.versionedWrite(MicroSocketClientInvoker.java:983)
  | 	at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:559)
  | 	at org.jboss.remoting.transport.bisocket.BisocketClientInvoker.transport(BisocketClientInvoker.java:413)
  | 	at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:122)
  | 	at org.jboss.remoting.ConnectionValidator.doCheckConnection(ConnectionValidator.java:133)
  | 	at org.jboss.remoting.ConnectionValidator.run(ConnectionValidator.java:308)
  | 	at java.util.TimerThread.mainLoop(Timer.java:512)
  | 	at java.util.TimerThread.run(Timer.java:462)
  | 

and LeasePinger starts its pingging...


  | 2008-12-12 17:08:37,295 WARN  [Timer-3] remoting.LeasePinger (LeasePinger.java:290)     - LeasePinger[SocketClientInvoker[104d3c8, bisocket://172.20.12.37:4457](4skc11-j1ifh9-fon18jfd-1-fon19dxv-a)] failed to ping to server: Can not get connection to server. Problem establishing socket connection for InvokerLocator [bisocket://172.20.12.37:4457/?JBM_clientMaxPoolSize=200&clientLeasePeriod=10000&clientSocketClass=org.jboss.jms.client.remoting.ClientSocketWrapper&dataType=jms&marshaller=org.jboss.jms.wireformat.JMSWireFormat&numberOfCallRetries=1&numberOfRetries=10&pingFrequency=214748364&pingWindowFactor=10&socket.check_connection=false&timeout=0&unmarshaller=org.jboss.jms.wireformat.JMSWireFormat]
  | 


If I use ConnectionFactory instead of SingleConnectionFactory evertything works perfectly, but for performance reasons I must use SingleConnectionFactory. 
Reason for this exceptions and pingging is that connection on client side (default server) is not destroyed when server shuts down. 
If I start Messaging server again and connection is re-established when I send message exception is thrown: 


  | org.jboss.jms.exception.MessagingJMSException: Failed to invoke; nested exception is java.lang.IllegalStateException: Cannot find object in dispatcher with id h-n2e91nof-1-8fe81nof-gdf8gm-11cks4
  | 	at com.navteq.lro.publishing.publish.impl.LROPublishSenderImpl.send(Unknown Source)
  | 	at com.navteq.lro.publishing.service.impl.LROPublishServiceImpl.publishLRO(Unknown Source)
  | 	at com.navteq.lro.test.SenderServlet.doGet(SenderServlet.java:63)
  | 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
  | 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
  | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | 	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
  | 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
  | 	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
  | 	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
  | 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  | 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
  | 	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
  | 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  | 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
  | 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
  | 	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
  | 	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
  | 	at java.lang.Thread.run(Thread.java:595) 
  | 
  |   | 
  |   | Reason: client is still having old connection instance. 
  |   | 
  |   | Finaly my question: is there any way to inform client from server to close it's connection while Messaging JBoss is shutting down. 
  |   | 
  |   | ps. I'm new in JBoss and JBoss Messaging. Maybe I've done this wrong. Any help I will gladly accept. I'm sorry if I forgot to write down some more information.
  |   | 
  |   | Amar

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4196286#4196286

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4196286



More information about the jboss-user mailing list