5 Replies Latest reply on Oct 24, 2003 2:17 AM by Stephane Nicoll

    Why does it hang?

    arabin Novice

      My code is:

      public class PerformanceTester implements Runnable
      {
      static CountDown done = new CountDown(1);

      public void run ()
      {
      while (true)
      {
      //Logging.debugInfoLog ("Running...");
      try
      {
      Thread.sleep (2000);
      }
      catch (Exception ignored){}
      }
      }

      public static class ExListener implements MessageListener
      {
      public void onMessage(Message msg)
      {
      //done.release();
      TextMessage tm = (TextMessage) msg;
      try
      {
      Logging.debugInfoLog("onMessage, received text="
      + tm.getText());
      }
      catch(Throwable t)
      {
      t.printStackTrace();
      }
      }
      }

      public void sendRecvAsync(String text)
      throws JMSException, NamingException
      {
      QueueConnection conn = null;
      QueueSession session = null;
      Queue que = null;
      //Logging.debugInfoLog("Begin sendRecvAsync");
      // Setup the PTP connection, session
      InitialContext iniCtx = new InitialContext();
      Object tmp = iniCtx.lookup("QueueConnectionFactory");
      QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
      conn = qcf.createQueueConnection("1", "ONE");
      que = (Queue) iniCtx.lookup("queue/testQueue");
      session = conn.createQueueSession(false,
      QueueSession.AUTO_ACKNOWLEDGE);
      conn.start();
      // Set the async listener
      QueueReceiver recv = session.createReceiver(que);
      recv.setMessageListener(new ExListener());
      // Send a text msg
      QueueSender send = session.createSender(que);
      TextMessage tm = session.createTextMessage(text);
      send.send(tm);
      //Logging.debugInfoLog("sendRecvAsync, sent text="
      // + tm.getText());
      send.close();
      //Logging.debugInfoLog("End sendRecvAsync");
      conn.stop();
      session.close();
      conn.close();
      }


      public static void main(String args[]) throws Exception
      {
      for (int ii=0; ii< 1000; ii++)
      {
      PerformanceTester client = new PerformanceTester();
      String msg = "Text Message " + ii + " " + ServiceTimer.getFormattedTime();
      Logging.debugInfoLog("Sending " + msg);
      client.sendRecvAsync(msg);
      }
      for (int ii=0; ii< 100000; ii++)
      {
      PerformanceTester client = new PerformanceTester();
      String msg = "Text Message " + ii + " " + ServiceTimer.getFormattedTime();
      //Logging.debugInfoLog("Sending " + msg);
      //client.sendRecvAsync(msg);
      }
      //client.done.acquire();
      //done.acquire();
      Thread a = new Thread (new PerformanceTester());
      a.start();
      Logging.debugInfoLog("Started");
      while(true)
      Thread.sleep(10000);
      //System.exit(0);
      }

      }

      It hangs on iteration 916.

      I have the following thread dump.

      Sending Text Message 908 06:27:28,972
      Sending Text Message 909 06:27:28,987
      Sending Text Message 910 06:27:29,003
      Sending Text Message 911 06:27:29,019
      Sending Text Message 912 06:27:29,034
      Sending Text Message 913 06:27:29,050
      Sending Text Message 914 06:27:29,066
      Sending Text Message 915 06:27:29,081
      Sending Text Message 916 06:27:29,097
      Full thread dump Java HotSpot(TM) Client VM (1.4.2_01-b06 mixed mode):

      "OILClientILService-916" daemon prio=5 tid=0x02c66788 nid=0x33d8 waiting for mon
      itor entry [308f000..308fd94]
      at org.jboss.mq.il.oil.OILServerIL.acknowledge(OILServerIL.java:200)
      - waiting to lock <0x100d8158> (a org.jboss.mq.il.oil.OILServerIL)
      at org.jboss.mq.Connection.send(Connection.java:903)
      at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:42
      1)
      at org.jboss.mq.Connection.asynchDeliver(Connection.java:688)
      at org.jboss.mq.il.oil.OILClientILService.run(OILClientILService.java:20
      8)
      at java.lang.Thread.run(Thread.java:534)

      "RMI ConnectionExpiration-[192.168.1.19:4510]" daemon prio=5 tid=0x02c69978 nid=
      0x1b74 waiting on condition [2fbf000..2fbfd94]
      at java.lang.Thread.sleep(Native Method)
      at sun.rmi.transport.tcp.TCPChannel$Reaper.run(TCPChannel.java:447)
      at java.lang.Thread.run(Thread.java:534)

      "Connection Monitor Thread" daemon prio=5 tid=0x02ca2160 nid=0x61d0 in Object.wa
      it() [303f000..303fd94]
      at java.lang.Object.wait(Native Method)
      at EDU.oswego.cs.dl.util.concurrent.ClockDaemon.nextTask(ClockDaemon.jav
      a:328)
      - locked <0x10514950> (a EDU.oswego.cs.dl.util.concurrent.ClockDaemon)
      at EDU.oswego.cs.dl.util.concurrent.ClockDaemon$RunLoop.run(ClockDaemon.
      java:362)
      at java.lang.Thread.run(Thread.java:534)

      "GC Daemon" daemon prio=2 tid=0x02c72318 nid=0x61b8 in Object.wait() [2f7f000..2
      f7fd94]
      at java.lang.Object.wait(Native Method)
      - waiting on <0x1050c6a0> (a sun.misc.GC$LatencyLock)
      at sun.misc.GC$Daemon.run(GC.java:100)
      - locked <0x1050c6a0> (a sun.misc.GC$LatencyLock)

      "RMI RenewClean-[192.168.1.19:4510]" daemon prio=5 tid=0x00a3bcd0 nid=0x61b4 in
      Object.wait() [2f3f000..2f3fd94]
      at java.lang.Object.wait(Native Method)
      - waiting on <0x1050c6f0> (a java.lang.ref.ReferenceQueue$Lock)
      at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
      - locked <0x1050c6f0> (a java.lang.ref.ReferenceQueue$Lock)
      at sun.rmi.transport.DGCClient$EndpointEntry$RenewCleanThread.run(DGCCli
      ent.java:500)
      at java.lang.Thread.run(Thread.java:534)

      "Signal Dispatcher" daemon prio=10 tid=0x009f8ec0 nid=0x61a4 waiting on conditio
      n [0..0]

      "Finalizer" daemon prio=9 tid=0x009be910 nid=0x619c in Object.wait() [2b5f000..2
      b5fd94]
      at java.lang.Object.wait(Native Method)
      at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
      - locked <0x104fce68> (a java.lang.ref.ReferenceQueue$Lock)
      at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
      at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

      "Reference Handler" daemon prio=10 tid=0x009bd4e0 nid=0x6198 in Object.wait() [2
      b1f000..2b1fd94]
      at java.lang.Object.wait(Native Method)
      - waiting on <0x104fced0> (a java.lang.ref.Reference$Lock)
      at java.lang.Object.wait(Object.java:429)
      at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:115)
      - locked <0x104fced0> (a java.lang.ref.Reference$Lock)

      "main" prio=5 tid=0x00034cd0 nid=0x6190 runnable [7f000..7fc3c]
      at java.net.SocketInputStream.socketRead0(Native Method)
      at java.net.SocketInputStream.read(SocketInputStream.java:129)
      at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
      at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
      - locked <0x100d8368> (a java.io.BufferedInputStream)
      at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java
      :2133)
      at java.io.ObjectInputStream$BlockDataInputStream.readBlockHeader(Object
      InputStream.java:2313)
      at java.io.ObjectInputStream$BlockDataInputStream.refill(ObjectInputStre
      am.java:2380)
      at java.io.ObjectInputStream$BlockDataInputStream.read(ObjectInputStream
      .java:2452)
      at java.io.ObjectInputStream$BlockDataInputStream.readByte(ObjectInputSt
      ream.java:2601)
      at java.io.ObjectInputStream.readByte(ObjectInputStream.java:845)
      at org.jboss.mq.il.oil.OILServerIL.waitAnswer(OILServerIL.java:601)
      at org.jboss.mq.il.oil.OILServerIL.connectionClosing(OILServerIL.java:33
      4)
      - locked <0x100d8158> (a org.jboss.mq.il.oil.OILServerIL)
      at org.jboss.mq.Connection.close(Connection.java:491)
      - locked <0x100d7ee8> (a org.jboss.mq.SpyConnection)
      at com.wrn.teamworks.cms.client.PerformanceTester.sendRecvAsync(Performa
      nceTester.java:84)
      at com.wrn.teamworks.cms.client.PerformanceTester.main(PerformanceTester
      .java:95)

      "VM Thread" prio=5 tid=0x009f76f8 nid=0x6194 runnable

      "VM Periodic Task Thread" prio=10 tid=0x009fb6d8 nid=0x61ac waiting on condition

      "Suspend Checker Thread" prio=10 tid=0x009f8578 nid=0x61a0 runnable