KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > store > MessageStore


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
4  * file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
5  * to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
6  * License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
11  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
12  * specific language governing permissions and limitations under the License.
13  */

14
15 package org.apache.activemq.store;
16
17 import java.io.IOException JavaDoc;
18 import org.apache.activemq.Service;
19 import org.apache.activemq.broker.ConnectionContext;
20 import org.apache.activemq.command.ActiveMQDestination;
21 import org.apache.activemq.command.Message;
22 import org.apache.activemq.command.MessageAck;
23 import org.apache.activemq.command.MessageId;
24 import org.apache.activemq.memory.UsageManager;
25
26 /**
27  * Represents a message store which is used by the persistent
28  * implementations
29  *
30  * @version $Revision: 1.5 $
31  */

32 public interface MessageStore extends Service{
33
34     /**
35      * Adds a message to the message store
36      *
37      * @param context context
38      * @param message
39      * @throws IOException
40      */

41     public void addMessage(ConnectionContext context,Message message) throws IOException JavaDoc;
42
43     /**
44      * Looks up a message using either the String messageID or the messageNumber. Implementations are encouraged to fill
45      * in the missing key if its easy to do so.
46      *
47      * @param identity which contains either the messageID or the messageNumber
48      * @return the message or null if it does not exist
49      * @throws IOException
50      */

51     public Message getMessage(MessageId identity) throws IOException JavaDoc;
52
53     /**
54      * Removes a message from the message store.
55      *
56      * @param context
57      * @param ack the ack request that cause the message to be removed. It conatins the identity which contains the
58      * messageID of the message that needs to be removed.
59      * @throws IOException
60      */

61     public void removeMessage(ConnectionContext context,MessageAck ack) throws IOException JavaDoc;
62
63     /**
64      * Removes all the messages from the message store.
65      *
66      * @param context
67      * @throws IOException
68      */

69     public void removeAllMessages(ConnectionContext context) throws IOException JavaDoc;
70
71     /**
72      * Recover any messages to be delivered.
73      *
74      * @param container
75      * @throws Exception
76      */

77     public void recover(MessageRecoveryListener container) throws Exception JavaDoc;
78
79     /**
80      * The destination that the message store is holding messages for.
81      *
82      * @return the destination
83      */

84     public ActiveMQDestination getDestination();
85
86     /**
87      * @param usageManager The UsageManager that is controlling the destination's memory usage.
88      */

89     public void setUsageManager(UsageManager usageManager);
90
91     /**
92      * @return the number of messages ready to deliver
93      * @throws IOException
94      *
95      */

96     public int getMessageCount() throws IOException JavaDoc;
97
98     /**
99      * A hint to the Store to reset any batching state for the Destination
100      *
101      * @param nextToDispatch
102      *
103      */

104     public void resetBatching();
105
106     
107     public void recoverNextMessages(int maxReturned,MessageRecoveryListener listener)
108             throws Exception JavaDoc;
109     
110 }
111
Popular Tags