001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  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    package org.apache.activemq.store.jdbc;
018    
019    import java.io.IOException;
020    import java.sql.SQLException;
021    import java.util.Set;
022    import org.apache.activemq.command.ActiveMQDestination;
023    import org.apache.activemq.command.ActiveMQTopic;
024    import org.apache.activemq.command.MessageId;
025    import org.apache.activemq.command.ProducerId;
026    import org.apache.activemq.command.SubscriptionInfo;
027    import org.apache.activemq.command.XATransactionId;
028    
029    /**
030     * 
031     */
032    public interface JDBCAdapter {
033    
034        void setStatements(Statements statementProvider);
035        
036        void doCreateTables(TransactionContext c) throws SQLException, IOException;
037    
038        void doDropTables(TransactionContext c) throws SQLException, IOException;
039    
040        void doAddMessage(TransactionContext c, long sequence, MessageId messageID, ActiveMQDestination destination, byte[] data, long expiration, byte priority, XATransactionId xid) throws SQLException, IOException;
041    
042        void doAddMessageReference(TransactionContext c, long sequence, MessageId messageId, ActiveMQDestination destination, long expirationTime, String messageRef) throws SQLException, IOException;
043    
044        byte[] doGetMessage(TransactionContext c, MessageId id) throws SQLException, IOException;
045        
046        byte[] doGetMessageById(TransactionContext c, long storeSequenceId) throws SQLException, IOException;
047    
048        String doGetMessageReference(TransactionContext c, long id) throws SQLException, IOException;
049    
050        void doRemoveMessage(TransactionContext c, long seq, XATransactionId xid) throws SQLException, IOException;
051    
052        void doRecover(TransactionContext c, ActiveMQDestination destination, JDBCMessageRecoveryListener listener) throws Exception;
053    
054        void doSetLastAck(TransactionContext c, ActiveMQDestination destination, XATransactionId xid, String clientId, String subscriptionName, long seq, long prio) throws SQLException, IOException;
055    
056        void doRecoverSubscription(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, JDBCMessageRecoveryListener listener)
057            throws Exception;
058    
059        void doRecoverNextMessages(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, long seq, long priority, int maxReturned,
060                                   JDBCMessageRecoveryListener listener) throws Exception;
061    
062        void doRecoverNextMessagesWithPriority(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, long seq, long priority, int maxReturned,
063                                   JDBCMessageRecoveryListener listener) throws Exception;
064    
065        void doSetSubscriberEntry(TransactionContext c, SubscriptionInfo subscriptionInfo, boolean retroactive, boolean isPrioritizeMessages) throws SQLException, IOException;
066    
067        SubscriptionInfo doGetSubscriberEntry(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName) throws SQLException, IOException;
068    
069        long[] getStoreSequenceId(TransactionContext c, ActiveMQDestination destination, MessageId messageID) throws SQLException, IOException;
070    
071        void doRemoveAllMessages(TransactionContext c, ActiveMQDestination destinationName) throws SQLException, IOException;
072    
073        void doDeleteSubscription(TransactionContext c, ActiveMQDestination destinationName, String clientId, String subscriptionName) throws SQLException, IOException;
074    
075        void doDeleteOldMessages(TransactionContext c) throws SQLException, IOException;
076    
077        long doGetLastMessageStoreSequenceId(TransactionContext c) throws SQLException, IOException;
078    
079        Set<ActiveMQDestination> doGetDestinations(TransactionContext c) throws SQLException, IOException;
080    
081        void setUseExternalMessageReferences(boolean useExternalMessageReferences);
082    
083        SubscriptionInfo[] doGetAllSubscriptions(TransactionContext c, ActiveMQDestination destination) throws SQLException, IOException;
084    
085        int doGetDurableSubscriberMessageCount(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, boolean isPrioritizeMessages) throws SQLException, IOException;
086    
087        int doGetMessageCount(TransactionContext c, ActiveMQDestination destination) throws SQLException, IOException;
088    
089        void doRecoverNextMessages(TransactionContext c, ActiveMQDestination destination, long nextSeq, long priority, int maxReturned, boolean isPrioritizeMessages, JDBCMessageRecoveryListener listener) throws Exception;
090    
091        long doGetLastAckedDurableSubscriberMessageId(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriberName) throws SQLException, IOException;
092    
093        void doMessageIdScan(TransactionContext c, int limit, JDBCMessageIdScanListener listener) throws SQLException, IOException;
094    
095        long doGetLastProducerSequenceId(TransactionContext c, ProducerId id) throws SQLException, IOException;
096    
097        void doSetLastAckWithPriority(TransactionContext c, ActiveMQDestination destination, XATransactionId xid, String clientId, String subscriptionName, long re, long re1) throws SQLException, IOException;
098    
099        public int getMaxRows();
100    
101        public void setMaxRows(int maxRows);
102    
103        void doRecordDestination(TransactionContext c, ActiveMQDestination destination) throws SQLException, IOException;
104    
105        void doRecoverPreparedOps(TransactionContext c, JdbcMemoryTransactionStore jdbcMemoryTransactionStore) throws SQLException, IOException;
106    
107        void doCommitAddOp(TransactionContext c, long storeSequenceIdForMessageId) throws SQLException, IOException;
108    
109        void doClearLastAck(TransactionContext c, ActiveMQDestination destination, byte priority, String subId, String subName) throws SQLException, IOException;
110    }