/** 
 * 
 * Copyright 2004 Protique Ltd
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 * 
 **/
package org.activemq.store;

import javax.jms.JMSException;

import org.activemq.message.ActiveMQMessage;
import org.activemq.message.MessageAck;
import org.activemq.service.MessageIdentity;
import org.activemq.service.Service;

/**
 * Represents a message store which is used by the persistent {@link org.activemq.service.MessageContainer}
 * implementations
 *
 * @version $Revision: 1.1.1.1 $
 */
public interface MessageStore extends Service {
    
    /**
     * Adds a message to the message store
     */
    public void addMessage(ActiveMQMessage message) throws JMSException;

    /**
     * Looks up a message using either the String messageID or
     * the messageNumber. Implementations are encouraged to fill in the missing
     * key if its easy to do so.
     *
     * @param identity which contains either the messageID or the messageNumber
     * @return the message or null if it does not exist
     */
    public ActiveMQMessage getMessage(MessageIdentity identity) throws JMSException;

    /**
     * Removes a message from the message store.
     *
     * @param ack the ack request that cause the message to be removed.  It conatins 
     *   the identity which contains the messageID of the message that needs to be removed.
     */
    public void removeMessage(MessageAck ack) throws JMSException;

    /**
     * Removes all the messages from the message store.
     */
    public void removeAllMessages() throws JMSException;
    
    /**
     * Recover any messages to be delivered.
     *
     * @param container
     */
    public void recover(RecoveryListener container) throws JMSException;
        
}
