Package javax.jms

Examples of javax.jms.Message


         sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);

         cons = sess.createConsumer(queue[1]);

         Message m = cons.receive(500);

         assertNull(m);

         log.info("got to end of test");
      }
View Full Code Here


      log.info("subscriptionName=" + consumerState.getSubscriptionName());

      log.info(">>Creating Producer");
      MessageProducer producer = session.createProducer(destination);
      log.info(">>creating Message");
      Message message = session.createTextMessage("Hello Before");
      log.info(">>sending Message");
      producer.send(message);
      session.commit();

      receiveMessage("consumerHA", consumerHA, true, false);
View Full Code Here

      try
      {
         Session ps = pconn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         Session cs = cconn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageConsumer c2 = cs.createConsumer(topic2);
         final Message m1 = ps.createMessage();

         cconn.start();

         final MessageProducer anonProducer = ps.createProducer(null);

         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);
                  anonProducer.send(topic2, m1);
               }
               catch(Exception e)
               {
                  log.error(e);
               }
            }
         }, "Producer Thread").start();

         Message m2 = c2.receive(3000);
         assertEquals(m1.getJMSMessageID(), m2.getJMSMessageID());

         log.debug("ending test");
      }
      finally
      {
View Full Code Here

         // send a message that is not created by the session

         cconn.start();

         Message m = new SimpleJMSTextMessage("something");
         p.send(m);        

         TextMessage rec = (TextMessage)c.receive(3000);
        
         assertEquals("something", rec.getText());
View Full Code Here

         p.setDisableMessageTimestamp(true);
         assertTrue(p.getDisableMessageTimestamp());

         p.send(ps.createMessage());

         Message m = c.receive(3000);

         assertEquals(0l, m.getJMSTimestamp());

         p.setDisableMessageTimestamp(false);
         assertFalse(p.getDisableMessageTimestamp());

         long t1 = System.currentTimeMillis();

         p.send(ps.createMessage());

         m = c.receive(3000);

         long t2 = System.currentTimeMillis();
         long timestamp = m.getJMSTimestamp();

         assertTrue(timestamp >= t1);
         assertTrue(timestamp <= t2);
      }
      finally
View Full Code Here

        
         now2 = System.currentTimeMillis();
        
         assertTrue(now2 - now >= 7000);
        
         Message m = cons.receive(1000);
        
         assertNull(m);
      }
      finally
      {
View Full Code Here

        
         now2 = System.currentTimeMillis();
        
         assertTrue(now2 - now >= 7000);
        
         Message m = cons.receive(1000);
        
         assertNull(m);
      }
      finally
      {
View Full Code Here

         public void run()
         {
            try
            {
               long start = System.currentTimeMillis();
               Message m = consumer.receive(2100);
               if (System.currentTimeMillis() - start >= 2000)
               {
                  //It timed out
                  failed = "Timed out";
               }
View Full Code Here

               sess2.recover();
            }
           
            //At this point all the messages have been delivered exactly MAX_DELIVERIES times
           
            Message m = cons.receive(1000);
           
            assertNull(m);
           
            //Now should be in default dlq
           
            MessageConsumer cons3 = sess.createConsumer(defaultDLQ);
           
            for (int i = 0; i < NUM_MESSAGES; i++)
            {
               TextMessage tm = (TextMessage)cons3.receive(1000);
  
               assertNotNull(tm);
  
               assertEquals("Message:" + i, tm.getText());
            }
           
            conn.close();
         }
        
        
         {
            //Now try with overriding the default dlq
           
            conn = cf.createConnection();
           
            ServerManagement.setAttribute(new ObjectName(testQueueObjectName), "DLQ", overrideDLQObjectName);
           
            Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
  
            MessageProducer prod = sess.createProducer(testQueue);
  
            for (int i = 0; i < NUM_MESSAGES; i++)
            {
               TextMessage tm = sess.createTextMessage("Message:" + i);
  
               prod.send(tm);
            }
  
            Session sess2 = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
           
            MessageConsumer cons = sess2.createConsumer(testQueue);
           
            conn.start();
  
            for (int i = 0; i < MAX_DELIVERIES; i++)
            {
               for (int j = 0; j < NUM_MESSAGES; j++)
               {
                  TextMessage tm = (TextMessage)cons.receive(1000);
  
                  assertNotNull(tm);
  
                  assertEquals("Message:" + j, tm.getText());
               }
  
               sess2.recover();
            }
           
            //At this point all the messages have been delivered exactly MAX_DELIVERIES times
           
            Message m = cons.receive(1000);
           
            assertNull(m);
           
            //Now should be in override dlq
           
View Full Code Here

         //At this point all the messages have been delivered exactly MAX_DELIVERIES times - this is ok
         //they haven't exceeded max delivery attempts so shouldn't be in the DLQ - let's check
        
         MessageConsumer cons3 = sess.createConsumer(dlq);
        
         Message m = cons3.receive(1000);
        
         assertNull(m);
        
         // So let's try and consume them - this should cause them to go to the DLQ - since they
         // will then exceed max delivery attempts
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.