Package javax.jms

Examples of javax.jms.QueueBrowser


      // Use the static MQConnection.newInstance() method to instantiate a
      // new
      // connection for messagequeues and creates a JMS-QueueBrowser for
      // the given queue.
      MQConnection mqCon = MQConnection.getInstance();
      QueueBrowser qb = mqCon.getBrowser(new XBUSSystem(logQueuename));

      TextMessage message = null;

      Enumeration e = qb.getEnumeration();

      while (e.hasMoreElements())
      {
        message = (TextMessage) e.nextElement();
        System.out.print(message.getText());
View Full Code Here


      // Use the static MQConnection.newInstance() method to instantiate a
      // new
      // connection for messagequeues and creates a JMS-QueueBrowser for
      // the given queue.
      MQConnection mqCon = MQConnection.getInstance();
      QueueBrowser qb = mqCon.getBrowser(new XBUSSystem(logQueuename));

      TextMessage message = null;
      Date timestamp = new Date();

      Enumeration e = qb.getEnumeration();

      while (e.hasMoreElements())
      {
        message = (TextMessage) e.nextElement();
        timestamp.setTime(message.getJMSTimestamp());
View Full Code Here

        sender = (QueueSender) e.nextElement();
        sender.close();
      }
      mSenders.clear();

      QueueBrowser browser;
      for (Enumeration e = mBrowsers.elements(); e.hasMoreElements();) {
        browser = (QueueBrowser) e.nextElement();
        browser.close();
      }
      mBrowsers.clear();

      mSession.close();
      mConnection.close();
View Full Code Here

  /**
   * Creates and returns a JMS- <code>QueueBrowser</code> for the given queue.
   */
  public QueueBrowser getBrowser(XBUSSystem system) throws XException {
    QueueBrowser browser = null;

    String pyhsQueuename = getPhysQueuename(system);
    Queue queue = getQueue(pyhsQueuename);
    try {
      if ((browser = (QueueBrowser) mBrowsers.get(pyhsQueuename)) == null) {
View Full Code Here

      producer.send(m);        
    }
   
    log.trace("Sent messages");

    QueueBrowser browser = session.createBrowser(queue);
   
    assertEquals(browser.getQueue(), queue);
   
    assertNull(browser.getMessageSelector());
   
    Enumeration en = browser.getEnumeration();
   
    int count = 0;
    while (en.hasMoreElements())
    {
      en.nextElement();
      count++;
    }
   
    assertEquals(numMessages, count);
   
    MessageConsumer mc = session.createConsumer(queue);
   
    connection.start();
   
    for (int i = 0; i < numMessages; i++)
    {
      Message m = mc.receive();
         assertNotNull(m);
    }
     
      // Need to pause here since delivery is done on a different thread. Message might not be
      // removed from in memory state by this point.
     
      Thread.sleep(2000);
   
    browser = session.createBrowser(queue);
    en = browser.getEnumeration();
   
   
    count = 0;
    while (en.hasMoreElements())
    {
View Full Code Here

      producer.send(m);
    }
   
    log.trace("Sent messages");
   
    QueueBrowser browser = session.createBrowser(queue, "test_counter > 30");
   
    Enumeration en = browser.getEnumeration();
    int count = 0;
    while (en.hasMoreElements())
    {
      Message m = (Message)en.nextElement();
      int testCounter = m.getIntProperty("test_counter");
View Full Code Here

      Message m = session.createTextMessage("A");
      producer.send(m);

      // make sure we can browse it

      QueueBrowser browser = session.createBrowser(queue);

      Enumeration en = browser.getEnumeration();

      assertTrue(en.hasMoreElements());

      TextMessage rm = (TextMessage)en.nextElement();

      assertNotNull(rm);
      assertEquals("A", rm.getText());

      assertFalse(en.hasMoreElements());

      // create a *new* enumeration, that should reset it

      en = browser.getEnumeration();

      assertTrue(en.hasMoreElements());

      rm = (TextMessage)en.nextElement();

View Full Code Here

      TextMessage m = session.createTextMessage("message one");

      prod.send(m);

      QueueBrowser browser = session.createBrowser(queue);


      Enumeration e = browser.getEnumeration();

      TextMessage bm = (TextMessage)e.nextElement();

      assertEquals("message one", bm.getText());
View Full Code Here

     
      try
      {
         conn = getConnection();
         session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         QueueBrowser browser = session.createBrowser(queue);
        
         ArrayList list = new ArrayList();
         for(Enumeration e = browser.getEnumeration(); e.hasMoreElements(); )
         {
            list.add(e.nextElement());
         }
        
         return list.size();
View Full Code Here

         assertEquals(1, ((JBossConnection)conn).getServerID());

         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);

         QueueBrowser browser = session.createBrowser(queue[1]);

         Enumeration en = browser.getEnumeration();
         assertFalse(en.hasMoreElements());

         // send one persistent and one non-persistent message

         MessageProducer prod = session.createProducer(queue[1]);
         prod.setDeliveryMode(DeliveryMode.PERSISTENT);
         prod.send(session.createTextMessage("click"));
         prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
         prod.send(session.createTextMessage("clack"));

         // register a failover listener
         SimpleFailoverListener failoverListener = new SimpleFailoverListener();
         ((JBossConnection)conn).registerFailoverListener(failoverListener);

         log.debug("killing node 1 ....");

         ServerManagement.kill(1);

         log.info("########");
         log.info("######## KILLED NODE 1");
         log.info("########");

         // wait for the client-side failover to complete

         while(true)
         {
            FailoverEvent event = failoverListener.getEvent(120000);
            if (event != null && FailoverEvent.FAILOVER_COMPLETED == event.getType())
            {
               break;
            }
            if (event == null)
            {
               fail("Did not get expected FAILOVER_COMPLETED event");
            }
         }

         // failover complete
         log.info("failover completed");

         assertEquals(0, ((JBossConnection)conn).getServerID());

         en = browser.getEnumeration();

         // we expect to only be able to browse the persistent message
         assertTrue(en.hasMoreElements());
         TextMessage tm = (TextMessage)en.nextElement();
         assertEquals("click", tm.getText());
View Full Code Here

TOP

Related Classes of javax.jms.QueueBrowser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.