View Javadoc

1   /*** 
2    * 
3    * Copyright 2004 Protique Ltd
4    * 
5    * Licensed under the Apache License, Version 2.0 (the "License"); 
6    * you may not use this file except in compliance with the License. 
7    * You may obtain a copy of the License at 
8    * 
9    * http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, 
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
14   * See the License for the specific language governing permissions and 
15   * limitations under the License. 
16   * 
17   **/
18  package org.codehaus.activemq.service;
19  
20  import org.codehaus.activemq.message.ActiveMQMessage;
21  
22  import javax.jms.JMSException;
23  
24  /***
25   * A Queue based {@link MessageContainer}
26   *
27   * @version $Revision: 1.6 $
28   */
29  public interface QueueMessageContainer extends MessageContainer {
30  
31      /***
32       * Some implementations may need to poll to fill subscriptions
33       * this returns the next message in the container
34       *
35       * @return the next message
36       * @throws javax.jms.JMSException
37       */
38      public ActiveMQMessage poll() throws JMSException;
39  
40      /***
41       * Used for browsing a MessageContainer
42       * this returns the next message in the container after the messageId
43       *
44       * @param messageIdentity the id if the message. If this is null, the first message will be retrieved
45       * @return the next message without updating it's state to being dispatched
46       * @throws JMSException
47       */
48  
49      public ActiveMQMessage peekNext(MessageIdentity messageIdentity) throws JMSException;
50  
51      /***
52       * After a poll() on the Container, if a message can't be dispatched, it is returned
53       *
54       * @param messageIdentity
55       * @throws JMSException
56       */
57      public void returnMessage(MessageIdentity messageIdentity) throws JMSException;
58  
59      /***
60       * called to reset dispatch pointers if a new Message Consumer joins
61       *
62       * @throws JMSException
63       */
64      public void reset() throws JMSException;
65  
66      /***
67       * This container has just been loaded from disk and so it needs to be recovered,
68       * that is iterate through all the message IDs in the persistent store and
69       * add them to the in memory list of message IDs to be dispatched by consumers
70       */
71      public void start() throws JMSException;
72  
73  
74      /***
75       * Invoked during the recovery to add the given message to the end of
76       * the messages to be delivered.
77       */
78      public void recoverMessageToBeDelivered(MessageIdentity messageIdentity) throws JMSException;
79  }