Package javax.jms

Examples of javax.jms.TopicSubscriber


                                    ", " + selector +
                                    ", " + noLocal + ")");

    checkValidity();

    TopicSubscriber sub =
      sess.createDurableSubscriber(topic, name, selector, noLocal);

    return new OutboundSubscriber(topic, noLocal, sub, this);
  }
View Full Code Here


                                    this + " createDurableSubscriber(" + topic +
                                    ", " + name + ")");

    checkValidity();

    TopicSubscriber sub = sess.createDurableSubscriber(topic, name);
    return new OutboundSubscriber(topic, false, sub, this);
  }
View Full Code Here

    ConnectionFactory tcf = (ConnectionFactory) ictx.lookup("tcf");
    ictx.close();

    Connection cnx = tcf.createConnection();
    Session session = cnx.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
    TopicSubscriber subscriber = session.createDurableSubscriber(topic, "durable");
    subscriber.setMessageListener(new MsgListener());

    cnx.start();

    System.in.read();
View Full Code Here

    PooledSession createPubSubSession(boolean producer,
                                              boolean consumer,
                                              Destination destination) throws JMSException {
        TopicSession session = ((TopicConnection)theConnection).createTopicSession(false,
                                                                                   Session.AUTO_ACKNOWLEDGE);
        TopicSubscriber sub = null;
        if (consumer) {
            String messageSelector =  jmsServerPolicy.getMessageSelector();
            String durableName = jmsServerPolicy.getDurableSubscriberName();
            if (durableName != null) {
                sub = session.createDurableSubscriber((Topic)destination,
View Full Code Here

         Topic topic = new XBDestination("jms-test", null, false);
     
         TopicConnection connection = factory.createTopicConnection();
         connection.start();
         TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
         TopicSubscriber subscriber = session.createSubscriber(topic);
         subscriber.setMessageListener(this);
     
         TopicPublisher publisher = session.createPublisher(topic);
     
         TextMessage msg = session.createTextMessage();
         msg.setText("this is a simple jms test message");
View Full Code Here

      throws JMSException {
      if (log.isLoggable(Level.FINER))
         log.finer("createDurableSubscriber '" + name + "' msgSelector=" + msgSelector + "' noLocal='" + noLocal + "'");
      checkIfOpen("createDurableSubscriber");
      checkControlThread();
      TopicSubscriber sub = new XBTopicSubscriber(this, topic, msgSelector, noLocal);
      this.durableSubscriptionMap.put(name, sub);
      return sub;
   }
View Full Code Here

      if (log.isLoggable(Level.FINER))
         log.finer("unsubscribe '" + subName + "'");
      checkIfOpen("unsubscribe");
      checkControlThread();
      try {
         TopicSubscriber sub = (TopicSubscriber)this.durableSubscriptionMap.remove(subName);
         if (sub == null)
            throw new JMSException(ME, "unsubscribe '" + subName + "'failed because the topic has not been found in this session");
         sub.close();
      }
      catch (Exception ex) {
         throw new JMSException(ME, "unsubscribe '" + subName + "'failed. Cause: " + ex.getMessage());
      }
   }
View Full Code Here

         conn.close();
         conn = cf.createTopicConnection();
         conn.start();
        
         TopicSession newsess = conn.createTopicSession(true, 0);
         TopicSubscriber newcons = newsess.createSubscriber(topic);
        
         Message m2 = (Message)newcons.receive(200);
         assertNull(m2);
      }
      finally
      {
         if (conn != null)
View Full Code Here

      {
         conn = cf.createTopicConnection();
         conn.start();
         TopicSession sess = conn.createTopicSession(true, 0);
         TopicPublisher pub = sess.createPublisher(topic);
         TopicSubscriber sub = sess.createSubscriber(topic);
         pub.setDeliveryMode(DeliveryMode.PERSISTENT);
        
         Message m = sess.createTextMessage("testing123");
         pub.publish(m);
         sess.commit();
        
         //receive but rollback
         TextMessage m2 = (TextMessage)sub.receive(3000);
               
         assertNotNull(m2);
         assertEquals("testing123", m2.getText());
        
         sess.rollback();
        
         conn.close();
         conn = cf.createTopicConnection();
         conn.start();
        
         TopicSession newsess = conn.createTopicSession(true, 0);
         TopicSubscriber newcons = newsess.createSubscriber(topic);
        
         Message m3 = (Message)newcons.receive(200);
         assertNull(m3);
      }
      finally
      {
         if (conn != null)
View Full Code Here

      try
      {
         conn = cf.createTopicConnection();
         TopicSession sess = conn.createTopicSession(true, 0);
         TopicPublisher pub = sess.createPublisher(topic);
         TopicSubscriber cons = sess.createSubscriber(topic);
         conn.start();
        
         Message m = sess.createTextMessage("testing123");
         pub.publish(m);
         sess.commit();
        
         TextMessage m2 = (TextMessage)cons.receive(3000);
         assertNotNull(m2);
         assertEquals("testing123", m2.getText());
        
         sess.rollback();
        
         m2 = (TextMessage)cons.receive(3000);
         assertNotNull(m2);
         assertEquals("testing123", m2.getText());
        
         conn.close();
        
         conn = cf.createTopicConnection();
         conn.start();
        
         //test 2
        
         TopicSession newsess = conn.createTopicSession(true, 0);
         TopicPublisher newpub = newsess.createPublisher(topic);
         TopicSubscriber newcons = newsess.createSubscriber(topic);
        
         Message m3 = newsess.createTextMessage("testing456");
         newpub.publish(m3);
         newsess.commit();
        
         TextMessage m4 = (TextMessage)newcons.receive(3000);
         assertNotNull(m4);
         assertEquals("testing456", m4.getText());
        
         newsess.commit();
        
         newpub.publish(m3);
         newsess.commit();
        
         TextMessage m5 = (TextMessage)newcons.receive(3000);
         assertNotNull(m5);
         assertEquals("testing456", m5.getText());
        
         newsess.rollback();
        
         TextMessage m6 = (TextMessage)newcons.receive(3000);
         assertNotNull(m6);
         assertEquals("testing456", m6.getText());
        
         newsess.commit();
        
View Full Code Here

TOP

Related Classes of javax.jms.TopicSubscriber

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.