KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > jms > QueueSender


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>QueueSender</CODE> object to send messages to a queue.
28   *
29   * <P>Normally, the <CODE>Queue</CODE> is specified when a
30   * <CODE>QueueSender</CODE> is created. In this case, an attempt to use
31   * the <CODE>send</CODE> methods for an unidentified
32   * <CODE>QueueSender</CODE> will throw a
33   * <CODE>java.lang.UnsupportedOperationException</CODE>.
34   *
35   * <P>If the <CODE>QueueSender</CODE> is created with an unidentified
36   * <CODE>Queue</CODE>, an attempt to use the <CODE>send</CODE> methods that
37   * assume that the <CODE>Queue</CODE> has been identified will throw a
38   * <CODE>java.lang.UnsupportedOperationException</CODE>.
39   *
40   * <P>During the execution of its <CODE>send</CODE> method, a message
41   * must not be changed by other threads within the client.
42   * If the message is modified, the result of the <CODE>send</CODE> is
43   * undefined.
44   *
45   * <P>After sending a message, a client may retain and modify it
46   * without affecting the message that has been sent. The same message
47   * object may be sent multiple times.
48   *
49   * <P>The following message headers are set as part of sending a
50   * message: <code>JMSDestination</code>, <code>JMSDeliveryMode</code>,
51   * <code>JMSExpiration</code>, <code>JMSPriority</code>,
52   * <code>JMSMessageID</code> and <code>JMSTimeStamp</code>.
53   * When the message is sent, the values of these headers are ignored.
54   * After the completion of the <CODE>send</CODE>, the headers hold the values
55   * specified by the method sending the message. It is possible for the
56   * <code>send</code> method not to set <code>JMSMessageID</code> and
57   * <code>JMSTimeStamp</code> if the
58   * setting of these headers is explicitly disabled by the
59   * <code>MessageProducer.setDisableMessageID</code> or
60   * <code>MessageProducer.setDisableMessageTimestamp</code> method.
61   *
62   * <P>Creating a <CODE>MessageProducer</CODE> provides the same features as
63   * creating a <CODE>QueueSender</CODE>. A <CODE>MessageProducer</CODE> object is
64   * recommended when creating new code. The <CODE>QueueSender</CODE> is
65   * provided to support existing code.
66   *
67   *
68   * @version 1.1 - February 2, 2002
69   * @author Mark Hapner
70   * @author Rich Burridge
71   * @author Kate Stout
72   *
73   * @see javax.jms.MessageProducer
74   * @see javax.jms.Session#createProducer(Destination)
75   * @see javax.jms.QueueSession#createSender(Queue)
76   */

77
78 public interface QueueSender extends MessageProducer JavaDoc {
79
80     /** Gets the queue associated with this <CODE>QueueSender</CODE>.
81       *
82       * @return this sender's queue
83       *
84       * @exception JMSException if the JMS provider fails to get the queue for
85       * this <CODE>QueueSender</CODE>
86       * due to some internal error.
87       */

88  
89     Queue JavaDoc
90     getQueue() throws JMSException JavaDoc;
91
92
93     /** Sends a message to the queue. Uses the <CODE>QueueSender</CODE>'s
94       * default delivery mode, priority, and time to live.
95       *
96       * @param message the message to send
97       *
98       * @exception JMSException if the JMS provider fails to send the message
99       * due to some internal error.
100       * @exception MessageFormatException if an invalid message is specified.
101       * @exception InvalidDestinationException if a client uses
102       * this method with a <CODE>QueueSender</CODE> with
103       * an invalid queue.
104       * @exception java.lang.UnsupportedOperationException if a client uses this
105       * method with a <CODE>QueueSender</CODE> that did
106       * not specify a queue at creation time.
107       *
108       * @see javax.jms.MessageProducer#getDeliveryMode()
109       * @see javax.jms.MessageProducer#getTimeToLive()
110       * @see javax.jms.MessageProducer#getPriority()
111       */

112
113     void
114     send(Message JavaDoc message) throws JMSException JavaDoc;
115
116
117     /** Sends a message to the queue, specifying delivery mode, priority, and
118       * time to live.
119       *
120       * @param message the message to send
121       * @param deliveryMode the delivery mode to use
122       * @param priority the priority for this message
123       * @param timeToLive the message's lifetime (in milliseconds)
124       *
125       * @exception JMSException if the JMS provider fails to send the message
126       * due to some internal error.
127       * @exception MessageFormatException if an invalid message is specified.
128       * @exception InvalidDestinationException if a client uses
129       * this method with a <CODE>QueueSender</CODE> with
130       * an invalid queue.
131       * @exception java.lang.UnsupportedOperationException if a client uses this
132       * method with a <CODE>QueueSender</CODE> that did
133       * not specify a queue at creation time.
134       */

135
136     void
137     send(Message JavaDoc message,
138      int deliveryMode,
139      int priority,
140      long timeToLive) throws JMSException JavaDoc;
141
142
143     /** Sends a message to a queue for an unidentified message producer.
144       * Uses the <CODE>QueueSender</CODE>'s default delivery mode, priority,
145       * and time to live.
146       *
147       * <P>Typically, a message producer is assigned a queue at creation
148       * time; however, the JMS API also supports unidentified message producers,
149       * which require that the queue be supplied every time a message is
150       * sent.
151       *
152       * @param queue the queue to send this message to
153       * @param message the message to send
154       *
155       * @exception JMSException if the JMS provider fails to send the message
156       * due to some internal error.
157       * @exception MessageFormatException if an invalid message is specified.
158       * @exception InvalidDestinationException if a client uses
159       * this method with an invalid queue.
160       *
161       * @see javax.jms.MessageProducer#getDeliveryMode()
162       * @see javax.jms.MessageProducer#getTimeToLive()
163       * @see javax.jms.MessageProducer#getPriority()
164       */

165  
166     void
167     send(Queue JavaDoc queue, Message JavaDoc message) throws JMSException JavaDoc;
168  
169  
170     /** Sends a message to a queue for an unidentified message producer,
171       * specifying delivery mode, priority and time to live.
172       *
173       * <P>Typically, a message producer is assigned a queue at creation
174       * time; however, the JMS API also supports unidentified message producers,
175       * which require that the queue be supplied every time a message is
176       * sent.
177       *
178       * @param queue the queue to send this message to
179       * @param message the message to send
180       * @param deliveryMode the delivery mode to use
181       * @param priority the priority for this message
182       * @param timeToLive the message's lifetime (in milliseconds)
183       *
184       * @exception JMSException if the JMS provider fails to send the message
185       * due to some internal error.
186       * @exception MessageFormatException if an invalid message is specified.
187       * @exception InvalidDestinationException if a client uses
188       * this method with an invalid queue.
189       */

190
191     void
192     send(Queue JavaDoc queue,
193      Message JavaDoc message,
194      int deliveryMode,
195      int priority,
196      long timeToLive) throws JMSException JavaDoc;
197 }
198
Popular Tags