Package javax.jms

Examples of javax.jms.MessageProducer


   {

    Connection conn = cf.createConnection();

    Session producerSess = conn.createSession(false, Session.CLIENT_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 = 20;
    final int ACKED_MESSAGES = 11;

    //Send some messages
    for (int i = 0; i < NUM_MESSAGES; i++)
    {
      Message m = producerSess.createMessage();
      producer.send(m);
    }
     
      assertRemainingMessages(NUM_MESSAGES);

    log.trace("Sent messages");
View Full Code Here


   {

    Connection conn = cf.createConnection();

    Session producerSess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageProducer producer = producerSess.createProducer(queue);

    Session consumerSess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer consumer = consumerSess.createConsumer(queue);
    conn.start();

    final int NUM_MESSAGES = 20;

    //Send some messages
    for (int i = 0; i < NUM_MESSAGES; i++)
    {
      Message m = producerSess.createMessage();
      producer.send(m);
    }
     
      assertRemainingMessages(NUM_MESSAGES);

    log.trace("Sent messages");
View Full Code Here

      ConnectionFactory myCF = (ConnectionFactory)initialContext.lookup("/mycf");
     
      Connection conn = myCF.createConnection();

      Session producerSess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      MessageProducer producer = producerSess.createProducer(queue);

      Session consumerSess = conn.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
      MessageConsumer consumer = consumerSess.createConsumer(queue);
      conn.start();

      //Send some messages
      for (int i = 0; i < 19; i++)
      {
         Message m = producerSess.createMessage();
         producer.send(m);
      }
     
      assertRemainingMessages(19);

      log.trace("Sent messages");
View Full Code Here

   {

    Connection conn = cf.createConnection();

    Session producerSess = conn.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
    MessageProducer producer = producerSess.createProducer(queue);

    Session consumerSess = conn.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
    MessageConsumer consumer = consumerSess.createConsumer(queue);
    conn.start();

    final int NUM_MESSAGES = 20;

    //Send some messages
    for (int i = 0; i < NUM_MESSAGES; i++)
    {
      Message m = producerSess.createMessage();
      producer.send(m);
    }

      assertRemainingMessages(NUM_MESSAGES);
     
    log.trace("Sent messages");
View Full Code Here

  
   public void testMessageListenerAutoAck() throws Exception
   {
      Connection conn = cf.createConnection();
      Session sessSend = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      MessageProducer prod = sessSend.createProducer(queue);
      prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
     
      log.trace("Sending messages");
     
      TextMessage tm1 = sessSend.createTextMessage("a");
      TextMessage tm2 = sessSend.createTextMessage("b");
      TextMessage tm3 = sessSend.createTextMessage("c");
      prod.send(tm1);
      prod.send(tm2);
      prod.send(tm3);
     
      log.trace("Sent messages");
     
      sessSend.close();
     
View Full Code Here

  
   public void testMessageListenerDupsOK() throws Exception
   {
      Connection conn = cf.createConnection();
      Session sessSend = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      MessageProducer prod = sessSend.createProducer(queue);
      prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
     
      log.trace("Sending messages");
     
      TextMessage tm1 = sessSend.createTextMessage("a");
      TextMessage tm2 = sessSend.createTextMessage("b");
      TextMessage tm3 = sessSend.createTextMessage("c");
      prod.send(tm1);
      prod.send(tm2);
      prod.send(tm3);
     
      log.trace("Sent messages");
     
      sessSend.close();
     
View Full Code Here

  
   public void testMessageListenerClientAck() throws Exception
   {
      Connection conn = cf.createConnection();
      Session sessSend = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      MessageProducer prod = sessSend.createProducer(queue);
      prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
      TextMessage tm1 = sessSend.createTextMessage("a");
      TextMessage tm2 = sessSend.createTextMessage("b");
      TextMessage tm3 = sessSend.createTextMessage("c");
      prod.send(tm1);
      prod.send(tm2);
      prod.send(tm3);
      sessSend.close();
     
      assertRemainingMessages(3);
     
      conn.start();
View Full Code Here

  
   public void testMessageListenerTransactionalAck() throws Exception
   {
      Connection conn = cf.createConnection();
      Session sessSend = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      MessageProducer prod = sessSend.createProducer(queue);
      prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
      TextMessage tm1 = sessSend.createTextMessage("a");
      TextMessage tm2 = sessSend.createTextMessage("b");
      TextMessage tm3 = sessSend.createTextMessage("c");
      prod.send(tm1);
      prod.send(tm2);
      prod.send(tm3);
      sessSend.close();
     
      assertRemainingMessages(3);
     
      conn.start();
View Full Code Here

     
      Connection conn = cf.createConnection();
     
      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
     
      MessageProducer prod = sess.createProducer(queue);
         
      int i = 0;
     
      //Thread.sleep(30000);
     
      try
      {        
         log.info("Please manually kill server process in a few seconds time...");
         while (true)
         {
            TextMessage tm = sess.createTextMessage("message:" + i);
           
            tm.setIntProperty("message", i);
           
            prod.send(tm);
           
            i++;
         }        
      }
      catch (Exception e)
View Full Code Here

      {        
         conn = cf.createConnection();
  
         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
        
         MessageProducer prod = sess.createProducer(queue);
        
         MessageConsumer cons = sess.createConsumer(queue);
        
         conn.start();                 
              
         String s1 = genString(16 * 1024);  
        
         String s2 = genString(32 * 1024);
        
         String s3 = genString(64 * 1024);
        
         String s4 = genString(10 * 64 * 1024);
        
         TextMessage tm1 = sess.createTextMessage(s1);
        
         TextMessage tm2 = sess.createTextMessage(s2);
        
         TextMessage tm3 = sess.createTextMessage(s3);
        
         TextMessage tm4 = sess.createTextMessage(s4);
        
         prod.send(tm1);
        
         prod.send(tm2);
        
         prod.send(tm3);
        
         prod.send(tm4);
  
         TextMessage rm1 = (TextMessage)cons.receive(1000);
        
         assertNotNull(rm1);          
        
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.