0 Replies Latest reply on Oct 21, 2004 9:59 AM by vitin

    JMS problem sending to queue

    vitin Newbie

      I am sending messages to a queue but the queue remains empty. I can see my queue in the jmx-console but it also shows empty. No exceptions are thrown.

      java 1.4.2; jboss 3.2.6

      my thread does this:

      ServiceLocator locator = ServiceLocator.getInstance();
      QueueConnectionFactory connFac = locator
      .getQueueConnectionFactory();
      Queue queue = (Queue) locator.getQueue();
      conn = connFac.createQueueConnection();
      QueueSession session = conn.createQueueSession(true,Session.AUTO_ACKNOWLEDGE);

      for (int i = 0; i < 10; i++) {
      System.out.println("Sending "+i+"...");
      TextMessage message = session.createTextMessage("Hello"+i);
      QueueSender sender = session.createSender(queue);
      sender.send(message);
      System.out.println("Sent!!!!!");

      //Count queue elements
      Enumeration enumer = browser.getEnumeration();
      int count = 0;
      while(enumer.hasMoreElements()) {
      enumer.nextElement();
      count++;
      }
      System.out.println("Queue count: "+count);

      //Wait a few secs
      Thread.sleep(2000);
      }


      The output looks like this:

      Sending 0 ...
      Sent!!!!!
      Queue count: 0
      Sending 1 ...
      Sent!!!!!
      Queue count: 0
      ...

      I am using the default connection factory called "/XAConnectionFactory" in JNDI and I created a queue. These are my configuration files:

      <!-- begin web.xml...-->
      <web-app>
      <!-- JMS Connection Factories (java:comp/env/jms) -->
      <resource-ref>
      Default Queue Connection Factory
      <res-ref-name>jms/QueueConnectionFactory</res-ref-name>
      <res-type>javax.jms.QueueConnectionFactory</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      <!-- JMS Queues (java:comp/env/queue) -->
      <resource-ref>
      Default Queue
      <res-ref-name>queue/sfuq</res-ref-name>
      <res-type>javax.jms.Queue</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>
      </web-app>
      <!-- ...end web.xml-->

      <!-- begin jboss-web.xml-->
      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-web>
      <resource-ref>
      The message queue
      <res-ref-name>queue/sfuq</res-ref-name>
      <res-type>javax.jms.Queue</res-type>
      <jndi-name>queue/sfuq</jndi-name>
      </resource-ref>
      <resource-ref>
      The connection factory
      <res-ref-name>jms/QueueConnectionFactory</res-ref-name>
      <res-type>javax.jms.QueueConnectionFactory</res-type>
      <jndi-name>XAConnectionFactory</jndi-name>
      </resource-ref>
      </jboss-web>
      <!-- end jboss-web.xml -->

      <!-- begin destinations-service.xml -->


      queue/sfuq
      <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager


      <!-- end destinations-service.xml -->