Home » jboss-javaee-sources » javax » jms » [javadoc | source]

    1   /*
    2    * JBoss, Home of Professional Open Source
    3    * Copyright 2005, JBoss Inc., and individual contributors as indicated
    4    * by the @authors tag. See the copyright.txt in the distribution for a
    5    * full listing of individual contributors.
    6    *
    7    * This is free software; you can redistribute it and/or modify it
    8    * under the terms of the GNU Lesser General Public License as
    9    * published by the Free Software Foundation; either version 2.1 of
   10    * the License, or (at your option) any later version.
   11    *
   12    * This software is distributed in the hope that it will be useful,
   13    * but WITHOUT ANY WARRANTY; without even the implied warranty of
   14    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   15    * Lesser General Public License for more details.
   16    *
   17    * You should have received a copy of the GNU Lesser General Public
   18    * License along with this software; if not, write to the Free
   19    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   20    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
   21    */
   22   package javax.jms;
   23   
   24   /** A client uses a <CODE>TopicSubscriber</CODE> object to receive messages that
   25    * have been published to a topic. A <CODE>TopicSubscriber</CODE> object is the
   26    * publish/subscribe form of a message consumer. A <CODE>MessageConsumer</CODE>
   27    * can be created by using <CODE>Session.createConsumer</CODE>. 
   28    *
   29    * <P>A <CODE>TopicSession</CODE> allows the creation of multiple 
   30    * <CODE>TopicSubscriber</CODE> objects per topic.  It will deliver each 
   31    * message for a topic to each
   32    * subscriber eligible to receive it. Each copy of the message
   33    * is treated as a completely separate message. Work done on one copy has
   34    * no effect on the others; acknowledging one does not acknowledge the
   35    * others; one message may be delivered immediately, while another waits
   36    * for its subscriber to process messages ahead of it.
   37    *
   38    * <P>Regular <CODE>TopicSubscriber</CODE> objects are not durable. They 
   39    * receive only messages that are published while they are active.
   40    *
   41    * <P>Messages filtered out by a subscriber's message selector will never 
   42    * be delivered to the subscriber. From the subscriber's perspective, they 
   43    * do not exist.
   44    *
   45    * <P>In some cases, a connection may both publish and subscribe to a topic.
   46    * The subscriber <CODE>NoLocal</CODE> attribute allows a subscriber to inhibit
   47    * the 
   48    * delivery of messages published by its own connection.
   49    *
   50    * <P>If a client needs to receive all the messages published on a topic, 
   51    * including the ones published while the subscriber is inactive, it uses 
   52    * a durable <CODE>TopicSubscriber</CODE>. The JMS provider retains a record of
   53    * this durable 
   54    * subscription and insures that all messages from the topic's publishers 
   55    * are retained until they are acknowledged by this durable 
   56    * subscriber or they have expired.
   57    *
   58    * <P>Sessions with durable subscribers must always provide the same client 
   59    * identifier. In addition, each client must specify a name that uniquely 
   60    * identifies (within client identifier) each durable subscription it creates.
   61    * Only one session at a time can have a <CODE>TopicSubscriber</CODE> for a 
   62    * particular durable subscription. 
   63    *
   64    * <P>A client can change an existing durable subscription by creating a 
   65    * durable <CODE>TopicSubscriber</CODE> with the same name and a new topic 
   66    * and/or message 
   67    * selector. Changing a durable subscription is equivalent to unsubscribing 
   68    * (deleting) the old one and creating a new one.
   69    *
   70    * <P>The <CODE>unsubscribe</CODE> method is used to delete a durable 
   71    * subscription. The <CODE>unsubscribe</CODE> method can be used at the 
   72    * <CODE>Session</CODE> or <CODE>TopicSession</CODE> level.
   73    * This method deletes the state being 
   74    * maintained on behalf of the subscriber by its provider.
   75    *
   76    * <P>Creating a <CODE>MessageConsumer</CODE> provides the same features as
   77    * creating a <CODE>TopicSubscriber</CODE>. To create a durable subscriber, 
   78    * use of <CODE>Session.CreateDurableSubscriber</CODE> is recommended. The 
   79    * <CODE>TopicSubscriber</CODE> is provided to support existing code.
   80    * 
   81    * @see         javax.jms.Session#createConsumer
   82    * @see         javax.jms.Session#createDurableSubscriber
   83    * @see         javax.jms.TopicSession
   84    * @see         javax.jms.TopicSession#createSubscriber
   85    * @see         javax.jms.MessageConsumer
   86    */
   87   
   88   public interface TopicSubscriber extends MessageConsumer
   89   {
   90   
   91      /** Gets the <CODE>Topic</CODE> associated with this subscriber.
   92       *  
   93       * @return this subscriber's <CODE>Topic</CODE>
   94       *  
   95       * @exception JMSException if the JMS provider fails to get the topic for
   96       *                         this topic subscriber
   97       *                         due to some internal error.
   98       */
   99   
  100      Topic getTopic() throws JMSException;
  101   
  102      /** Gets the <CODE>NoLocal</CODE> attribute for this subscriber. 
  103       * The default value for this attribute is false.
  104       *  
  105       * @return true if locally published messages are being inhibited
  106       *  
  107       * @exception JMSException if the JMS provider fails to get the
  108       *                         <CODE>NoLocal</CODE> attribute for
  109       *                         this topic subscriber
  110       *                         due to some internal error.
  111       */
  112   
  113      boolean getNoLocal() throws JMSException;
  114   }

Home » jboss-javaee-sources » javax » jms » [javadoc | source]