KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exolab > jms > messagemgr > MessageHandle


1 /**
2  * Redistribution and use of this software and associated documentation
3  * ("Software"), with or without modification, are permitted provided
4  * that the following conditions are met:
5  *
6  * 1. Redistributions of source code must retain copyright
7  * statements and notices. Redistributions must also contain a
8  * copy of this document.
9  *
10  * 2. Redistributions in binary form must reproduce the
11  * above copyright notice, this list of conditions and the
12  * following disclaimer in the documentation and/or other
13  * materials provided with the distribution.
14  *
15  * 3. The name "Exolab" must not be used to endorse or promote
16  * products derived from this Software without prior written
17  * permission of Exoffice Technologies. For written permission,
18  * please contact info@exolab.org.
19  *
20  * 4. Products derived from this Software may not be called "Exolab"
21  * nor may "Exolab" appear in their names without prior written
22  * permission of Exoffice Technologies. Exolab is a registered
23  * trademark of Exoffice Technologies.
24  *
25  * 5. Due credit should be given to the Exolab Project
26  * (http://www.exolab.org/).
27  *
28  * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
29  * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
30  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
32  * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39  * OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * Copyright 2001-2005 (C) Exoffice Technologies Inc. All Rights Reserved.
42  *
43  * $Id: MessageHandle.java,v 1.1 2005/03/18 03:58:39 tanderson Exp $
44  */

45 package org.exolab.jms.messagemgr;
46
47 import java.sql.Connection JavaDoc;
48 import javax.jms.MessageConsumer JavaDoc;
49 import javax.jms.JMSException JavaDoc;
50
51 import org.exolab.jms.client.JmsDestination;
52 import org.exolab.jms.message.MessageImpl;
53 import org.exolab.jms.persistence.PersistenceException;
54
55
56 /**
57  * A message handle is used to indirectly reference a message.
58  *
59  * @version $Revision: 1.1 $ $Date: 2005/03/18 03:58:39 $
60  * @author <a HREF="mailto:jima@comware.com.au">Jim Alateras</a>
61  * @author <a HREF="mailto:tma@netspace.net.au">Tim Anderson</a>
62  * @see MessageHandleComparator
63  */

64 public interface MessageHandle {
65
66     /**
67      * Returns the message identifier.
68      *
69      * @return the message identifier
70      */

71     String JavaDoc getMessageId();
72
73     /**
74      * Indicates if a message has been delivered to a {@link MessageConsumer},
75      * but not acknowledged.
76      *
77      * @param delivered if <code>true</code> indicates that an attempt has
78      * been made to deliver the message
79      */

80     void setDelivered(boolean delivered);
81
82     /**
83      * Returns if an attempt has already been made to deliver the message.
84      *
85      * @return <code>true</code> if delivery has been attempted
86      */

87     boolean getDelivered();
88
89     /**
90      * Returns the priority of the message.
91      *
92      * @return the message priority
93      */

94     int getPriority();
95
96     /**
97      * Returns the time that the corresponding message was accepted,
98      * in milliseconds.
99      *
100      * @return the time that the corresponding message was accepted
101      */

102     long getAcceptedTime();
103
104     /**
105      * Returns the time that the message expires, in milliseconds.
106      *
107      * @return the expiry time
108      */

109     long getExpiryTime();
110
111     /**
112      * Determines if the message has expired.
113      *
114      * @return <code>true</code> if the message has expired, otherwise
115      * <code>false</code>
116      */

117     boolean hasExpired();
118
119     /**
120      * Returns the handle's sequence number.
121      *
122      * @return the sequence number
123      */

124     long getSequenceNumber();
125
126     /**
127      * Returns the message destination.
128      *
129      * @return the message destination
130      */

131     JmsDestination getDestination();
132
133     /**
134      * Returns the consumer identity associated with the message.
135      *
136      * @return the consumer identity associated with the message, or
137      * * <code>-1</code> if the message isn't associated with a consumer
138      */

139     long getConsumerId();
140
141     /**
142      * Returns the connection identity associated with the message.
143      *
144      * @return the connection identity associated with the message, or
145      * <code>-1</code> if the message isn't associated with a connection
146      */

147     long getConnectionId();
148
149     /**
150      * Returns the persistent identity of the the consumer endpoint that owns
151      * this handle. If it is set, then a consumer owns it exclusively,
152      * otherwise the handle may be shared across a number of consumers.
153
154      * @return the consumer's persistent identity, or <code>null</code>
155      */

156     String JavaDoc getConsumerPersistentId();
157
158     /**
159      * Determines if the handle is persistent.
160      *
161      * @return <code>true</code> if the handle is persistent; otherwise
162      * <code>false</code>
163      */

164     boolean isPersistent();
165
166     /**
167      * Returns the message associated with this handle.
168      *
169      * @return the associated message, or <code>null</code> if the handle
170      * is no longer valid
171      * @throws JMSException for any error
172      */

173     MessageImpl getMessage() throws JMSException JavaDoc;
174
175     /**
176      * Make the handle persistent.
177      *
178      * @param connection the connection to use
179      * @throws PersistenceException for any persistence error
180      */

181     void add(Connection JavaDoc connection) throws PersistenceException;
182
183     /**
184      * Update the persistent handle.
185      *
186      * @param connection the connection to use
187      * @throws PersistenceException for any persistence error
188      */

189     void update(Connection JavaDoc connection) throws PersistenceException;
190
191     /**
192      * Destroy this handle. If this is the last handle to reference the
193      * message, also destroys the message.
194      *
195      * @throws JMSException for any error
196      */

197     void destroy() throws JMSException JavaDoc;
198
199     /**
200      * Destroy this handle. If this is the last handle to reference the
201      * message, also destroys the message.
202      *
203      * @param connection the connection to use
204      * @throws JMSException for any error
205      * @throws PersistenceException for any persistence error
206      */

207     void destroy(Connection JavaDoc connection) throws JMSException JavaDoc, PersistenceException;
208
209     /**
210      * Returns the message reference.
211      *
212      * @return the message reference, or <code>null</code> if none has been set
213      */

214     MessageRef getMessageRef();
215
216 }
217
218
Popular Tags