Package javax.jms

Examples of javax.jms.MessageProducer


      {
        
         conn = cf.createConnection();
  
         Session producerSess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
         MessageProducer producer = producerSess.createProducer(queue);
  
         Session consumerSess = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
         MessageConsumer consumer = consumerSess.createConsumer(queue);
         conn.start();
  
         final int NUM_MESSAGES = 10;
         final int NUM_TX = 10;
  
         //Send some messages
  
         for (int j = 0; j < NUM_TX; j++)
         {
  
            for (int i = 0; i < NUM_MESSAGES; i++)
            {
               Message m = producerSess.createMessage();
               producer.send(m);
            }
  
            producerSess.commit();
         }
  
View Full Code Here


         public void onMessage(Message m)
         {
            try
            {
               MessageProducer prod = sess.createProducer(queue2);

               prod.send(m);

               count++;

               if (count == numMessages)
               {
View Full Code Here

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

      boolean namedSucceeded = true;
      try
      {
         MessageProducer prod = sess.createProducer(dest);
         Message m = sess.createTextMessage("Kippers");
         prod.send(m);
      }
      catch (JMSSecurityException e)
      {
         log.trace("Can't write to destination using named producer");
         namedSucceeded = false;
      }

      boolean anonSucceeded = true;
      try
      {
         MessageProducer producerAnon = sess.createProducer(null);
         Message m = sess.createTextMessage("Kippers");
         producerAnon.send(dest, m);
      }
      catch (JMSSecurityException e)
      {
         log.trace("Can't write to destination using named producer");
         anonSucceeded = false;
View Full Code Here

      {
         conn = cf.createConnection();
        
         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
        
         MessageProducer prod = sess.createProducer(queue);
        
         final int NUM_MESSAGES = 5;
        
         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(queue);
View Full Code Here

         public void onMessage(Message m)
         {
            try
            {
               MessageProducer prod = sess.createProducer(queue2);

               prod.send(m);

               count++;

               if (count == numMessages)
               {
                  synchronized (lock)
                  {
                     lock.notify();
                  }

               }
            }
            catch (JMSException e)
            {
               failed = true;
            }
         }
      }

      MyListener listener = new MyListener();

      cons.setMessageListener(listener);

      MessageProducer prod = sess.createProducer(queue);

      for (int i = 0; i < numMessages; i++)
      {
         prod.send(sess.createMessage());
      }

      synchronized (lock)
      {
         lock.wait();
View Full Code Here

      {
         conn = cf.createConnection();
     
         Session sessSend = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
  
         MessageProducer prod = sessSend.createProducer(queue);
  
         conn.start();
  
         Session sessConsume1 = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
  
         MessageConsumer cons1 = sessConsume1.createConsumer(queue);
  
         TextMessage tm = sessSend.createTextMessage();
  
         tm.setText("Your mum");
  
         prod.send(tm);
  
         TextMessage tm2 = (TextMessage)cons1.receive();
  
         assertNotNull(tm2);
  
View Full Code Here

      conn.setClientID("wibble");

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

      MessageProducer prod = sessSend.createProducer(topic);

      conn.start();

      Session sessConsume1 = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);

      MessageConsumer cons1 = sessConsume1.createDurableSubscriber(topic, "sub1");

      TextMessage tm = sessSend.createTextMessage();

      tm.setText("Your mum");

      prod.send(tm);

      TextMessage tm2 = (TextMessage)cons1.receive();

      assertNotNull(tm2);
View Full Code Here

         connSend.start();

         Session sessSend = connSend.createSession(true, Session.SESSION_TRANSACTED);

         MessageProducer prod = sessSend.createProducer(queue2);

         prod.setDeliveryMode(DeliveryMode.PERSISTENT);

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

         prod.send(m);

         sessSend.commit();

         connReceive = cf.createConnection();
View Full Code Here

       {
          conn = cf.createConnection();
          conn.start();

          Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
          MessageProducer prod = sess.createProducer(queue);
          TextMessage tm1 = sess.createTextMessage("a");
          TextMessage tm2 = sess.createTextMessage("b");
          TextMessage tm3 = sess.createTextMessage("c");
          prod.send(tm1);
          prod.send(tm2);
          prod.send(tm3);
          sess.commit();

          MessageConsumer cons1 = sess.createConsumer(queue);

          TextMessage rm1 = (TextMessage)cons1.receive();
View Full Code Here

       {
          conn = cf.createConnection();
          conn.start();

          Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
          MessageProducer prod = sess.createProducer(queue);
          TextMessage tm1 = sess.createTextMessage("hello1");
          TextMessage tm2 = sess.createTextMessage("hello2");
          TextMessage tm3 = sess.createTextMessage("hello3");
          prod.send(tm1);
          prod.send(tm2);
          prod.send(tm3);
          sess.commit();

          MessageConsumer cons1 = sess.createConsumer(queue);

          TextMessage rm1 = (TextMessage)cons1.receive(1500);
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.