Package javax.jms

Examples of javax.jms.QueueBrowser


         {
            // Nah...
         }
      }

      QueueBrowser browser = null;

      try
      {
         if (isRunning())
         {
            Hermes.ui.getDefaultMessageSink().add(getTitle() + "...") ;
           
            Destination targetDestination = null;

            if (targetDestinationConfig != null)
            {
               targetDestination = hermes.getDestination(targetDestinationConfig.getName(), Domain.getDomain(targetDestinationConfig.getDomain()));
            }

            final MessageStore.HeaderPolicy headerPolicy = targetDestination == null ? MessageStore.HeaderPolicy.DESTINATION_ONLY
                  : MessageStore.HeaderPolicy.NO_HEADER;
            browser = (sourceDestination == null) ? messageStore.visit(hermes, headerPolicy) : messageStore.visit(hermes, sourceDestination, headerPolicy);

            for (Enumeration iter = browser.getEnumeration(); iter.hasMoreElements() && isRunning();)
            {
               final Message message = (Message) iter.nextElement();

               if (message != null)
               {
View Full Code Here


    * @see hermes.browser.tasks.Task#run()
    */
   public void invoke() throws Exception
   {
      int nmessages = 0;
      QueueBrowser browser = null;
     
     
     
      try
      {      
         if (destination == null)
         {
            if (hermes == null)
            {
               browser = messageStore.visit();
            }
            else
            {
               browser = messageStore.visit(hermes, MessageStore.HeaderPolicy.MESSAGEID_AND_DESTINATION);
            }
         }
         else
         {
            if (hermes == null)
            {
               browser = messageStore.visit(destination);
            }
            else
            {
               browser = messageStore.visit(hermes, destination, MessageStore.HeaderPolicy.MESSAGEID_AND_DESTINATION);
            }
         }

        
         for  (Enumeration iter = browser.getEnumeration() ; iter.hasMoreElements() && isRunning() ;)
         {
            final Message m = (Message) iter.nextElement();
        
            if (m != null)
            {
View Full Code Here

         }) ;
        
         Hermes.ui.getDefaultMessageSink().add(getTitle()) ;
        
         final Destination d = hermes.getDestination(node.getDestinationName(), node.getDomain());
         final QueueBrowser browser = hermes.createBrowser(node.getConfig());

         for (Enumeration iter = browser.getEnumeration(); iter.hasMoreElements() && isRunning();)
         {
            Message m = (Message) iter.nextElement();

            if (m != null)
            {
               messageStore.store(m);
               messageStore.checkpoint();
            }
         }

         messageStore.checkpoint();
         browser.close();
         hermes.close();
      }
      finally
      {
         Hermes.ui.getDefaultMessageSink().add("Finished recording " + node.getDestinationName() + " into " + messageStore.getId()) ;
View Full Code Here

        Session session = connection.createSession(false, Session.SESSION_TRANSACTED);
        destination = createDestination(session, destinationType);
        sendMessages(session, destination, 5);

       
        QueueBrowser browser = session.createBrowser((Queue) destination);
        Enumeration enumeration = browser.getEnumeration();
        for(int i=0; i < 5; i++) {
            Thread.sleep(100);
            assertTrue(enumeration.hasMoreElements());
            Message m = (Message)enumeration.nextElement();
            assertNotNull(m);
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

            Queue queue = getQueue(request, session);
            if (queue == null) {
                throw new ServletException("No queue URI specified");
            }
            String selector = getSelector(request);
            QueueBrowser browser = session.createBrowser(queue, selector);
            MessageRenderer renderer = getMessageRenderer(request);
            configureRenderer(request, renderer);
            renderer.renderMessages(request, response, browser);
        }
        catch (JMSException e) {
View Full Code Here

            consumer.close();
        }
        consumers.clear();
       
        for (Iterator iter = browsers.iterator(); iter.hasNext();) {
            QueueBrowser browser = (QueueBrowser) iter.next();
            browser.close();
        }
        browsers.clear();

        // maybe do a rollback?
        if (transactional) {
View Full Code Here

     */
    public int getDepth(DestinationConfig dest) throws JMSException
    {
        if (dest.getDomain() == Domain.QUEUE.getId())
        {
            final QueueBrowser browser = getHermes().createBrowser(dest);
            int depth = 0;

            try
            {
                for (Enumeration iter = browser.getEnumeration(); iter.hasMoreElements();)
                {
                    iter.nextElement();
                    depth++;

                    if ( depth > maxSize)
                    {
                        throw new HermesException("The default admin provider only implements queue depth functionality up to " + maxSize + " messages");
                    }
                }
            }
            finally
            {
                browser.close();
            }

            return depth;
        }
        else
View Full Code Here

            signature = new String[] { String.class.getName(), String.class.getName(), String.class.getName() };
         }

         final Collection messages = (Collection) getRMIAdapter().invoke(objectName, "listDurableMessages", params, signature);

         return new QueueBrowser (){
        
            public void close() throws JMSException
            {
               // TODO Auto-generated method stub              
            }
View Full Code Here

  }

  public long getAge(DestinationConfig dest) throws JMSException {
    long rval = 0;

    QueueBrowser browser = hermes.createBrowser(dest);
    Enumeration iter = browser.getEnumeration();

    if (iter.hasMoreElements()) {
      Message topMessage = (Message) iter.nextElement();

      if (topMessage != null) {
        rval = topMessage.getJMSTimestamp();
      }
    }

    browser.close();

    return rval;
  }
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.