Package javax.jms

Examples of javax.jms.TopicPublisher


            {
                Message message = subscriber_.receive();
   
                // create a publisher and then publish the message back to
                // the sender
                TopicPublisher publisher = session_.createPublisher(topic_);
                publisher.publish((Topic)message.getJMSReplyTo(), message);
            }

            connection_.close();
        }
        catch (Exception exception)
View Full Code Here


    try
    {
      TopicSession session = connection_.createTopicSession
        (false, Session.CLIENT_ACKNOWLEDGE);
      Topic topic = session.createTopic("OpenJMSDemo-deals");
      TopicPublisher publisher = session.createPublisher(topic);
      int delivery_mode = DeliveryMode.PERSISTENT;
      ObjectMessage message = session.createObjectMessage(this);
      publisher.publish(message, delivery_mode, 1, 0);
      //      session.close();
    }
    catch (Exception exception)
    {
      success = false;
View Full Code Here

    {
      TopicSession session = connection_.createTopicSession
        (false, Session.CLIENT_ACKNOWLEDGE);
            connection_.start();
      Topic topic = session.createTopic(newTopic);
      TopicPublisher publisher = session.createPublisher(topic);
      int delivery_mode = DeliveryMode.NON_PERSISTENT;
      // need to copy message else destination will change, and ack will
      // fail.
      ObjectMessage message = session.createObjectMessage(data);
      publisher.publish(message, delivery_mode, 1, 0);
      session.close();
    }
    catch (Exception exception)
    {
      success = false;
View Full Code Here

            QueueSession qsession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
            TemporaryQueue temp = qsession.createTemporaryQueue();
            message.setJMSReplyTo(temp);

            TopicPublisher publisher = session.createPublisher(topic);
            publisher.publish(message);

            QueueReceiver receiver = qsession.createReceiver(temp);
            receiver.receive();
            receiver.close();
           
View Full Code Here

               {

                  TopicSession session = topicConnection.createTopicSession(transacted != TRANS_NONE, Session.AUTO_ACKNOWLEDGE);
                  Topic topic = (Topic)context.lookup(TEST_TOPIC);

                  TopicPublisher publisher = session.createPublisher(topic);

                  waitForSynchMessage();

                  BytesMessage message = session.createBytesMessage();
                  message.writeBytes(PERFORMANCE_TEST_DATA_PAYLOAD);

                  long startTime = System.currentTimeMillis();
                  for (int i = 0; i < iterationCount; i++)
                  {
                     publisher.publish(message, persistence, 4, 0);
                     //publisher.publish(topic, message, persistence, 4, 0);
                     //getLog().debug("  Sent #"+i);
                     if (transacted == TRANS_INDIVIDUAL)
                     {
                        session.commit();
View Full Code Here

               {

                  TopicSession session = topicConnection.createTopicSession(transacted != TRANS_NONE, Session.AUTO_ACKNOWLEDGE);
                  Topic topic = (Topic)context.lookup(TEST_TOPIC);

                  TopicPublisher publisher = session.createPublisher(topic);

                  waitForSynchMessage();

                  BytesMessage message = session.createBytesMessage();
                  message.writeBytes(PERFORMANCE_TEST_DATA_PAYLOAD);

                  long startTime = System.currentTimeMillis();
                  for (int i = 0; i < iterationCount; i++)
                  {
                     publisher.publish(message, persistence, 4, 0);
                     //publisher.publish(topic, message, persistence, 4, 0);
                     //getLog().debug("  Sent #"+i);
                     if (transacted == TRANS_INDIVIDUAL)
                     {
                        session.commit();
View Full Code Here

               {

                  TopicSession session = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
                  Topic topic = (Topic)context.lookup(TEST_TOPIC);

                  TopicPublisher publisher = session.createPublisher(topic);

                  waitForSynchMessage();

                  BytesMessage message = session.createBytesMessage();
                  message.writeBytes(PAYLOAD);

                  for (int i = 0; i < iterationCount; i++)
                  {
                     publisher.publish(message, persistence, 4, 0);
                  }

                  session.close();
               }
               catch (Exception e)
View Full Code Here

               {

                  TopicSession session = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
                  Topic topic = (Topic)context.lookup(TEST_DURABLE_TOPIC);

                  TopicPublisher publisher = session.createPublisher(topic);

                  waitForSynchMessage();

                  BytesMessage message = session.createBytesMessage();
                  message.writeBytes(PAYLOAD);

                  for (int i = 0; i < iterationCount; i++)
                  {
                     publisher.publish(message, persistence, 4, 0);
                  }

                  session.close();
               }
               catch (Exception e)
View Full Code Here

      getLog().debug("Starting InvaidDestinationTopicPublish test");
      connect();

      TopicSession session = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
      TemporaryTopic topic = session.createTemporaryTopic();
      TopicPublisher publisher = session.createPublisher(topic);
      topic.delete();

      TextMessage message = session.createTextMessage("hello");
      boolean caught = false;
      try
      {
         publisher.publish(message);
      }
      catch (InvalidDestinationException expected)
      {
         caught = true;
      }
View Full Code Here

      TopicSubscriber sub1 = session.createDurableSubscriber(topic, "sub1");
      TopicSubscriber sub2 = session.createSubscriber(topic);
      TopicSubscriber sub3 = session.createSubscriber(topic);

      //Now a sender
      TopicPublisher sender = session.createPublisher(topic);

      //send some messages
      sender.publish(session.createTextMessage("Message 1"));
      sender.publish(session.createTextMessage("Message 2"));
      sender.publish(session.createTextMessage("Message 3"));
      drainMessagesForTopic(sub1);
      drainMessagesForTopic(sub2);
      drainMessagesForTopic(sub3);

      //close some subscribers
      sub1.close();
      sub2.close();

      //send some more messages
      sender.publish(session.createTextMessage("Message 4"));
      sender.publish(session.createTextMessage("Message 5"));
      sender.publish(session.createTextMessage("Message 6"));

      //give time for message 4 to be negatively acked (as it will be cause last receive timed out)
      try
      {
         Thread.sleep(5 * 1000);
      }
      catch (InterruptedException e)
      {
      }

      drainMessagesForTopic(sub3);

      //open subscribers again.
      sub1 = session.createDurableSubscriber(topic, "sub1");
      sub2 = session.createSubscriber(topic);

      //Send a final message
      sender.publish(session.createTextMessage("Final message"));
      sender.close();

      drainMessagesForTopic(sub1);
      drainMessagesForTopic(sub2);
      drainMessagesForTopic(sub3);

View Full Code Here

TOP

Related Classes of javax.jms.TopicPublisher

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.