Package javax.jms

Examples of javax.jms.MessageProducer


   {
      Connection conn = cf.createConnection();
     
      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
     
      MessageProducer prod = sess.createProducer(dest);
     
      MessageConsumer cons = sess.createConsumer(dest);
     
      conn.start();
     
      TextMessage tm = sess.createTextMessage("ref test");
     
      prod.send(tm);
     
      tm = (TextMessage)cons.receive(1000);
     
      assertNotNull(tm);
     
View Full Code Here


   {
      Connection conn = cf.createConnection();
     
      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
     
      MessageProducer prod = sess.createProducer(queue);
     
      //Make persistent to make sure message gets serialized
      prod.setDeliveryMode(DeliveryMode.PERSISTENT);
     
      MessageConsumer cons = sess.createConsumer(queue);
     
      TestMessage tm = new TestMessage(123, false);
     
      ObjectMessage om = sess.createObjectMessage();
     
      om.setObject(tm);
     
      conn.start();
     
      prod.send(om);
     
      ObjectMessage om2 = (ObjectMessage)cons.receive(1000);
     
      assertNotNull(om2);
     
View Full Code Here

         {
            try
            {
               int lastMessage = messageCount;
               Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
               MessageProducer producer = sess.createProducer((Destination)queue);

               for (int j = 0; j < 20; j++)
               {
                  producer.send(sess.createTextMessage("Message " + i + ", " + j));

                  if (j % 2 == 0)
                  {
                     log.debug("commit");
                     messagesProduced += (messageCount - lastMessage);
View Full Code Here

     
      Connection conn = cf.createConnection();

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

      MessageProducer prod = sess.createProducer(queue);

      prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

      final int NUM_MESSAGES = 1000;
     
      //send some messages
     
View Full Code Here

     
      Connection conn = cf.createConnection();

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

      MessageProducer prod = sess.createProducer(queue);

      prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

      final int NUM_MESSAGES = 100;
     
      //send some messages
      ArrayList payLoad = new ArrayList();
View Full Code Here

         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
        
         MessageConsumer cons = sess.createConsumer(topic, "name = 'Watt'");
         //MessageConsumer cons = sess.createConsumer(topic);
        
         MessageProducer prod = sess.createProducer(topic);
        
         relayers[i] = new Relayer(prod);
        
         cons.setMessageListener(relayers[i]);
      }
     
      for (int i = 0; i < numConsumers; i++)
      {
         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
        
         MessageConsumer cons = sess.createConsumer(topic, "name = 'Tim'");
        
         consumers[i] = new Consumer();
        
         cons.setMessageListener(consumers[i]);
      }
     
      conn.start();
     
      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
     
      MessageProducer prod = sess.createProducer(topic);
     
      prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
     
      for (int i = 0; i < numMessages; i++)
      {
         Message m = sess.createMessage();
        
         m.setStringProperty("name", "Watt");
        
         prod.send(m);
        
         if (i % 100 == 0)
         {
            log.info("sent " + i + " messages");
         }
View Full Code Here

    */
   public void testQueuePersistence() throws Exception
   {
      Connection conn = cf.createConnection();
      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      MessageProducer prod = sess.createProducer(queue);
      prod.setDeliveryMode(DeliveryMode.PERSISTENT);
     
      for (int i = 0; i < 10; i++)
      {
         TextMessage tm = sess.createTextMessage("message" + i);
         prod.send(tm);
      }
     
      conn.close();
     
      ServerManagement.stopServerPeer();
View Full Code Here

    */
   public void testMessageOrderPersistence_1() throws Exception
   {
      Connection conn = cf.createConnection();
      Session sessSend = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      MessageProducer prod = sessSend.createProducer(queue);
     
      TextMessage m0 = sessSend.createTextMessage("a");
      TextMessage m1 = sessSend.createTextMessage("b");
      TextMessage m2 = sessSend.createTextMessage("c");
      TextMessage m3 = sessSend.createTextMessage("d");
      TextMessage m4 = sessSend.createTextMessage("e");
      TextMessage m5 = sessSend.createTextMessage("f");
      TextMessage m6 = sessSend.createTextMessage("g");
      TextMessage m7 = sessSend.createTextMessage("h");
      TextMessage m8 = sessSend.createTextMessage("i");
      TextMessage m9 = sessSend.createTextMessage("j");
     
      prod.send(m0, DeliveryMode.PERSISTENT, 0, 0);
      prod.send(m1, DeliveryMode.PERSISTENT, 1, 0);
      prod.send(m2, DeliveryMode.PERSISTENT, 2, 0);
      prod.send(m3, DeliveryMode.PERSISTENT, 3, 0);
      prod.send(m4, DeliveryMode.PERSISTENT, 4, 0);
      prod.send(m5, DeliveryMode.PERSISTENT, 5, 0);
      prod.send(m6, DeliveryMode.PERSISTENT, 6, 0);
      prod.send(m7, DeliveryMode.PERSISTENT, 7, 0);
      prod.send(m8, DeliveryMode.PERSISTENT, 8, 0);
      prod.send(m9, DeliveryMode.PERSISTENT, 9, 0);
     
      conn.close();
     
      ServerManagement.stopServerPeer();

View Full Code Here

    */
   public void testMessageOrderPersistence_2() throws Exception
   {
      Connection conn = cf.createConnection();
      Session sessSend = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      MessageProducer prod = sessSend.createProducer(queue);
     
      TextMessage m0 = sessSend.createTextMessage("a");
      TextMessage m1 = sessSend.createTextMessage("b");
      TextMessage m2 = sessSend.createTextMessage("c");
      TextMessage m3 = sessSend.createTextMessage("d");
      TextMessage m4 = sessSend.createTextMessage("e");
      TextMessage m5 = sessSend.createTextMessage("f");
      TextMessage m6 = sessSend.createTextMessage("g");
      TextMessage m7 = sessSend.createTextMessage("h");
      TextMessage m8 = sessSend.createTextMessage("i");
      TextMessage m9 = sessSend.createTextMessage("j");

     
      prod.send(m0, DeliveryMode.PERSISTENT, 0, 0);
      prod.send(m1, DeliveryMode.PERSISTENT, 0, 0);
      prod.send(m2, DeliveryMode.PERSISTENT, 0, 0);
      prod.send(m3, DeliveryMode.PERSISTENT, 3, 0);
      prod.send(m4, DeliveryMode.PERSISTENT, 3, 0);
      prod.send(m5, DeliveryMode.PERSISTENT, 4, 0);
      prod.send(m6, DeliveryMode.PERSISTENT, 4, 0);
      prod.send(m7, DeliveryMode.PERSISTENT, 5, 0);
      prod.send(m8, DeliveryMode.PERSISTENT, 5, 0);
      prod.send(m9, DeliveryMode.PERSISTENT, 6, 0);
     
      conn.close();
     
      ServerManagement.stopServerPeer();

View Full Code Here

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

      MessageConsumer ds = s.createDurableSubscriber(thisTopic, "sub", null, false);

      MessageProducer p = s.createProducer(thisTopic);
      p.setDeliveryMode(DeliveryMode.PERSISTENT);
      TextMessage tm = s.createTextMessage("thebody");
      p.send(tm);
      log.debug("message sent");

      conn.close();

      log.debug("stopping the server");
View Full Code Here

TOP

Related Classes of javax.jms.MessageProducer

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.