Package javax.jms

Examples of javax.jms.QueueBrowser


     */
    private void browserCloseWhileFailoverImpl(int acknowledgeMode) throws JMSException
    {
        setDelayedFailoverPolicy();

        QueueBrowser browser = prepareQueueBrowser(acknowledgeMode);

        @SuppressWarnings("unchecked")
        Enumeration<Message> messages = browser.getEnumeration();
        Message receivedMessage = (Message) messages.nextElement();
        assertReceivedMessage(receivedMessage, TEST_MESSAGE_FORMAT, 0);

        failBroker(getFailingPort());

        browser.close();

        assertFailoverException();
    }
View Full Code Here


        // Browse queue
        try {
            String selector = null;
            Queue q = session.createQueue(name);
            QueueBrowser qb;
      if (selector == null) {
                qb = session.createBrowser(q);
      } else {
                qb = session.createBrowser(q, selector);
      }
            // Load messages into table
            MsgTable mt = (MsgTable)msgTable.getModel();
            int n = mt.load(qb.getEnumeration());
            setFooter(name + ": " + String.valueOf(n));
            qb.close();
        } catch (JMSException ex) {
            setFooter(ex.getMessage());
        }
    }
View Full Code Here

            Queue queue = (Queue) getDestination(portletRequest, jmsDestinationInfo);
            List<JMSMessageInfo> messages = new LinkedList<JMSMessageInfo>();
            connection = connectionFactory.createConnection();
            connection.start();
            Session session = connection.createSession(false, QueueSession.AUTO_ACKNOWLEDGE);
            QueueBrowser qBrowser = session.createBrowser(queue);
            for (Enumeration e = qBrowser.getEnumeration(); e.hasMoreElements();) {
                Message message = (Message) e.nextElement();
                JMSMessageInfo messageInfo = new JMSMessageInfo();
                messageInfo.setPriority(message.getJMSPriority());
                messageInfo.setMessageId(message.getJMSMessageID());
                messageInfo.setDestination(message.getJMSDestination().toString());
View Full Code Here

            if (dest instanceof Queue) {
                Queue queue = (Queue) dest;
                QueueConnectionFactory qConFactory = null;
                QueueConnection qConnection = null;
                QueueSession qSession = null;
                QueueBrowser qBrowser = null;
                try {
                    qConFactory = (QueueConnectionFactory) kernel.invoke(
                            JCA_MANAGED_CONNECTION_FACTORY_NAME,
                            "$getResource");
                    qConnection = qConFactory.createQueueConnection();
                    qSession = qConnection.createQueueSession(false,
                            QueueSession.AUTO_ACKNOWLEDGE);
                    qBrowser = qSession.createBrowser(queue);
                    qConnection.start();
                    for (Enumeration e = qBrowser.getEnumeration(); e
                            .hasMoreElements();) {
                        Object o = e.nextElement();
                        ret.add(o);
                    }
                    qConnection.stop();
                } catch (Exception e) {
                    log.error(e.getMessage(), e);
                } finally {
                    try {
                        if (qBrowser != null) {
                            qBrowser.close();
                        }
                    } catch (JMSException ignore) {
                    }
                    try {
                        if (qSession != null) {
View Full Code Here

        return browsedMessage;
    }


    protected int browseMessages(String broker, Destination dest) throws Exception {
        QueueBrowser browser = createBrowser(broker, dest);
        int browsedMessage = browseMessages(browser, "browser");
        browser.close();
        return browsedMessage;
    }
View Full Code Here

        public void run() {
            int retries = 0;
            while (retries++ < 5) {
                try {
                    QueueBrowser browser = createBrowser(broker, dest);
                    int count  = browseMessages(browser, broker);
                    if (consume) {
                        if (count != 0) {
                            MessageConsumer consumer = createSyncConsumer(broker, dest);
                            totalCount += count;
                            for (int i = 0; i < count; i++) {
                                ActiveMQTextMessage message = (ActiveMQTextMessage)consumer.receive(1000);
                                LOG.info(broker + " consumer: " + message.getText() + " " + message.getDestination() " " + message.getMessageId() + " " + Arrays.toString(message.getBrokerPath()));
                                if (message == null) break;
                            }
                        }
                    } else {
                        totalCount = count;
                    }
                    LOG.info("browser '" + broker + "' browsed " + totalCount);

                    Thread.sleep(1000);
                } catch (Exception e) {
                    LOG.info("Exception browsing " + e, e);
                } finally {
                    try {
                        if (browser != null) {
                            browser.close();
                        }
                        if (consumer != null) {
                            consumer.close();
                        }
                    } catch (Exception e) {
View Full Code Here

        if (acknowledgeMode == Session.SESSION_TRANSACTED)
        {
            _producerSession.commit();
        }

        QueueBrowser browser = _consumerSession.createBrowser((Queue) _destination);
        return browser;
    }
View Full Code Here

     * @param acknowledgeMode session acknowledge mode
     * @throws JMSException
     */
    private void browserCloseWhileFailoverImpl(int acknowledgeMode) throws Exception
    {
        QueueBrowser browser = prepareQueueBrowser(acknowledgeMode);

        @SuppressWarnings("unchecked")
        Enumeration<Message> messages = browser.getEnumeration();
        Message receivedMessage = (Message) messages.nextElement();
        assertReceivedMessage(receivedMessage, TEST_MESSAGE_FORMAT, 0);

        failBroker(getFailingPort());

        // wait until failover is started
        _failoverStarted.await(5, TimeUnit.SECONDS);

        browser.close();

        assertTrue("Failover has not completed yet but browser was closed", _failoverComplete.await(5, TimeUnit.SECONDS));

        assertFailoverException();
    }
View Full Code Here

      if (HornetQRASession.trace)
      {
         HornetQRASession.log.trace("createBrowser " + session + " queue=" + queue);
      }

      QueueBrowser result = session.createBrowser(queue);

      if (HornetQRASession.trace)
      {
         HornetQRASession.log.trace("createdBrowser " + session + " browser=" + result);
      }
View Full Code Here

      if (HornetQRASession.trace)
      {
         HornetQRASession.log.trace("createBrowser " + session + " queue=" + queue + " selector=" + messageSelector);
      }

      QueueBrowser result = session.createBrowser(queue, messageSelector);

      if (HornetQRASession.trace)
      {
         HornetQRASession.log.trace("createdBrowser " + session + " browser=" + result);
      }
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.