0 Replies Latest reply on Jul 4, 2002 12:53 PM by drpacman

    JBoss 3.0 JMS - messages not appearing in queues

    drpacman

      Hello,
      I have recently installed JBoss but cannot seem to get
      JMS/Message beans to work correctly. I have gone right
      back to basics and tried to send messages to the example queues but still have no luck. When the code executes it appears to successfully send a message but when I check the queue depth of the receiving queue via the JNDIView MBean it is always zero. Please help! My code snippet is listed below and the output generated.

      try{
      ...
      ...
      // try and get a connection to MQ!
      System.out.println("getting MQ factory");
      javax.jms.QueueConnectionFactory factory=(javax.jms.QueueConnectionFactory)ctx.lookup("ConnectionFactory");
      System.out.println("got MQ factory");

      System.out.println("getting Queue connection");
      javax.jms.QueueConnection qConn=factory.createQueueConnection();
      System.out.println("got Queue connection");

      System.out.println("getting Queue session");
      javax.jms.QueueSession qSession=qConn.createQueueSession(true, javax.jms.QueueSession.CLIENT_ACKNOWLEDGE);
      System.out.println("got Queue connection");

      // get a handle on my queue
      System.out.println("getting Queue");
      javax.jms.Queue myQ=(javax.jms.Queue)ctx.lookup("queue/A");
      System.out.println("got Queue - "+myQ.getQueueName());

      // get handle for sender
      System.out.println("getting Sender");
      javax.jms.QueueSender qSender=qSession.createSender(myQ);
      // make message sent persistent
      qSender.setDeliveryMode(javax.jms.DeliveryMode.PERSISTENT);
      qSender.setTimeToLive(10000);

      System.out.println("created Sender for Q "+qSender.getQueue().getQueueName()+" and time to live="+qSender.getTimeToLive());

      System.out.println("done");

      // get message to fill
      System.out.println("getting Message");
      javax.jms.TextMessage txtMsg=qSession.createTextMessage("My Test Message");
      txtMsg.setJMSExpiration(10000);
      System.out.println("created Message");

      // send message
      System.out.println("sending Message with expiration "+txtMsg.getJMSExpiration());
      qSender.send(txtMsg);
      System.out.println("Sent message to "+txtMsg.getJMSDestination().toString());

      qSender.close();
      qConn.close();
      }
      catch (Exception e){...}

      and the output is:

      getting MQ factory

      got MQ factory

      getting Queue connection

      got Queue connection

      getting Queue session

      got Queue connection

      getting Queue

      got Queue - A

      getting Sender

      created Sender for Q A and time to live=10000

      done

      getting Message

      created Message

      sending Message with expiration 10000

      Sent message to QUEUE.A

      Thanks
      Paul