Save This Page
Home » mq4_2-source-20080707.jar » javax » jms » [javadoc | source]
    1   /*
    2    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    3    *
    4    * Copyright 2000-2007 Sun Microsystems, Inc. All rights reserved. 
    5    *
    6    * The contents of this file are subject to the terms of either the GNU
    7    * General Public License Version 2 only ("GPL") or the Common Development
    8    * and Distribution License ("CDDL") (collectively, the "License").  You may
    9    * not use this file except in compliance with the License.  You can obtain
   10    * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
   11    * or mq/legal/LICENSE.txt.  See the License for the specific language
   12    * governing permissions and limitations under the License.
   13    * 
   14    * When distributing the software, include this License Header Notice in each
   15    * file and include the License file at mq/legal/LICENSE.txt.  Sun designates
   16    * this particular file as subject to the "Classpath" exception as provided by
   17    * Sun in the GPL Version 2 section of the License file that accompanied this
   18    * code.  If applicable, add the following below the License Header, with the
   19    * fields enclosed by brackets [] replaced by your own identifying information:
   20    * "Portions Copyrighted [year] [name of copyright owner]"
   21    * 
   22    * Contributor(s):
   23    * 
   24    * If you wish your version of this file to be governed by only the CDDL or
   25    * only the GPL Version 2, indicate your decision by adding "[Contributor]
   26    * elects to include this software in this distribution under the [CDDL or GPL
   27    * Version 2] license."  If you don't indicate a single choice of license, a
   28    * recipient has the option to distribute your version of this file under
   29    * either the CDDL, the GPL Version 2 or  to extend the choice of license to
   30    * its licensees as provided above.  However, if you add GPL Version 2 code
   31    * and therefore, elected the GPL Version 2 license, then the option applies
   32    * only if the new code is made subject to such option by the copyright holder. 
   33    */
   34   
   35   /*
   36    * @(#)TopicPublisher.java	1.32 07/02/07
   37    */ 
   38   
   39   package javax.jms;
   40   
   41   /** A client uses a <CODE>TopicPublisher</CODE> object to publish messages on a 
   42     * topic. A <CODE>TopicPublisher</CODE> object is the publish-subscribe form
   43     * of a message producer.
   44     *
   45     * <P>Normally, the <CODE>Topic</CODE> is specified when a 
   46     * <CODE>TopicPublisher</CODE> is created.  In this case, an attempt to use 
   47     * the <CODE>publish</CODE> methods for an unidentified 
   48     * <CODE>TopicPublisher</CODE> will throw a 
   49     * <CODE>java.lang.UnsupportedOperationException</CODE>.
   50     *
   51     * <P>If the <CODE>TopicPublisher</CODE> is created with an unidentified 
   52     * <CODE>Topic</CODE>, an attempt to use the <CODE>publish</CODE> methods that 
   53     * assume that the <CODE>Topic</CODE> has been identified will throw a 
   54     * <CODE>java.lang.UnsupportedOperationException</CODE>.
   55     *
   56     * <P>During the execution of its <CODE>publish</CODE> method,
   57     * a message must not be changed by other threads within the client. 
   58     * If the message is modified, the result of the <CODE>publish</CODE> is 
   59     * undefined.
   60     * 
   61     * <P>After publishing a message, a client may retain and modify it
   62     * without affecting the message that has been published. The same message
   63     * object may be published multiple times.
   64     * 
   65     * <P>The following message headers are set as part of publishing a 
   66     * message: <code>JMSDestination</code>, <code>JMSDeliveryMode</code>, 
   67     * <code>JMSExpiration</code>, <code>JMSPriority</code>, 
   68     * <code>JMSMessageID</code> and <code>JMSTimeStamp</code>.
   69     * When the message is published, the values of these headers are ignored. 
   70     * After completion of the <CODE>publish</CODE>, the headers hold the values 
   71     * specified by the method publishing the message. It is possible for the 
   72     * <CODE>publish</CODE> method not to set <code>JMSMessageID</code> and 
   73     * <code>JMSTimeStamp</code> if the 
   74     * setting of these headers is explicitly disabled by the 
   75     * <code>MessageProducer.setDisableMessageID</code> or
   76     * <code>MessageProducer.setDisableMessageTimestamp</code> method.
   77     *
   78     *<P>Creating a <CODE>MessageProducer</CODE> provides the same features as
   79     * creating a <CODE>TopicPublisher</CODE>. A <CODE>MessageProducer</CODE> object is 
   80     * recommended when creating new code. The  <CODE>TopicPublisher</CODE> is
   81     * provided to support existing code.
   82   
   83     *
   84     *<P>Because <CODE>TopicPublisher</CODE> inherits from 
   85     * <CODE>MessageProducer</CODE>, it inherits the
   86     * <CODE>send</CODE> methods that are a part of the <CODE>MessageProducer</CODE> 
   87     * interface. Using the <CODE>send</CODE> methods will have the same
   88     * effect as using the
   89     * <CODE>publish</CODE> methods: they are functionally the same.
   90     * 
   91     * @see Session#createProducer(Destination) 
   92     * @see TopicSession#createPublisher(Topic)
   93     */
   94   
   95   public interface TopicPublisher extends MessageProducer {
   96   
   97       /** Gets the topic associated with this <CODE>TopicPublisher</CODE>.
   98         *
   99         * @return this publisher's topic
  100         *  
  101         * @exception JMSException if the JMS provider fails to get the topic for
  102         *                         this <CODE>TopicPublisher</CODE>
  103         *                         due to some internal error.
  104         */
  105   
  106       Topic 
  107       getTopic() throws JMSException;
  108   
  109    
  110       /** Publishes a message to the topic.
  111         * Uses the <CODE>TopicPublisher</CODE>'s default delivery mode, priority,
  112         * and time to live.
  113         *
  114         * @param message the message to publish
  115         *
  116         * @exception JMSException if the JMS provider fails to publish the message
  117         *                         due to some internal error.
  118         * @exception MessageFormatException if an invalid message is specified.
  119         * @exception InvalidDestinationException if a client uses this method
  120         *                         with a <CODE>TopicPublisher</CODE> with
  121         *                         an invalid topic.
  122         * @exception java.lang.UnsupportedOperationException if a client uses this
  123         *                         method with a <CODE>TopicPublisher</CODE> that
  124         *                         did not specify a topic at creation time.
  125         * 
  126         * @see javax.jms.MessageProducer#getDeliveryMode()
  127         * @see javax.jms.MessageProducer#getTimeToLive()
  128         * @see javax.jms.MessageProducer#getPriority()
  129         */
  130   
  131       void 
  132       publish(Message message) throws JMSException;
  133   
  134   
  135       /** Publishes a message to the topic, specifying delivery mode,
  136         * priority, and time to live.
  137         *
  138         * @param message the message to publish
  139         * @param deliveryMode the delivery mode to use
  140         * @param priority the priority for this message
  141         * @param timeToLive the message's lifetime (in milliseconds)
  142         *
  143         * @exception JMSException if the JMS provider fails to publish the message
  144         *                         due to some internal error.
  145         * @exception MessageFormatException if an invalid message is specified.
  146         * @exception InvalidDestinationException if a client uses this method
  147         *                         with a <CODE>TopicPublisher</CODE> with
  148         *                         an invalid topic.
  149         * @exception java.lang.UnsupportedOperationException if a client uses this
  150         *                         method with a <CODE>TopicPublisher</CODE> that
  151         *                         did not specify a topic at creation time.
  152         */
  153    
  154       void
  155       publish(Message message, 
  156               int deliveryMode, 
  157   	    int priority,
  158   	    long timeToLive) throws JMSException;
  159   
  160   
  161       /** Publishes a message to a topic for an unidentified message producer. 
  162         * Uses the <CODE>TopicPublisher</CODE>'s default delivery mode, 
  163         * priority, and time to live.
  164         *  
  165         * <P>Typically, a message producer is assigned a topic at creation 
  166         * time; however, the JMS API also supports unidentified message producers,
  167         * which require that the topic be supplied every time a message is
  168         * published.
  169         *
  170         * @param topic the topic to publish this message to
  171         * @param message the message to publish
  172         *  
  173         * @exception JMSException if the JMS provider fails to publish the message
  174         *                         due to some internal error.
  175         * @exception MessageFormatException if an invalid message is specified.
  176         * @exception InvalidDestinationException if a client uses
  177         *                         this method with an invalid topic.
  178         * 
  179         * @see javax.jms.MessageProducer#getDeliveryMode()
  180         * @see javax.jms.MessageProducer#getTimeToLive()
  181         * @see javax.jms.MessageProducer#getPriority()
  182         */ 
  183   
  184       void
  185       publish(Topic topic, Message message) throws JMSException;
  186   
  187   
  188       /** Publishes a message to a topic for an unidentified message 
  189         * producer, specifying delivery mode, priority and time to live.
  190         *  
  191         * <P>Typically, a message producer is assigned a topic at creation
  192         * time; however, the JMS API also supports unidentified message producers,
  193         * which require that the topic be supplied every time a message is
  194         * published.
  195         *
  196         * @param topic the topic to publish this message to
  197         * @param message the message to publish
  198         * @param deliveryMode the delivery mode to use
  199         * @param priority the priority for this message
  200         * @param timeToLive the message's lifetime (in milliseconds)
  201         *  
  202         * @exception JMSException if the JMS provider fails to publish the message
  203         *                         due to some internal error.
  204         * @exception MessageFormatException if an invalid message is specified.
  205         * @exception InvalidDestinationException if a client uses
  206         *                         this method with an invalid topic.
  207         */ 
  208   
  209       void
  210       publish(Topic topic, 
  211               Message message, 
  212               int deliveryMode, 
  213               int priority,
  214   	    long timeToLive) throws JMSException;
  215   }

Save This Page
Home » mq4_2-source-20080707.jar » javax » jms » [javadoc | source]