001 /** 002 * 003 * Copyright 2004 Protique Ltd 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.adapter; 019 020 import org.activemq.store.jdbc.StatementProvider; 021 022 /** 023 * Axion specific Adapter. 024 * 025 * Axion does not seem to support ALTER statments or Subselects. This means: 026 * - We cannot auto upgrade the schema was we roll out new versions of ActiveMQ 027 * - We cannot delete durable sub messages that have be acknowleged by all consumers. 028 * 029 * @version $Revision: 1.1 $ 030 */ 031 public class AxionJDBCAdapter extends StreamJDBCAdapter { 032 033 public static StatementProvider createStatementProvider() { 034 DefaultStatementProvider answer = new DefaultStatementProvider() { 035 public String [] getCreateSchemaStatments() { 036 return new String[]{ 037 "CREATE TABLE "+tablePrefix+messageTableName+"(" 038 +"ID "+sequenceDataType+" NOT NULL" 039 +", CONTAINER "+containerNameDataType 040 +", MSGID "+msgIdDataType 041 +", MSG "+binaryDataType 042 +", EXPIRATION "+longDataType 043 +", PRIMARY KEY ( ID ) )", 044 "CREATE INDEX "+tablePrefix+messageTableName+"_MIDX ON "+tablePrefix+messageTableName+" (MSGID)", 045 "CREATE INDEX "+tablePrefix+messageTableName+"_CIDX ON "+tablePrefix+messageTableName+" (CONTAINER)", 046 "CREATE TABLE "+tablePrefix+txTableName+"(" 047 +"XID "+xidDataType+" NOT NULL" 048 +", PRIMARY KEY ( XID ))", 049 "CREATE TABLE "+tablePrefix+durableSubAcksTableName+"(" 050 +"SUB "+subscriptionIdDataType+" NOT NULL" 051 +", CONTAINER "+containerNameDataType+" NOT NULL" 052 +", LAST_ACKED_ID "+sequenceDataType 053 +", SE_ID INTEGER" 054 +", SE_CLIENT_ID "+stringIdDataType 055 +", SE_CONSUMER_NAME "+stringIdDataType 056 +", SE_SELECTOR "+stringIdDataType 057 +", PRIMARY KEY ( SUB, CONTAINER ))", 058 "CREATE INDEX "+tablePrefix+durableSubAcksTableName+"_CIDX ON "+tablePrefix+durableSubAcksTableName+" (CONTAINER)", 059 }; 060 } 061 062 public String getDeleteOldMessagesStatment() { 063 return "DELETE FROM "+tablePrefix+messageTableName+ 064 " WHERE ( EXPIRATION<>0 AND EXPIRATION<?)"; 065 } 066 067 }; 068 answer.setLongDataType("LONG"); 069 return answer; 070 } 071 072 public AxionJDBCAdapter() { 073 this(createStatementProvider()); 074 } 075 076 public AxionJDBCAdapter(StatementProvider provider) { 077 super(provider); 078 } 079 }