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.MessageId;
024    import org.apache.activemq.command.ProducerId;
025    import org.apache.activemq.command.SubscriptionInfo;
026    
027    /**
028     * 
029     */
030    public interface JDBCAdapter {
031    
032        void setStatements(Statements statementProvider);
033        
034        void doCreateTables(TransactionContext c) throws SQLException, IOException;
035    
036        void doDropTables(TransactionContext c) throws SQLException, IOException;
037    
038        void doAddMessage(TransactionContext c, long sequence, MessageId messageID, ActiveMQDestination destination, byte[] data, long expiration, byte priority) throws SQLException, IOException;
039    
040        void doAddMessageReference(TransactionContext c, long sequence, MessageId messageId, ActiveMQDestination destination, long expirationTime, String messageRef) throws SQLException, IOException;
041    
042        byte[] doGetMessage(TransactionContext c, MessageId id) throws SQLException, IOException;
043        
044        byte[] doGetMessageById(TransactionContext c, long storeSequenceId) throws SQLException, IOException;
045    
046        String doGetMessageReference(TransactionContext c, long id) throws SQLException, IOException;
047    
048        void doRemoveMessage(TransactionContext c, long seq) throws SQLException, IOException;
049    
050        void doRecover(TransactionContext c, ActiveMQDestination destination, JDBCMessageRecoveryListener listener) throws Exception;
051    
052        void doSetLastAck(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, long seq, long prio) throws SQLException, IOException;
053    
054        void doRecoverSubscription(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, JDBCMessageRecoveryListener listener)
055            throws Exception;
056    
057        void doRecoverNextMessages(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, long seq, long priority, int maxReturned,
058                                   JDBCMessageRecoveryListener listener) throws Exception;
059    
060        void doRecoverNextMessagesWithPriority(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, long seq, long priority, int maxReturned,
061                                   JDBCMessageRecoveryListener listener) throws Exception;
062    
063        void doSetSubscriberEntry(TransactionContext c, SubscriptionInfo subscriptionInfo, boolean retroactive, boolean isPrioritizeMessages) throws SQLException, IOException;
064    
065        SubscriptionInfo doGetSubscriberEntry(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName) throws SQLException, IOException;
066    
067        long[] getStoreSequenceId(TransactionContext c, ActiveMQDestination destination, MessageId messageID) throws SQLException, IOException;
068    
069        void doRemoveAllMessages(TransactionContext c, ActiveMQDestination destinationName) throws SQLException, IOException;
070    
071        void doDeleteSubscription(TransactionContext c, ActiveMQDestination destinationName, String clientId, String subscriptionName) throws SQLException, IOException;
072    
073        void doDeleteOldMessages(TransactionContext c) throws SQLException, IOException;
074    
075        long doGetLastMessageStoreSequenceId(TransactionContext c) throws SQLException, IOException;
076    
077        Set<ActiveMQDestination> doGetDestinations(TransactionContext c) throws SQLException, IOException;
078    
079        void setUseExternalMessageReferences(boolean useExternalMessageReferences);
080    
081        SubscriptionInfo[] doGetAllSubscriptions(TransactionContext c, ActiveMQDestination destination) throws SQLException, IOException;
082    
083        int doGetDurableSubscriberMessageCount(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, boolean isPrioritizeMessages) throws SQLException, IOException;
084    
085        int doGetMessageCount(TransactionContext c, ActiveMQDestination destination) throws SQLException, IOException;
086    
087        void doRecoverNextMessages(TransactionContext c, ActiveMQDestination destination, long nextSeq, long priority, int maxReturned, boolean isPrioritizeMessages, JDBCMessageRecoveryListener listener) throws Exception;
088    
089        long doGetLastAckedDurableSubscriberMessageId(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriberName) throws SQLException, IOException;
090    
091        void doMessageIdScan(TransactionContext c, int limit, JDBCMessageIdScanListener listener) throws SQLException, IOException;
092    
093        long doGetLastProducerSequenceId(TransactionContext c, ProducerId id) throws SQLException, IOException;
094    
095        void doSetLastAckWithPriority(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, long re, long re1) throws SQLException, IOException;
096    
097        public int getMaxRows();
098    
099        public void setMaxRows(int maxRows);
100    
101        void doRecordDestination(TransactionContext c, ActiveMQDestination destination) throws SQLException, IOException;
102    }