0 Replies Latest reply on Jan 5, 2012 11:06 AM by Arash Bijanzadeh

    Browser Question

    Arash Bijanzadeh Newbie

      I have a problem with browser. I coded the following sample as a test case to see how browser works.

       

       @Test
          public void testBrowse() throws NamingException, JMSException {
              InitialContext ic = new InitialContext();
              String queueAddress = "/queue/" + QueueEnum.YospaceVerificationQueue;
              HornetQConnectionFactory factory = (HornetQConnectionFactory)ic.lookup("/ConnectionFactory");
      
      
              Connection connection = factory.createConnection();
              Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
              QueueBrowser browser = session.createBrowser((Queue) ic.lookup(queueAddress));
              Enumeration e = browser.getEnumeration();
              while(e.hasMoreElements()){
                  Object o = e.nextElement();
                  System.out.println(o);
                  System.out.println(o.getClass());
                  HornetQObjectMessage message = (HornetQObjectMessage) o;
                  MSBMessage msg = (MSBMessage) message.getObject();
                  System.out.println(msg.getMedia().getOriginalFileName() );
      
                  browser.close();
                  connection.close();
              }
      
              
          }
      

      I have one sinngle message in the queue and I can confirm it through the JMX browser, but the code doesn't show it usually. I said usually because sometimes it does.

       

      Is there any mistake in the code?

      What is the best way to look inside a queue? Maybe I should be looking at a Jmx solution?

       

      thanks for your help in advance.