Package javax.jms

Examples of javax.jms.Message


   public void testSendMessageAndCloseConsumer1() throws Exception
   {
      // setUp() created a consumer already

      Message m = producerSession.createMessage();
      queueProducer.send(m);

      queueConsumer.close();

      // since no message was received, we expect the message back in the queue

      queueConsumer = consumerSession.createConsumer(queue);

      consumerConnection.start();

      Message r = queueConsumer.receive(3000);
      assertEquals(m.getJMSMessageID(), r.getJMSMessageID());
   }
View Full Code Here


          MessageConsumer cons2 = sess.createConsumer(queue);

          log.trace("cons2 created");

          Message r1 = cons2.receive();
          Message r2 = cons2.receive();
          Message r3 = cons2.receive();

          //Messages should be received?
          assertNotNull(r1);
          assertNotNull(r2);
          assertNotNull(r3);
View Full Code Here

         MessageProducer prod = sessSend.createProducer(null);

         prod.setDeliveryMode(DeliveryMode.PERSISTENT);

         Message m = sessSend.createTextMessage("hello");

         prod.send(queue2, m);

         sessSend.commit();
View Full Code Here

      MessageProducer prod = prodSession.createProducer(topic);
      prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

      for (int i = 0; i < NUM_MESSAGES; i++)
      {
         Message m = prodSession.createTextMessage("testing");
         prod.send(m);
         log.trace("Sent message to topic");
      }

      t1.join();
View Full Code Here


   public void testReceiveOnTopicTimeoutNoMessage() throws Exception
   {
      if (log.isTraceEnabled()) log.trace("testReceiveOnTopicTimeoutNoMessage");
      Message m = topicConsumer.receive(1000);
      assertNull(m);
   }
View Full Code Here

   public void testReceiveOnTopicConnectionStopped() throws Exception
   {
      if (log.isTraceEnabled()) log.trace("testReceiveOnTopicConnectionStopped");
      consumerConnection.stop();

      final Message m = producerSession.createMessage();
      new Thread(new Runnable()
      {
         public void run()
         {
            try
View Full Code Here

   public void testReceiveOnTopicTimeout() throws Exception
   {
      if (log.isTraceEnabled()) log.trace("testReceiveOnTopicTimeout");
      consumerConnection.start();

      final Message m1 = producerSession.createMessage();
      new Thread(new Runnable()
      {
         public void run()
         {
            try
            {
               // this is needed to make sure the main thread has enough time to block
               Thread.sleep(1000);
               topicProducer.send(m1);
            }
            catch(Exception e)
            {
               log.error(e);
            }
         }
      }, "Producer").start();

      Message m2 = topicConsumer.receive(1500);
      assertEquals(m1.getJMSMessageID(), m2.getJMSMessageID());
   }
View Full Code Here

   public void testReceiveOnTopic() throws Exception
   {
      if (log.isTraceEnabled()) log.trace("testReceiveOnTopic");
      consumerConnection.start();

      final Message m1 = producerSession.createMessage();
      new Thread(new Runnable()
      {
         public void run()
         {
            try
            {
               // this is needed to make sure the main thread has enough time to block
               Thread.sleep(1000);
               topicProducer.send(m1);
            }
            catch(Exception e)
            {
               log.error(e);
            }
         }
      }, "Producer").start();

      Message m2 = topicConsumer.receive(3000);

      if (log.isTraceEnabled()) log.trace("m1:" + m1 + ", m2:" + m2) ;

      assertEquals(m1.getJMSMessageID(), m2.getJMSMessageID());
   }
View Full Code Here

   public void testReceiveNoWaitOnTopic() throws Exception
   {
      consumerConnection.start();

      Message m = topicConsumer.receiveNoWait();

      assertNull(m);

      Message m1 = producerSession.createMessage();
      topicProducer.send(m1);

      // block this thread for a while to allow ServerConsumerDelegate's delivery thread to kick in
      Thread.sleep(500);

      m = topicConsumer.receiveNoWait();

      assertEquals(m1.getJMSMessageID(), m.getJMSMessageID());
   }
View Full Code Here

               Thread.sleep(1000);


               for (int i = 0; i < count; i++)
               {
                  Message m = producerSession.createMessage();
                  queueProducer.send(m);
               }
            }
            catch(Exception e)
            {
               log.error(e);
            }
         }
      }, "ProducerTestThread").start();

      int received = 0;
      while(true)
      {
         Message m = queueConsumer.receive(1500);
         if (m == null)
         {
            break;
         }
         //Thread.sleep(1000);
View Full Code Here

TOP

Related Classes of javax.jms.Message

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.