Package javax.jms

Examples of javax.jms.QueueBrowser


      addMessages();
      validateCounts(MESSAGE_COUNT, MESSAGE_COUNT, MESSAGE_COUNT * 2);

      purgeCommand.execute(tokens);

      QueueBrowser withPropertyBrowser = requestServerSession.createBrowser(
          theQueue, MSG_SEL_COMPLEX_SQL_AND);
      QueueBrowser allBrowser = requestServerSession.createBrowser(theQueue);

      int withCount = getMessageCount(withPropertyBrowser, "withProperty ");
      int allCount = getMessageCount(allBrowser, "allMessages ");

      withPropertyBrowser.close();
      allBrowser.close();
     
      assertEquals("Expected withCount to be " + "0" + " was "
          + withCount, 0, withCount);
      assertEquals("Expected allCount to be " + MESSAGE_COUNT + " was "
          + allCount, MESSAGE_COUNT, allCount);
View Full Code Here


      addMessages();
      validateCounts(MESSAGE_COUNT, MESSAGE_COUNT, MESSAGE_COUNT * 2);

      purgeCommand.execute(tokens);

      QueueBrowser withPropertyBrowser = requestServerSession.createBrowser(
          theQueue, MSG_SEL_COMPLEX_SQL_OR);
      QueueBrowser allBrowser = requestServerSession.createBrowser(theQueue);

      int withCount = getMessageCount(withPropertyBrowser, "withProperty ");
      int allCount = getMessageCount(allBrowser, "allMessages ");

      withPropertyBrowser.close();
      allBrowser.close();
     
      assertEquals("Expected withCount to be 0 but was "
          + withCount, 0, withCount);
      assertEquals("Expected allCount to be 0 but was "
          + allCount, 0, allCount);
View Full Code Here

                    MessageConsumer consumer = iter.next();
                    consumer.close();
                }

                for (Iterator<QueueBrowser> iter = browsers.iterator(); iter.hasNext();) {
                    QueueBrowser browser = iter.next();
                    browser.close();
                }

                if (transactional && !isXa) {
                    try {
                        getInternalSession().rollback();
View Full Code Here

      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerUri.toString());
      connection = connectionFactory.createConnection();
      connection.start();
      session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      Queue destination = session.createQueue(queueName);
      QueueBrowser browser = session.createBrowser(destination);
      List<Message> list = new ArrayList<Message>();
      for (Enumeration<Message> enumn = browser.getEnumeration(); enumn.hasMoreElements();) {
        list.add(enumn.nextElement());
      }
      messages = list.toArray();
    }
    finally {
View Full Code Here

        // Let the messages expire
        Thread.sleep(2000);

        // Simply browse the queue
        Session browserSession = createSession();
        QueueBrowser browser = browserSession.createBrowser((Queue) destination);
        assertFalse("no message in the browser", browser.getEnumeration().hasMoreElements());

        // The messages expire and should be reaped because of the presence of
        // the queue browser
        assertEquals("Wrong inFlightCount: " + view.getInFlightCount(), 0, view.getInFlightCount());
    }
View Full Code Here

        // Get the first.
        assertEquals(outbound[0], consumer.receive(1000));
        consumer.close();
        //Thread.sleep(200);

        QueueBrowser browser = session.createBrowser((Queue) destination);
        Enumeration enumeration = browser.getEnumeration();

        // browse the second
        assertTrue("should have received the second message", enumeration.hasMoreElements());
        assertEquals(outbound[1], (Message) enumeration.nextElement());

        // browse the third.
        assertTrue("Should have received the third message", enumeration.hasMoreElements());
        assertEquals(outbound[2], (Message) enumeration.nextElement());

        // There should be no more.
        boolean tooMany = false;
        while (enumeration.hasMoreElements()) {
            LOG.info("Got extra message: " + ((TextMessage) enumeration.nextElement()).getText());
            tooMany = true;
        }
        assertFalse(tooMany);
        browser.close();

        // Re-open the consumer.
        consumer = session.createConsumer(destination);
        // Receive the second.
        assertEquals(outbound[1], consumer.receive(1000));
View Full Code Here

       
        MessageProducer producer = session.createProducer(destination);
        producer.send(outbound[0]);
       
        // create browser first
        QueueBrowser browser = session.createBrowser((Queue) destination);
        Enumeration enumeration = browser.getEnumeration();
       
        // create consumer
        MessageConsumer consumer = session.createConsumer(destination);
       
        // browse the first message
        assertTrue("should have received the first message", enumeration.hasMoreElements());
        assertEquals(outbound[0], (Message) enumeration.nextElement());
       
        // Receive the first message.
        assertEquals(outbound[0], consumer.receive(1000));
        consumer.close();
        browser.close();
        producer.close();

    }
View Full Code Here

        for (int i=0; i<numMessages; i++) {
            TextMessage message = session.createTextMessage("Message: " + i);
            producer.send(message);  
        }
       
        QueueBrowser browser = session2.createBrowser(destinationPrefetch1);
        Enumeration<Message> browserView = browser.getEnumeration();
   
        List<Message> messages = new ArrayList<Message>();
        for (int i = 0; i < numMessages; i++) {
            Message m1 = consumer.receive(5000);
            assertNotNull("m1 is null for index: " + i, m1);
View Full Code Here

        producer.send(outbound[1]);
        producer.send(outbound[2]);


        // create browser first
        QueueBrowser browser = session.createBrowser((Queue) destination);
        Enumeration enumeration = browser.getEnumeration();


        // browse some messages
        assertEquals(outbound[0], (Message) enumeration.nextElement());
        assertEquals(outbound[1], (Message) enumeration.nextElement());
        //assertEquals(outbound[2], (Message) enumeration.nextElement());


        browser.close();

        // create consumer
        MessageConsumer consumer = session.createConsumer(destination);

        // Receive the first message.
View Full Code Here

       
        Connection c = new ActiveMQConnectionFactory("vm://localhost").createConnection("system", "manager");
        c.start();
       
        // browser consumer will force expriation check on addConsumer
        QueueBrowser browser = c.createSession(false, Session.AUTO_ACKNOWLEDGE).createBrowser(new ActiveMQQueue("TEST.Q"));
        assertTrue("no message in the q", !browser.getEnumeration().hasMoreElements());
       
        // verify dlq got the message, no security exception as brokers context is now used
        browser = c.createSession(false, Session.AUTO_ACKNOWLEDGE).createBrowser(new ActiveMQQueue("ActiveMQ.DLQ"))
        assertTrue("one message in the dlq", browser.getEnumeration().hasMoreElements());
    }
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.