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.store; 19 20 import org.codehaus.activemq.service.QueueMessageContainer; 21 import org.codehaus.activemq.service.Service; 22 import org.codehaus.activemq.service.TopicMessageContainer; 23 24 import javax.jms.JMSException; 25 import java.util.Map; 26 27 /*** 28 * Adapter to the actual persistence mechanism used with ActiveMQ 29 * 30 * @version $Revision: 1.3 $ 31 */ 32 public interface PersistenceAdapter extends Service { 33 34 /*** 35 * Returns a map, indexed by String name, of all the {@link javax.jms.Destination} 36 * objects active on startup. 37 * 38 * @return 39 */ 40 public Map getInitialDestinations(); 41 42 43 /*** 44 * Factory method to create a new queue message store with the given destination name 45 */ 46 public MessageStore createQueueMessageStore(String destinationName) throws JMSException; 47 48 /*** 49 * Factory method to create a new topic message store with the given destination name 50 */ 51 public TopicMessageStore createTopicMessageStore(String destinationName) throws JMSException; 52 53 /*** 54 * Factory method to create a new persistent prepared transaction store for XA recovery 55 */ 56 public PreparedTransactionStore createPreparedTransactionStore() throws JMSException; 57 58 /*** 59 * Factory method to create a new durable queue based message contaienr 60 */ 61 public QueueMessageContainer createQueueMessageContainer(String destinationName) throws JMSException; 62 63 /*** 64 * Factory method to create a new durable topic based message container 65 */ 66 public TopicMessageContainer createTopicMessageContainer(String destinationName) throws JMSException; 67 68 /*** 69 * This method starts a transaction on the persistent storage - which is nothing to 70 * do with JMS or XA transactions - its purely a mechanism to perform multiple writes 71 * to a persistent store in 1 transaction as a performance optimisation. 72 * <p/> 73 * Typically one transaction will require one disk synchronization point and so for 74 * real high performance its usually faster to perform many writes within the same 75 * transaction to minimise latency caused by disk synchronization. This is especially 76 * true when using tools like Berkeley Db or embedded JDBC servers. 77 */ 78 public void beginTransaction() throws JMSException; 79 80 81 /*** 82 * Commit a persistence transaction 83 * 84 * @see PersistenceAdapter#beginTransaction() 85 */ 86 public void commitTransaction() throws JMSException; 87 88 /*** 89 * Rollback a persistence transaction 90 * 91 * @see PersistenceAdapter#beginTransaction() 92 */ 93 public void rollbackTransaction(); 94 }