KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > jms > TopicSubscriber


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24
25 package javax.jms;
26
27 /** A client uses a <CODE>TopicSubscriber</CODE> object to receive messages that
28   * have been published to a topic. A <CODE>TopicSubscriber</CODE> object is the
29   * publish/subscribe form of a message consumer. A <CODE>MessageConsumer</CODE>
30   * can be created by using <CODE>Session.createConsumer</CODE>.
31   *
32   * <P>A <CODE>TopicSession</CODE> allows the creation of multiple
33   * <CODE>TopicSubscriber</CODE> objects per topic. It will deliver each
34   * message for a topic to each
35   * subscriber eligible to receive it. Each copy of the message
36   * is treated as a completely separate message. Work done on one copy has
37   * no effect on the others; acknowledging one does not acknowledge the
38   * others; one message may be delivered immediately, while another waits
39   * for its subscriber to process messages ahead of it.
40   *
41   * <P>Regular <CODE>TopicSubscriber</CODE> objects are not durable. They
42   * receive only messages that are published while they are active.
43   *
44   * <P>Messages filtered out by a subscriber's message selector will never
45   * be delivered to the subscriber. From the subscriber's perspective, they
46   * do not exist.
47   *
48   * <P>In some cases, a connection may both publish and subscribe to a topic.
49   * The subscriber <CODE>NoLocal</CODE> attribute allows a subscriber to inhibit
50   * the
51   * delivery of messages published by its own connection.
52   *
53   * <P>If a client needs to receive all the messages published on a topic,
54   * including the ones published while the subscriber is inactive, it uses
55   * a durable <CODE>TopicSubscriber</CODE>. The JMS provider retains a record of
56   * this durable
57   * subscription and insures that all messages from the topic's publishers
58   * are retained until they are acknowledged by this durable
59   * subscriber or they have expired.
60   *
61   * <P>Sessions with durable subscribers must always provide the same client
62   * identifier. In addition, each client must specify a name that uniquely
63   * identifies (within client identifier) each durable subscription it creates.
64   * Only one session at a time can have a <CODE>TopicSubscriber</CODE> for a
65   * particular durable subscription.
66   *
67   * <P>A client can change an existing durable subscription by creating a
68   * durable <CODE>TopicSubscriber</CODE> with the same name and a new topic
69   * and/or message
70   * selector. Changing a durable subscription is equivalent to unsubscribing
71   * (deleting) the old one and creating a new one.
72   *
73   * <P>The <CODE>unsubscribe</CODE> method is used to delete a durable
74   * subscription. The <CODE>unsubscribe</CODE> method can be used at the
75   * <CODE>Session</CODE> or <CODE>TopicSession</CODE> level.
76   * This method deletes the state being
77   * maintained on behalf of the subscriber by its provider.
78   *
79   * <P>Creating a <CODE>MessageConsumer</CODE> provides the same features as
80   * creating a <CODE>TopicSubscriber</CODE>. To create a durable subscriber,
81   * use of <CODE>Session.CreateDurableSubscriber</CODE> is recommended. The
82   * <CODE>TopicSubscriber</CODE> is provided to support existing code.
83   *
84   *
85   * @version 1.1 - February 2, 2002
86   * @author Mark Hapner
87   * @author Rich Burridge
88   * @author Kate Stout
89   *
90   * @see javax.jms.Session#createConsumer
91   * @see javax.jms.Session#createDurableSubscriber
92   * @see javax.jms.TopicSession
93   * @see javax.jms.TopicSession#createSubscriber
94   * @see javax.jms.MessageConsumer
95   */

96
97 public interface TopicSubscriber extends MessageConsumer JavaDoc {
98
99     /** Gets the <CODE>Topic</CODE> associated with this subscriber.
100       *
101       * @return this subscriber's <CODE>Topic</CODE>
102       *
103       * @exception JMSException if the JMS provider fails to get the topic for
104       * this topic subscriber
105       * due to some internal error.
106       */

107
108     Topic JavaDoc
109     getTopic() throws JMSException JavaDoc;
110
111
112     /** Gets the <CODE>NoLocal</CODE> attribute for this subscriber.
113       * The default value for this attribute is false.
114       *
115       * @return true if locally published messages are being inhibited
116       *
117       * @exception JMSException if the JMS provider fails to get the
118       * <CODE>NoLocal</CODE> attribute for
119       * this topic subscriber
120       * due to some internal error.
121       */

122
123     boolean
124     getNoLocal() throws JMSException JavaDoc;
125 }
126
Popular Tags