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