Package javax.jms

Examples of javax.jms.MessageConsumer.receiveNoWait()


   
    // Waiting for the message to be expired.
    System.out.println("Waits for the message to be expired");
    Thread.sleep(100);

    msg = (TextMessage) consumer.receiveNoWait();
    System.out.println("receives: " + msg);
   
    // Producing "undeliverable" messages
    System.out.println("Send Message2");  
    msg = prodSession.createTextMessage("Message2");
View Full Code Here


            msgIn[i] = publisherSession.createTextMessage();
            msgIn[i].setText("msg " + i);
            publisher.send(this.topic, msgIn[i]);
         }
         for (int i=0; i < nmax; i++) {
            msg2 = consumer.receiveNoWait();
            if (!(msg2 instanceof TextMessage)) {
               assertTrue("received message if of wrong type, should be TextMessage but is '" + msg2.getClass().getName() + "'", false);
            }
            assertEquals("receive(): messages are not the same", msgIn[i].getText(), ((TextMessage)msg2).getText());        
         }
View Full Code Here

            if (!(msg2 instanceof TextMessage)) {
               assertTrue("received message if of wrong type, should be TextMessage but is '" + msg2.getClass().getName() + "'", false);
            }
            assertEquals("receive(): messages are not the same", msgIn[i].getText(), ((TextMessage)msg2).getText());        
         }
         msg2 = consumer.receiveNoWait();
         if (msg2 != null) {
            assertTrue("no message was sent, so null should have been returned here but it was " + msg.toString(), false);
         }
        
         // test receive(long)
View Full Code Here

         TextMessage t = (TextMessage)cons.receive(1000);
         assertNotNull(t);
         assertEquals("c", t.getText());
      }
      {
         TextMessage t = (TextMessage)cons.receiveNoWait();
         assertNull(t);
      }
     
      conn.close();
   }
View Full Code Here

         assertNotNull(m);
      }

      Thread.sleep(500);

      Message m = cons1.receiveNoWait();

      assertNull(m);

      sess.close();
   }
View Full Code Here

            Message m = cons1.receive(1000);

            assertNotNull(m);
         }

         Message m = cons1.receiveNoWait();

         assertNull(m);

         sess.close();
View Full Code Here

            Message m = cons1.receive(1000);

            assertNotNull(m);
         }

         Message m = cons1.receiveNoWait();

         assertNull(m);

         sess.close();
View Full Code Here

         session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageConsumer consumer = session.createConsumer(queue);
         Message m = null;
         do
         {
            m = consumer.receiveNoWait();
         }
         while(m != null);
      }
      finally
      {
View Full Code Here

            assertNull(sessionRunnable.error);

            // Drain the queue
            QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
            MessageConsumer consumer = session.createConsumer(queue);
            while (consumer.receiveNoWait() != null);
            session.close();
         }
      }
      finally
      {
View Full Code Here

            assertNull(sessionRunnable.error);

            // Drain the queue
            QueueSession session = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
            MessageConsumer consumer = session.createConsumer(queue);
            while (consumer.receiveNoWait() != null);
            session.close();
         }
      }
      finally
      {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.