Package javax.jms

Examples of javax.jms.QueueSession


   {

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

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

      queue.delete();

      disconnect();
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
      {
         sender.send(message);
      }
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
      {
View Full Code Here

   {

      getLog().debug("Starting create queue test");
      connect();

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

      Queue jndiQueue = (Queue) getInitialContext().lookup("queue/testQueue");
      Queue createQueue = session.createQueue(jndiQueue.getQueueName());
      assertTrue("Failed for " + QUEUE_FACTORY, jndiQueue.equals(createQueue));

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

      connect();
      queueConnection.start();
      drainQueue();
      final CountDown counter1 = new CountDown(3);

      QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      Queue queue = (Queue) context.lookup(TEST_QUEUE);

      QueueReceiver receiver = session.createReceiver(queue);
      receiver.setMessageListener(new MessageListener()
      {
         public void onMessage(Message msg)
         {
            Logger log = Logger.getLogger(getClass().getName());
            log.debug("ML");
            try
            {
               if (msg instanceof TextMessage)
               {
                  log.debug(((TextMessage) msg).getText());
                  counter1.release();
               }
            }
            catch (Exception e)
            {
            }
         }
      });

      QueueSender sender = session.createSender(queue);

      TextMessage message = session.createTextMessage();
      message.setText("Normal message");
      sender.send(message, DeliveryMode.NON_PERSISTENT, 4, 0);
      //sender.send(queue, message, DeliveryMode.NON_PERSISTENT, 4, 0);
      message.setText("Persistent message");
      sender.send(message, DeliveryMode.PERSISTENT, 4, 0);
View Full Code Here

   {
      getLog().debug("Starting testing app server stuff");
      connect();

      Queue testQueue = (Queue) context.lookup(TEST_QUEUE);
      final QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

      session.setMessageListener(new MessageListener()
      {
         public void onMessage(Message mess)
         {
            Logger log = Logger.getLogger(getClass().getName());
            log.debug("Processing message");
            try
            {
               if (mess instanceof TextMessage)
                  log.debug(((TextMessage) mess).getText());
            }
            catch (Exception e)
            {
               log.error("Error", e);
            }
         }
      });

      QueueSender sender = session.createSender(testQueue);
      sender.send(session.createTextMessage("Hi"));
      sender.send(session.createTextMessage("There"));
      sender.send(session.createTextMessage("Guys"));
      queueConnection.createConnectionConsumer(testQueue, null, new ServerSessionPool()
      {
         public ServerSession getServerSession()
         {
            Logger.getLogger(getClass().getName()).debug("Getting server session.");
            return new ServerSession()
            {
               public Session getSession()
               {
                  return session;
               }
               public void start()
               {
                  Logger.getLogger(getClass().getName()).debug("Starting server session.");
                  session.run();
               }
            };
         }
      }, 10);
View Full Code Here

      {
         queueConnection.start();
         drainQueue();
         queueConnection.stop();

         QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
         Queue queue = (Queue) context.lookup(TEST_QUEUE);
         QueueSender sender = session.createSender(queue);
         QueueReceiver receiver = session.createReceiver(queue);

         // Send a message that has expired
         TextMessage message = session.createTextMessage("Outdated");
         sender.send(message, DeliveryMode.PERSISTENT, 4, 1);
         Thread.sleep(100);

         // Send a message that has not expired
         message = session.createTextMessage("OK");
         sender.send(message);

         // Try to receive the message the not expired message
         queueConnection.start();
         message = (TextMessage) receiver.receiveNoWait();
View Full Code Here

      try
      {
         queueConnection.start();
         drainQueue();

         QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
         Queue queue = (Queue) context.lookup(TEST_QUEUE);
         QueueSender sender = session.createSender(queue);
         QueueReceiver receiver = session.createReceiver(queue);

         // Send a message that expires in 5 seconds
         TextMessage message = session.createTextMessage("5 Second Expiration");
         sender.send(message, DeliveryMode.PERSISTENT, 4, 5*1000);
         // Send a message that has not expired
         message = session.createTextMessage("OK");
         sender.send(message);
         // Sleep 6 seconds
         Thread.sleep(6*1000);
         // Try to receive the OK message
         message = (TextMessage) receiver.receiveNoWait();
         assertEquals("OK", message.getText());

         // Should be no more
         assertTrue("Didn't expect anymore messages", receiver.receiveNoWait() == null);

         // Send a message that expires in 10 seconds
         message = session.createTextMessage("10 Second Expiration");
         sender.send(message, DeliveryMode.PERSISTENT, 4, 10*1000);
         // Send a message that has not expired
         message = session.createTextMessage("OK");
         sender.send(message);
         // Sleep 1 seconds
         Thread.sleep(1*1000);
         // Try to receive the messages
         message = (TextMessage) receiver.receiveNoWait();
         assertEquals("10 Second Expiration", message.getText());
         message = (TextMessage) receiver.receiveNoWait();
         assertEquals("OK", message.getText());

         // Should be no more
         assertTrue("Didn't expect anymore messages", receiver.receiveNoWait() == null);
        
         // Test that JMSExpiration has no affect
         message = session.createTextMessage("5 Second Expiration");
         message.setJMSExpiration(System.currentTimeMillis() + 5*1000);
         sender.send(message, DeliveryMode.PERSISTENT, 4, 0);
         // Send a message that has not expired
         message = session.createTextMessage("OK");
         sender.send(message);
         // Sleep 6 seconds
         Thread.sleep(6*1000);
         // Try to receive the OK message
         message = (TextMessage) receiver.receiveNoWait();
View Full Code Here

      {
         queueConnection.start();
         drainQueue();
         queueConnection.stop();

         QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
         Queue queue = (Queue) context.lookup(TEST_QUEUE);
         QueueSender sender = session.createSender(queue);
         QueueReceiver receiver = session.createReceiver(queue);

         // Send a message that has expired
         TextMessage message = session.createTextMessage("Outdated");
         sender.send(message, DeliveryMode.PERSISTENT, 4, 1);
         Thread.sleep(100);

         // Send a message that has not expired
         message = session.createTextMessage("OK");
         sender.send(message);

         // Try to receive the message the not expired message
         final Synch synch = new Synch();
         MessageListener messagelistener = new MessageListener()
View Full Code Here

   // Emptys out all the messages in a queue
   private void drainQueue() throws Exception
   {

      QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      Queue queue = (Queue)context.lookup(TEST_QUEUE);

      QueueReceiver receiver = session.createReceiver(queue);
      Message message = receiver.receive(50);
      int c = 0;
      while (message != null)
      {
         message = receiver.receive(50);
         c++;
      }

      if (c != 0)
      {
         getLog().debug("  Drained " + c + " messages from the queue");
      }

      session.close();

   }
View Full Code Here

TOP

Related Classes of javax.jms.QueueSession

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.