« Return to Thread: publish() call to remote JMS server hangs

publish() call to remote JMS server hangs

by skarthik :: Rate this Message:

Reply to Author | View in Thread

Hi,

 This is rather long post as it took me a while to narrow down the problem.

 We are running activeMQ RC2 server on a windows XP machine and a simple JMS client test-program on another remote XP machine within the same LAN subnet. The test-program opens one JMS connection to the activeMQ server, establishes one session (with auto acknowledge), and creates one publisher on a topic on the session. Then in a loop, it creates an ObjectMessage and publishes it with PERSISTENT DeliveryMode, peppered by Thread.sleep() calls after each publish. The following snippet provides an example:

         TopicConnectionFactory tcf = (TopicConnectionFactory) jndiCtx.lookup (tcfName);
         Topic topic = (Topic) jndiCtx.lookup (topicName);

         TopicConnection jmsCon = tcf.createTopicConnection();
         TopicSession session = jmsCon.createTopicSession (false, Session.AUTO_ACKNOWLEDGE);
         TopicPublisher publisher = session.createPublisher (topic);

         while (true) {
            ObjectMessage om = session.createObjectMessage ();
            om.setObject ("TESTSTRING");
            publisher.publish (om, DeliveryMode.PERSISTENT, 9, 20000);

            Thread.sleep (20000);
         }


 It was found that when we disconnect the LAN cable from the client machine (to simulate network outage), if the test client tries to publish an ObjectMessage before activeMQ client stub detects the network disconnect, the publish call hangs.

 After further analysis, we found that even setting simple string payload to the ObjectMessage as shown in the following code snippet causes the hang.

         ObjectMessage om = session.createObjectMessage ();
         om.setObject ("TESTSTRING");
         publisher.publish (om, DeliveryMode.PERSISTENT, 9, 20000);

 But using a byte array (byte[]) as payload does not cause an hang.

        byte[] payload; // populated by reading a specified input ascii file

         ObjectMessage om = session.createObjectMessage ();
         om.setObject (payload);
         publisher.publish (om, DeliveryMode.PERSISTENT, 9, 20000);

 Also setting a complex java serializable class instance as payload causes a hang, but an instance of almost similar class, but with an additional byte[] array attribute does not cause the publish() call to hang.

 Wanted to clarify that this hang is observered only in the test case scenario involving LAN disconnects. In normal cases the same messages flow sucessfully between the multiple remote producers and consumers. Also when I say the publish() call does not hang, I meant the publish() class throws the following exception which is the normal expected behavior.

javax.jms.JMSException: Connection reset by peer: socket write error at
 org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:57)
        at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1118)
        at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1524)
        at org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:462)
        at org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:384)
        at org.apache.activemq.ActiveMQTopicPublisher.publish(ActiveMQTopicPublisher.java:151)
                at com.nec.tdd.tools.platformX.util.PingJMSMsg$Publisher.publishMessage(PingJMSMsg.java:122)
        at com.nec.tdd.tools.platformX.util.PingJMSMsg$Publisher.run(PingJMSMsg.java:102)
Caused by: java.net.SocketException: 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 org.apache.activemq.transport.tcp.TcpBufferedOutputStream.write(TcpBufferedOutputStream.java:95)
        at java.io.DataOutputStream.write(DataOutputStream.java:85)
        at org.apache.activemq.openwire.v1.BaseDataStreamMarshaller.tightMarshalByteSequence2(BaseDataStreamMarshaller.java:403)
        at org.apache.activemq.openwire.v1.MessageMarshaller.tightMarshal2(MessageMarshaller.java:160)
        at org.apache.activemq.openwire.v1.ActiveMQMessageMarshaller.tightMarshal2(ActiveMQMessageMarshaller.java:88)
        at org.apache.activemq.openwire.v1.ActiveMQObjectMessageMarshaller.tightMarshal2(ActiveMQObjectMessageMarshaller.java:88)
        at org.apache.activemq.openwire.OpenWireFormat.marshal(OpenWireFormat.java:240)
        at org.apache.activemq.transport.tcp.TcpTransport.oneway(TcpTransport.java:120)
        at org.apache.activemq.transport.InactivityMonitor.oneway(InactivityMonitor.java:141)
        at org.apache.activemq.transport.TransportFilter.oneway(TransportFilter.java:86)
        at org.apache.activemq.transport.WireFormatNegotiator.oneway(WireFormatNegotiator.java:77)
        at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:44)
        at org.apache.activemq.transport.ResponseCorrelator.asyncRequest(ResponseCorrelator.java:63)
        at org.apache.activemq.transport.ResponseCorrelator.request(ResponseCorrelator.java:68)
        at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1108)
        ... 6 more

  I hope this was helpful and would lead to a fix as this is a crital test scenario for us.

Thanks in advance

regards
karthik

 « Return to Thread: publish() call to remote JMS server hangs