001    /** 
002     * 
003     * Copyright 2004 Protique Ltd
004     * 
005     * Licensed under the Apache License, Version 2.0 (the "License"); 
006     * you may not use this file except in compliance with the License. 
007     * You may obtain a copy of the License at 
008     * 
009     * http://www.apache.org/licenses/LICENSE-2.0
010     * 
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS, 
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
014     * See the License for the specific language governing permissions and 
015     * limitations under the License. 
016     * 
017     **/
018    package org.activemq.store;
019    
020    import java.util.Map;
021    
022    import javax.jms.JMSException;
023    
024    import org.activemq.service.Service;
025    
026    /**
027     * Adapter to the actual persistence mechanism used with ActiveMQ
028     *
029     * @version $Revision: 1.1.1.1 $
030     */
031    public interface PersistenceAdapter extends Service {
032    
033        /**
034         * Returns a map, indexed by String name, of all the {@link javax.jms.Destination}
035         * objects active on startup.
036         *
037         * @return
038         */
039        public Map getInitialDestinations();
040    
041    
042        /**
043         * Factory method to create a new queue message store with the given destination name
044         */
045        public MessageStore createQueueMessageStore(String destinationName) throws JMSException;
046    
047        /**
048         * Factory method to create a new topic message store with the given destination name
049         */
050        public TopicMessageStore createTopicMessageStore(String destinationName) throws JMSException;
051    
052        /**
053         * Factory method to create a new persistent prepared transaction store for XA recovery
054         */
055        public TransactionStore createTransactionStore() throws JMSException;
056    
057        /**
058         * This method starts a transaction on the persistent storage - which is nothing to
059         * do with JMS or XA transactions - its purely a mechanism to perform multiple writes
060         * to a persistent store in 1 transaction as a performance optimisation.
061         * <p/>
062         * Typically one transaction will require one disk synchronization point and so for
063         * real high performance its usually faster to perform many writes within the same
064         * transaction to minimise latency caused by disk synchronization. This is especially
065         * true when using tools like Berkeley Db or embedded JDBC servers.
066         */
067        public void beginTransaction() throws JMSException;
068    
069    
070        /**
071         * Commit a persistence transaction
072         *
073         * @see PersistenceAdapter#beginTransaction()
074         */
075        public void commitTransaction() throws JMSException;
076    
077        /**
078         * Rollback a persistence transaction
079         *
080         * @see PersistenceAdapter#beginTransaction()
081         */
082        public void rollbackTransaction();
083        
084        /**
085         * Verifies if a dead letter has already been sent for a message  
086         * @param seq
087         * @param useDatabaseLocking to prevent concurrency/dups
088         * @return
089         */
090        public boolean deadLetterAlreadySent(long seq, boolean useDatabaseLocking);
091    }