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