001 /** 002 * 003 * Copyright 2004 Hiram Chirino 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * 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 **/ 018 package org.activemq.store.jdbc; 019 020 import java.sql.Connection; 021 import java.sql.SQLException; 022 023 import javax.jms.JMSException; 024 import javax.transaction.xa.XAException; 025 026 import org.activemq.message.ActiveMQXid; 027 import org.activemq.service.SubscriberEntry; 028 import org.activemq.store.TransactionStore.RecoveryListener; 029 import org.activemq.util.LongSequenceGenerator; 030 import org.activemq.service.MessageIdentity; 031 032 /** 033 * @version $Revision: 1.1 $ 034 */ 035 public interface JDBCAdapter { 036 037 public interface MessageListResultHandler { 038 public void onMessage(long seq, String messageID) throws JMSException; 039 } 040 041 public interface ExpiredMessageResultHandler { 042 public void onMessage(long seq, String container, String messageID, boolean isSentToDeadLetter) throws JMSException; 043 } 044 045 public abstract LongSequenceGenerator getSequenceGenerator(); 046 public abstract void doCreateTables(Connection c) throws SQLException; 047 public abstract void doDropTables(Connection c) throws SQLException; 048 public abstract void initSequenceGenerator(Connection c); 049 public abstract void doAddMessage(Connection c, long seq, String messageID, 050 String destinationName, byte[] data, long expiration) throws SQLException, 051 JMSException; 052 public abstract byte[] doGetMessage(Connection c, long seq) 053 throws SQLException; 054 public abstract void doGetMessageForUpdate(Connection c, long seq, boolean useLocking, ExpiredMessageResultHandler handler) 055 throws SQLException, JMSException; 056 public abstract void doRemoveMessage(Connection c, long seq) 057 throws SQLException; 058 public abstract void doRecover(Connection c, String destinationName, MessageListResultHandler listener) 059 throws SQLException, JMSException; 060 public abstract void doRemoveXid(Connection c, ActiveMQXid xid) 061 throws SQLException, XAException; 062 public abstract void doAddXid(Connection c, ActiveMQXid xid) 063 throws SQLException, XAException; 064 public abstract void doLoadPreparedTransactions(Connection c, 065 RecoveryListener listener) throws SQLException; 066 public abstract void doSetLastAck(Connection c, String destinationName, String sub, long seq) 067 throws SQLException, JMSException; 068 public abstract void doRecoverSubscription(Connection c, String destinationName, String sub, MessageListResultHandler listener) 069 throws SQLException, JMSException; 070 public abstract void doSetSubscriberEntry(Connection c, String destinationName, String sub, SubscriberEntry subscriberEntry) 071 throws SQLException, JMSException; 072 public abstract SubscriberEntry doGetSubscriberEntry(Connection c, String destinationName, String sub) 073 throws SQLException, JMSException; 074 public abstract Long getMessageSequenceId(Connection c, String messageID) 075 throws SQLException, JMSException; 076 public abstract void doRemoveAllMessages(Connection c, String destinationName) 077 throws SQLException, JMSException; 078 public abstract void doDeleteSubscription(Connection c, String destinationName, String subscription) 079 throws SQLException, JMSException; 080 public abstract void doDeleteOldMessages(Connection c) 081 throws SQLException, JMSException; 082 public abstract void doGetExpiredMessages(Connection c, ExpiredMessageResultHandler handler) 083 throws SQLException, JMSException; 084 public abstract void doDeleteExpiredMessage(Connection c, MessageIdentity messageIdentity) 085 throws SQLException, JMSException; 086 public void doSetDeadLetterFlag(Connection c, long seq) 087 throws SQLException, JMSException; 088 089 public StatementProvider getStatementProvider(); 090 091 }