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