Package javax.jms

Examples of javax.jms.TemporaryQueue



   public void testTemporaryQueueBasic() throws Exception
   {

      TemporaryQueue tempQueue = producerSession.createTemporaryQueue();

      MessageProducer producer = producerSession.createProducer(tempQueue);

      MessageConsumer consumer = consumerSession.createConsumer(tempQueue);
View Full Code Here


   public void testTemporaryQueueDeleted() throws Exception
   {
      //Make sure temporary queue cannot be used after it has been deleted

      TemporaryQueue tempQueue = producerSession.createTemporaryQueue();

      MessageProducer producer = producerSession.createProducer(tempQueue);

      MessageConsumer consumer = consumerSession.createConsumer(tempQueue);

      connection.start();

      final String messageText = "This is a message";

      Message m = producerSession.createTextMessage(messageText);

      producer.send(m);

      TextMessage m2 = (TextMessage)consumer.receive(2000);

      assertNotNull(m2);

      assertEquals(messageText, m2.getText());

      consumer.close();

      tempQueue.delete();

      try
      {
         producer.send(m);
         fail();
View Full Code Here

           
         }
        
         //Create a temp queue
        
         TemporaryQueue tempQueue = sess.createTemporaryQueue();
        
         counters = (List)
         ServerManagement.getAttribute(ServerManagement.getServerPeerObjectName(), "MessageCounters");
     
         assertNotNull(counters);
     
         //Should now be 7
         assertEquals(7, counters.size());
        
         //Send some messages
        
         MessageProducer prod = sess.createProducer(null);
        
         TextMessage tm1 = sess.createTextMessage("message1");
        
         TextMessage tm2 = sess.createTextMessage("message2");
        
         TextMessage tm3 = sess.createTextMessage("message3");
        
         prod.send(queue1, tm1);        
         prod.send(queue1, tm2);        
         prod.send(queue1, tm3);
        
         prod.send(queue2, tm1);        
         prod.send(queue2, tm2);        
         prod.send(queue2, tm3);
        
         prod.send(queue3, tm1);        
         prod.send(queue3, tm2);        
         prod.send(queue3, tm3);
        
         prod.send(tempQueue, tm1);        
         prod.send(tempQueue, tm2);        
         prod.send(tempQueue, tm3);
        
         prod.send(topic1, tm1);        
         prod.send(topic1, tm2);        
         prod.send(topic1, tm3);
        
         prod.send(topic2, tm1);        
         prod.send(topic2, tm2);        
         prod.send(topic2, tm3);
        
         iter = counters.iterator();
        
         //Wait until the stats are updated
         Thread.sleep(1500);
        
         while (iter.hasNext())
         {
            MessageCounter counter = (MessageCounter)iter.next();
           
            assertEquals(3, counter.getCount());
           
            assertEquals(3, counter.getCountDelta());
           
            assertEquals(-1, counter.getHistoryLimit());
           
         }
        
         while (iter.hasNext())
         {
            MessageCounter counter = (MessageCounter)iter.next();
               
            assertEquals(3, counter.getCount());
           
            assertEquals(0, counter.getCountDelta());
           
            assertEquals(-1, counter.getHistoryLimit());
           
         }
           
         ServerManagement.invoke(ServerManagement.getServerPeerObjectName(), "resetAllMessageCounters", null, null);
        
         ServerManagement.invoke(ServerManagement.getServerPeerObjectName(), "resetAllMessageCounterHistories", null, null);
        
        
         while (iter.hasNext())
         {
            MessageCounter counter = (MessageCounter)iter.next();
           
            assertEquals(0, counter.getCount());
           
            assertEquals(0, counter.getCountDelta());
           
            assertEquals(-1, counter.getHistoryLimit());           
         }
        
         String html = (String)ServerManagement.invoke(ServerManagement.getServerPeerObjectName(), "listMessageCountersAsHTML", null, null);
        
         assertNotNull(html);
        
         while (iter.hasNext())
         {
            MessageCounter counter = (MessageCounter)iter.next();

            assertTrue(html.indexOf(counter.getDestinationName()) != -1);          
         }
        
         List stats = (List)ServerManagement.getAttribute(ServerManagement.getServerPeerObjectName(), "MessageStatistics");
        
         assertNotNull(stats);
        
         assertEquals(7, stats.size());
        
         iter = stats.iterator();
        
         while (iter.hasNext())
         {
            MessageStatistics stat = (MessageStatistics)iter.next();
           
            assertEquals(0, stat.getCount());
           
            assertEquals(0, stat.getCountDelta());
           
            assertEquals(3, stat.getDepth());
           
            assertEquals(0, stat.getDepthDelta());  
         }
        
         cons1.close();
         cons2.close();
         cons3.close();
         sess.unsubscribe("sub1");
        
         counters = (List)
         ServerManagement.getAttribute(ServerManagement.getServerPeerObjectName(), "MessageCounters");
     
         assertNotNull(counters);
     
         assertEquals(4, counters.size());
                 
         tempQueue.delete();
        
        
         counters = (List)
         ServerManagement.getAttribute(ServerManagement.getServerPeerObjectName(), "MessageCounters");
     
View Full Code Here

      getLog().debug("Starting TemporaryQueueDelete test");
      connect();

      QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      TemporaryQueue queue = session.createTemporaryQueue();

      queue.delete();

      disconnect();

      getLog().debug("TemporaryQueueDelete passed");
   }
View Full Code Here

      getLog().debug("Starting InvaidDestinationQueueSend test");
      connect();

      QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      TemporaryQueue queue = session.createTemporaryQueue();
      QueueSender sender = session.createSender(queue);
      queue.delete();

      TextMessage message = session.createTextMessage("hello");
      boolean caught = false;
      try
      {
View Full Code Here

      getLog().debug("Starting InvalidDestinationQueueBrowse test");
      connect();

      QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      TemporaryQueue queue = session.createTemporaryQueue();
      QueueBrowser browser = session.createBrowser(queue);
      queue.delete();

      boolean caught = false;
      try
      {
         browser.getEnumeration();
View Full Code Here

      getLog().debug("Starting TemporaryQueueDelete test");
      connect();

      Session session = queueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      TemporaryQueue queue = session.createTemporaryQueue();

      queue.delete();

      disconnect();

      getLog().debug("TemporaryQueueDelete passed");
   }
View Full Code Here

      getLog().debug("Starting InvalidDestinationQueueBrowse test");
      connect();

      Session session = queueConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      TemporaryQueue queue = session.createTemporaryQueue();
      QueueBrowser browser = session.createBrowser(queue);
      queue.delete();

      boolean caught = false;
      try
      {
         browser.getEnumeration();
View Full Code Here

   {
      ConnectionFactory connFactory = lookup("ConnectionFactory", ConnectionFactory.class);
      Connection conn = connFactory.createConnection();
      conn.start();
      Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      TemporaryQueue replyQueue = session.createTemporaryQueue();
      TextMessage msg = session.createTextMessage("Hello world");
      msg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
      msg.setJMSReplyTo(replyQueue);
      Queue queue = lookup("queue/mdbtest", Queue.class);
      MessageProducer producer = session.createProducer(queue);
View Full Code Here

      {
         try
         {
            Queue queue = (Queue)context.lookup(TEST_QUEUE);
            QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
            TemporaryQueue temp = session.createTemporaryQueue();
            Message message = session.createTextMessage();
            message.setJMSReplyTo(temp);

            QueueSender sender = session.createSender(queue);
            sender.send(message);

            QueueReceiver receiver = session.createReceiver(temp);
            if (receiver.receive(2000) == null)
            {
               state.addError(new Exception("Didn't receive message"));
            }
            receiver.close();
            temp.delete();
           
            session.close();
         }
         catch (Throwable t)
         {
View Full Code Here

TOP

Related Classes of javax.jms.TemporaryQueue

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.