KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > store > jdbc > adapter > AxionJDBCAdapter


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.store.jdbc.adapter;
19
20 import org.apache.activemq.store.jdbc.Statements;
21
22 /**
23  * Axion specific Adapter.
24  *
25  * Axion does not seem to support ALTER statements or sub-selects. This means:
26  * - We cannot auto upgrade the schema was we roll out new versions of ActiveMQ
27  * - We cannot delete durable sub messages that have be acknowledged by all consumers.
28  *
29  * @org.apache.xbean.XBean element="axionJDBCAdapter"
30  * @version $Revision: 1.4 $
31  */

32 public class AxionJDBCAdapter extends StreamJDBCAdapter {
33
34     public void setStatements(Statements statements) {
35         
36         statements.setCreateSchemaStatements(
37                 new String JavaDoc[]{
38                         "CREATE TABLE "+statements.getFullMessageTableName()+"("
39                                +"ID "+statements.getSequenceDataType()+" NOT NULL"
40                                +", CONTAINER "+statements.getContainerNameDataType()
41                                +", MSGID_PROD "+statements.getMsgIdDataType()
42                                +", MSGID_SEQ "+statements.getSequenceDataType()
43                                +", EXPIRATION "+statements.getLongDataType()
44                                +", MSG "+(statements.isUseExternalMessageReferences() ? statements.getStringIdDataType() : statements.getBinaryDataType())
45                                +", PRIMARY KEY ( ID ) )",
46                          "CREATE INDEX "+statements.getFullMessageTableName()+"_MIDX ON "+statements.getFullMessageTableName()+" (MSGID_PROD,MSGID_SEQ)",
47                          "CREATE INDEX "+statements.getFullMessageTableName()+"_CIDX ON "+statements.getFullMessageTableName()+" (CONTAINER)",
48                          "CREATE INDEX "+statements.getFullMessageTableName()+"_EIDX ON "+statements.getFullMessageTableName()+" (EXPIRATION)",
49                          "CREATE TABLE "+statements.getFullAckTableName()+"("
50                                +"CONTAINER "+statements.getContainerNameDataType()+" NOT NULL"
51                                +", CLIENT_ID "+statements.getStringIdDataType()+" NOT NULL"
52                                +", SUB_NAME "+statements.getStringIdDataType()+" NOT NULL"
53                                +", SELECTOR "+statements.getStringIdDataType()
54                                +", LAST_ACKED_ID "+statements.getSequenceDataType()
55                                +", PRIMARY KEY ( CONTAINER, CLIENT_ID, SUB_NAME))",
56                     }
57         );
58         statements.setDeleteOldMessagesStatement("DELETE FROM "+statements.getFullMessageTableName()+ " WHERE ( EXPIRATION<>0 AND EXPIRATION<?)");
59         statements.setLongDataType("LONG");
60         
61         super.setStatements(statements);
62     }
63     
64 }
65
Popular Tags