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 019/** 020 * 021 * 022 * @org.apache.xbean.XBean element="statements" 023 * 024 */ 025public class Statements { 026 027 protected String messageTableName = "ACTIVEMQ_MSGS"; 028 protected String durableSubAcksTableName = "ACTIVEMQ_ACKS"; 029 protected String lockTableName = "ACTIVEMQ_LOCK"; 030 protected String binaryDataType = "BLOB"; 031 protected String containerNameDataType = "VARCHAR(250)"; 032 protected String msgIdDataType = "VARCHAR(250)"; 033 protected String sequenceDataType = "BIGINT"; 034 protected String longDataType = "BIGINT"; 035 protected String stringIdDataType = "VARCHAR(250)"; 036 protected boolean useExternalMessageReferences; 037 038 private String tablePrefix = ""; 039 private String addMessageStatement; 040 private String updateMessageStatement; 041 private String removeMessageStatement; 042 private String findMessageSequenceIdStatement; 043 private String findMessageStatement; 044 private String findMessageByIdStatement; 045 private String findAllMessagesStatement; 046 private String findLastSequenceIdInMsgsStatement; 047 private String findLastSequenceIdInAcksStatement; 048 private String createDurableSubStatement; 049 private String findDurableSubStatement; 050 private String findAllDurableSubsStatement; 051 private String updateLastPriorityAckRowOfDurableSubStatement; 052 private String deleteSubscriptionStatement; 053 private String findAllDurableSubMessagesStatement; 054 private String findDurableSubMessagesStatement; 055 private String findDurableSubMessagesByPriorityStatement; 056 private String findAllDestinationsStatement; 057 private String removeAllMessagesStatement; 058 private String removeAllSubscriptionsStatement; 059 private String[] createSchemaStatements; 060 private String[] createLockSchemaStatements; 061 private String[] dropSchemaStatements; 062 private String lockCreateStatement; 063 private String lockUpdateStatement; 064 private String nextDurableSubscriberMessageStatement; 065 private String durableSubscriberMessageCountStatement; 066 private String lastAckedDurableSubscriberMessageStatement; 067 private String destinationMessageCountStatement; 068 private String findNextMessagesStatement; 069 private String findNextMessagesByPriorityStatement; 070 private boolean useLockCreateWhereClause; 071 private String findAllMessageIdsStatement; 072 private String lastProducerSequenceIdStatement; 073 private String selectDurablePriorityAckStatement; 074 075 private String insertDurablePriorityAckStatement; 076 private String updateDurableLastAckStatement; 077 private String deleteOldMessagesStatementWithPriority; 078 private String durableSubscriberMessageCountStatementWithPriority; 079 private String dropAckPKAlterStatementEnd; 080 private String updateXidFlagStatement; 081 private String findOpsPendingOutcomeStatement; 082 private String clearXidFlagStatement; 083 private String updateDurableLastAckInTxStatement; 084 private String findAcksPendingOutcomeStatement; 085 private String clearDurableLastAckInTxStatement; 086 private String updateDurableLastAckWithPriorityStatement; 087 private String updateDurableLastAckWithPriorityInTxStatement; 088 private String findXidByIdStatement; 089 private String leaseObtainStatement; 090 private String currentDateTimeStatement; 091 private String leaseUpdateStatement; 092 private String leaseOwnerStatement; 093 094 public String[] getCreateSchemaStatements() { 095 if (createSchemaStatements == null) { 096 createSchemaStatements = new String[] { 097 "CREATE TABLE " + getFullMessageTableName() + "(" + "ID " + sequenceDataType + " NOT NULL" 098 + ", CONTAINER " + containerNameDataType + ", MSGID_PROD " + msgIdDataType + ", MSGID_SEQ " 099 + sequenceDataType + ", EXPIRATION " + longDataType + ", MSG " 100 + (useExternalMessageReferences ? stringIdDataType : binaryDataType) 101 + ", PRIMARY KEY ( ID ) )", 102 "CREATE INDEX " + getFullMessageTableName() + "_MIDX ON " + getFullMessageTableName() + " (MSGID_PROD,MSGID_SEQ)", 103 "CREATE INDEX " + getFullMessageTableName() + "_CIDX ON " + getFullMessageTableName() + " (CONTAINER)", 104 "CREATE INDEX " + getFullMessageTableName() + "_EIDX ON " + getFullMessageTableName() + " (EXPIRATION)", 105 "CREATE TABLE " + getFullAckTableName() + "(" + "CONTAINER " + containerNameDataType + " NOT NULL" 106 + ", SUB_DEST " + stringIdDataType 107 + ", CLIENT_ID " + stringIdDataType + " NOT NULL" + ", SUB_NAME " + stringIdDataType 108 + " NOT NULL" + ", SELECTOR " + stringIdDataType + ", LAST_ACKED_ID " + sequenceDataType 109 + ", PRIMARY KEY ( CONTAINER, CLIENT_ID, SUB_NAME))", 110 "ALTER TABLE " + getFullMessageTableName() + " ADD PRIORITY " + sequenceDataType, 111 "CREATE INDEX " + getFullMessageTableName() + "_PIDX ON " + getFullMessageTableName() + " (PRIORITY)", 112 "ALTER TABLE " + getFullMessageTableName() + " ADD XID " + stringIdDataType, 113 "ALTER TABLE " + getFullAckTableName() + " ADD PRIORITY " + sequenceDataType + " DEFAULT 5 NOT NULL", 114 "ALTER TABLE " + getFullAckTableName() + " ADD XID " + stringIdDataType, 115 "ALTER TABLE " + getFullAckTableName() + " " + getDropAckPKAlterStatementEnd(), 116 "ALTER TABLE " + getFullAckTableName() + " ADD PRIMARY KEY (CONTAINER, CLIENT_ID, SUB_NAME, PRIORITY)", 117 "CREATE INDEX " + getFullMessageTableName() + "_XIDX ON " + getFullMessageTableName() + " (XID)", 118 "CREATE INDEX " + getFullAckTableName() + "_XIDX ON " + getFullAckTableName() + " (XID)" 119 }; 120 } 121 getCreateLockSchemaStatements(); 122 String[] allCreateStatements = new String[createSchemaStatements.length + createLockSchemaStatements.length]; 123 System.arraycopy(createSchemaStatements, 0, allCreateStatements, 0, createSchemaStatements.length); 124 System.arraycopy(createLockSchemaStatements, 0, allCreateStatements, createSchemaStatements.length, createLockSchemaStatements.length); 125 126 return allCreateStatements; 127 } 128 129 public String[] getCreateLockSchemaStatements() { 130 if (createLockSchemaStatements == null) { 131 createLockSchemaStatements = new String[] { 132 "CREATE TABLE " + getFullLockTableName() 133 + "( ID " + longDataType + " NOT NULL, TIME " + longDataType 134 + ", BROKER_NAME " + stringIdDataType + ", PRIMARY KEY (ID) )", 135 "INSERT INTO " + getFullLockTableName() + "(ID) VALUES (1)" 136 }; 137 } 138 return createLockSchemaStatements; 139 } 140 141 public String getDropAckPKAlterStatementEnd() { 142 if (dropAckPKAlterStatementEnd == null) { 143 dropAckPKAlterStatementEnd = "DROP PRIMARY KEY"; 144 } 145 return dropAckPKAlterStatementEnd; 146 } 147 148 public void setDropAckPKAlterStatementEnd(String dropAckPKAlterStatementEnd) { 149 this.dropAckPKAlterStatementEnd = dropAckPKAlterStatementEnd; 150 } 151 152 public String[] getDropSchemaStatements() { 153 if (dropSchemaStatements == null) { 154 dropSchemaStatements = new String[] {"DROP TABLE " + getFullAckTableName() + "", 155 "DROP TABLE " + getFullMessageTableName() + "", 156 "DROP TABLE " + getFullLockTableName() + ""}; 157 } 158 return dropSchemaStatements; 159 } 160 161 public String getAddMessageStatement() { 162 if (addMessageStatement == null) { 163 addMessageStatement = "INSERT INTO " 164 + getFullMessageTableName() 165 + "(ID, MSGID_PROD, MSGID_SEQ, CONTAINER, EXPIRATION, PRIORITY, MSG, XID) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; 166 } 167 return addMessageStatement; 168 } 169 170 public String getUpdateMessageStatement() { 171 if (updateMessageStatement == null) { 172 updateMessageStatement = "UPDATE " + getFullMessageTableName() + " SET MSG=? WHERE MSGID_PROD=? AND MSGID_SEQ=? AND CONTAINER=?"; 173 } 174 return updateMessageStatement; 175 } 176 177 public String getRemoveMessageStatement() { 178 if (removeMessageStatement == null) { 179 removeMessageStatement = "DELETE FROM " + getFullMessageTableName() + " WHERE ID=?"; 180 } 181 return removeMessageStatement; 182 } 183 184 public String getFindMessageSequenceIdStatement() { 185 if (findMessageSequenceIdStatement == null) { 186 findMessageSequenceIdStatement = "SELECT ID, PRIORITY FROM " + getFullMessageTableName() 187 + " WHERE MSGID_PROD=? AND MSGID_SEQ=? AND CONTAINER=?"; 188 } 189 return findMessageSequenceIdStatement; 190 } 191 192 public String getFindMessageStatement() { 193 if (findMessageStatement == null) { 194 findMessageStatement = "SELECT MSG FROM " + getFullMessageTableName() + " WHERE MSGID_PROD=? AND MSGID_SEQ=?"; 195 } 196 return findMessageStatement; 197 } 198 199 public String getFindMessageByIdStatement() { 200 if (findMessageByIdStatement == null) { 201 findMessageByIdStatement = "SELECT MSG FROM " + getFullMessageTableName() + " WHERE ID=?"; 202 } 203 return findMessageByIdStatement; 204 } 205 206 public String getFindXidByIdStatement() { 207 if (findXidByIdStatement == null) { 208 findXidByIdStatement = "SELECT XID FROM " + getFullMessageTableName() + " WHERE ID=?"; 209 } 210 return findXidByIdStatement; 211 } 212 213 public String getFindAllMessagesStatement() { 214 if (findAllMessagesStatement == null) { 215 findAllMessagesStatement = "SELECT ID, MSG FROM " + getFullMessageTableName() 216 + " WHERE CONTAINER=? ORDER BY ID"; 217 } 218 return findAllMessagesStatement; 219 } 220 221 public String getFindAllMessageIdsStatement() { 222 // this needs to be limited maybe need to use getFindLastSequenceIdInMsgsStatement 223 // and work back for X 224 if (findAllMessageIdsStatement == null) { 225 findAllMessageIdsStatement = "SELECT ID, MSGID_PROD, MSGID_SEQ FROM " + getFullMessageTableName() 226 + " ORDER BY ID DESC"; 227 } 228 return findAllMessageIdsStatement; 229 } 230 231 public void setFindAllMessageIdsStatement(String val) { 232 findAllMessageIdsStatement = val; 233 } 234 235 public String getFindLastSequenceIdInMsgsStatement() { 236 if (findLastSequenceIdInMsgsStatement == null) { 237 findLastSequenceIdInMsgsStatement = "SELECT MAX(ID) FROM " + getFullMessageTableName(); 238 } 239 return findLastSequenceIdInMsgsStatement; 240 } 241 242 public String getLastProducerSequenceIdStatement() { 243 if (lastProducerSequenceIdStatement == null) { 244 lastProducerSequenceIdStatement = "SELECT MAX(MSGID_SEQ) FROM " + getFullMessageTableName() 245 + " WHERE MSGID_PROD=?"; 246 } 247 return lastProducerSequenceIdStatement; 248 } 249 250 251 public String getFindLastSequenceIdInAcksStatement() { 252 if (findLastSequenceIdInAcksStatement == null) { 253 findLastSequenceIdInAcksStatement = "SELECT MAX(LAST_ACKED_ID) FROM " + getFullAckTableName(); 254 } 255 return findLastSequenceIdInAcksStatement; 256 } 257 258 public String getCreateDurableSubStatement() { 259 if (createDurableSubStatement == null) { 260 createDurableSubStatement = "INSERT INTO " 261 + getFullAckTableName() 262 + "(CONTAINER, CLIENT_ID, SUB_NAME, SELECTOR, LAST_ACKED_ID, SUB_DEST, PRIORITY) " 263 + "VALUES (?, ?, ?, ?, ?, ?, ?)"; 264 } 265 return createDurableSubStatement; 266 } 267 268 public String getFindDurableSubStatement() { 269 if (findDurableSubStatement == null) { 270 findDurableSubStatement = "SELECT SELECTOR, SUB_DEST " + "FROM " + getFullAckTableName() 271 + " WHERE CONTAINER=? AND CLIENT_ID=? AND SUB_NAME=?"; 272 } 273 return findDurableSubStatement; 274 } 275 276 public String getFindAllDurableSubsStatement() { 277 if (findAllDurableSubsStatement == null) { 278 findAllDurableSubsStatement = "SELECT SELECTOR, SUB_NAME, CLIENT_ID, SUB_DEST" + " FROM " 279 + getFullAckTableName() + " WHERE CONTAINER=? AND PRIORITY=0"; 280 } 281 return findAllDurableSubsStatement; 282 } 283 284 public String getUpdateLastPriorityAckRowOfDurableSubStatement() { 285 if (updateLastPriorityAckRowOfDurableSubStatement == null) { 286 updateLastPriorityAckRowOfDurableSubStatement = "UPDATE " + getFullAckTableName() + " SET LAST_ACKED_ID=?" 287 + " WHERE CONTAINER=? AND CLIENT_ID=? AND SUB_NAME=? AND PRIORITY=?"; 288 } 289 return updateLastPriorityAckRowOfDurableSubStatement; 290 } 291 292 public String getDeleteSubscriptionStatement() { 293 if (deleteSubscriptionStatement == null) { 294 deleteSubscriptionStatement = "DELETE FROM " + getFullAckTableName() 295 + " WHERE CONTAINER=? AND CLIENT_ID=? AND SUB_NAME=?"; 296 } 297 return deleteSubscriptionStatement; 298 } 299 300 public String getFindAllDurableSubMessagesStatement() { 301 if (findAllDurableSubMessagesStatement == null) { 302 findAllDurableSubMessagesStatement = "SELECT M.ID, M.MSG FROM " + getFullMessageTableName() 303 + " M, " + getFullAckTableName() + " D " 304 + " WHERE D.CONTAINER=? AND D.CLIENT_ID=? AND D.SUB_NAME=?" 305 + " AND M.CONTAINER=D.CONTAINER AND M.ID > D.LAST_ACKED_ID" 306 + " ORDER BY M.PRIORITY DESC, M.ID"; 307 } 308 return findAllDurableSubMessagesStatement; 309 } 310 311 public String getFindDurableSubMessagesStatement() { 312 if (findDurableSubMessagesStatement == null) { 313 findDurableSubMessagesStatement = "SELECT M.ID, M.MSG FROM " + getFullMessageTableName() + " M, " 314 + getFullAckTableName() + " D " 315 + " WHERE D.CONTAINER=? AND D.CLIENT_ID=? AND D.SUB_NAME=?" 316 + " AND M.XID IS NULL" 317 + " AND M.CONTAINER=D.CONTAINER AND M.ID > D.LAST_ACKED_ID" 318 + " AND M.ID > ?" 319 + " ORDER BY M.ID"; 320 } 321 return findDurableSubMessagesStatement; 322 } 323 324 public String getFindDurableSubMessagesByPriorityStatement() { 325 if (findDurableSubMessagesByPriorityStatement == null) { 326 findDurableSubMessagesByPriorityStatement = "SELECT M.ID, M.MSG FROM " + getFullMessageTableName() + " M," 327 + " " + getFullAckTableName() + " D" 328 + " WHERE D.CONTAINER=? AND D.CLIENT_ID=? AND D.SUB_NAME=?" 329 + " AND M.XID IS NULL" 330 + " AND M.CONTAINER=D.CONTAINER" 331 + " AND M.PRIORITY=D.PRIORITY AND M.ID > D.LAST_ACKED_ID" 332 + " AND M.ID > ? AND M.PRIORITY = ?" 333 + " ORDER BY M.ID"; 334 } 335 return findDurableSubMessagesByPriorityStatement; 336 } 337 338 public String getNextDurableSubscriberMessageStatement() { 339 if (nextDurableSubscriberMessageStatement == null) { 340 nextDurableSubscriberMessageStatement = "SELECT M.ID, M.MSG FROM " 341 + getFullMessageTableName() 342 + " M, " 343 + getFullAckTableName() 344 + " D " 345 + " WHERE D.CONTAINER=? AND D.CLIENT_ID=? AND D.SUB_NAME=?" 346 + " AND M.CONTAINER=D.CONTAINER AND M.ID > ?" 347 + " ORDER BY M.ID "; 348 } 349 return nextDurableSubscriberMessageStatement; 350 } 351 352 /** 353 * @return the durableSubscriberMessageCountStatement 354 */ 355 356 public String getDurableSubscriberMessageCountStatement() { 357 if (durableSubscriberMessageCountStatement == null) { 358 durableSubscriberMessageCountStatement = "SELECT COUNT(*) FROM " 359 + getFullMessageTableName() 360 + " M, " 361 + getFullAckTableName() 362 + " D " 363 + " WHERE D.CONTAINER=? AND D.CLIENT_ID=? AND D.SUB_NAME=?" 364 + " AND M.CONTAINER=D.CONTAINER " 365 + " AND M.ID >" 366 + " ( SELECT LAST_ACKED_ID FROM " + getFullAckTableName() 367 + " WHERE CONTAINER=D.CONTAINER AND CLIENT_ID=D.CLIENT_ID" 368 + " AND SUB_NAME=D.SUB_NAME )"; 369 370 } 371 return durableSubscriberMessageCountStatement; 372 } 373 374 public String getDurableSubscriberMessageCountStatementWithPriority() { 375 if (durableSubscriberMessageCountStatementWithPriority == null) { 376 durableSubscriberMessageCountStatementWithPriority = "SELECT COUNT(*) FROM " 377 + getFullMessageTableName() 378 + " M, " 379 + getFullAckTableName() 380 + " D " 381 + " WHERE D.CONTAINER=? AND D.CLIENT_ID=? AND D.SUB_NAME=?" 382 + " AND M.CONTAINER=D.CONTAINER " 383 + " AND M.PRIORITY=D.PRIORITY " 384 + " AND M.ID > D.LAST_ACKED_ID"; 385 } 386 387 return durableSubscriberMessageCountStatementWithPriority; 388 } 389 390 public String getFindAllDestinationsStatement() { 391 if (findAllDestinationsStatement == null) { 392 findAllDestinationsStatement = "SELECT DISTINCT CONTAINER FROM " + getFullMessageTableName() 393 + " UNION SELECT DISTINCT CONTAINER FROM " + getFullAckTableName(); 394 } 395 return findAllDestinationsStatement; 396 } 397 398 public String getRemoveAllMessagesStatement() { 399 if (removeAllMessagesStatement == null) { 400 removeAllMessagesStatement = "DELETE FROM " + getFullMessageTableName() + " WHERE CONTAINER=?"; 401 } 402 return removeAllMessagesStatement; 403 } 404 405 public String getRemoveAllSubscriptionsStatement() { 406 if (removeAllSubscriptionsStatement == null) { 407 removeAllSubscriptionsStatement = "DELETE FROM " + getFullAckTableName() + " WHERE CONTAINER=?"; 408 } 409 return removeAllSubscriptionsStatement; 410 } 411 412 public String getDeleteOldMessagesStatementWithPriority() { 413 if (deleteOldMessagesStatementWithPriority == null) { 414 deleteOldMessagesStatementWithPriority = "DELETE FROM " + getFullMessageTableName() 415 + " WHERE (PRIORITY=? AND ID <= " 416 + " ( SELECT min(" + getFullAckTableName() + ".LAST_ACKED_ID)" 417 + " FROM " + getFullAckTableName() + " WHERE " 418 + getFullAckTableName() + ".CONTAINER=" 419 + getFullMessageTableName() + ".CONTAINER" 420 + " AND " + getFullAckTableName() + ".PRIORITY=?)" 421 + " )"; 422 } 423 return deleteOldMessagesStatementWithPriority; 424 } 425 426 public String getLockCreateStatement() { 427 if (lockCreateStatement == null) { 428 lockCreateStatement = "SELECT * FROM " + getFullLockTableName(); 429 if (useLockCreateWhereClause) { 430 lockCreateStatement += " WHERE ID = 1"; 431 } 432 lockCreateStatement += " FOR UPDATE"; 433 } 434 return lockCreateStatement; 435 } 436 437 public String getLeaseObtainStatement() { 438 if (leaseObtainStatement == null) { 439 leaseObtainStatement = "UPDATE " + getFullLockTableName() 440 + " SET BROKER_NAME=?, TIME=?" 441 + " WHERE (TIME IS NULL OR TIME < ?) AND ID = 1"; 442 } 443 return leaseObtainStatement; 444 } 445 446 public String getCurrentDateTime() { 447 if (currentDateTimeStatement == null) { 448 currentDateTimeStatement = "SELECT CURRENT_TIMESTAMP FROM " + getFullLockTableName(); 449 } 450 return currentDateTimeStatement; 451 } 452 453 public String getLeaseUpdateStatement() { 454 if (leaseUpdateStatement == null) { 455 leaseUpdateStatement = "UPDATE " + getFullLockTableName() 456 + " SET BROKER_NAME=?, TIME=?" 457 + " WHERE BROKER_NAME=? AND ID = 1"; 458 } 459 return leaseUpdateStatement; 460 } 461 462 public String getLeaseOwnerStatement() { 463 if (leaseOwnerStatement == null) { 464 leaseOwnerStatement = "SELECT BROKER_NAME, TIME FROM " + getFullLockTableName() 465 + " WHERE ID = 1"; 466 } 467 return leaseOwnerStatement; 468 } 469 470 public String getLockUpdateStatement() { 471 if (lockUpdateStatement == null) { 472 lockUpdateStatement = "UPDATE " + getFullLockTableName() + " SET TIME = ? WHERE ID = 1"; 473 } 474 return lockUpdateStatement; 475 } 476 477 /** 478 * @return the destinationMessageCountStatement 479 */ 480 public String getDestinationMessageCountStatement() { 481 if (destinationMessageCountStatement == null) { 482 destinationMessageCountStatement = "SELECT COUNT(*) FROM " + getFullMessageTableName() 483 + " WHERE CONTAINER=? AND XID IS NULL"; 484 } 485 return destinationMessageCountStatement; 486 } 487 488 /** 489 * @return the findNextMessagesStatement 490 */ 491 public String getFindNextMessagesStatement() { 492 if (findNextMessagesStatement == null) { 493 findNextMessagesStatement = "SELECT ID, MSG FROM " + getFullMessageTableName() 494 + " WHERE CONTAINER=? AND ID < ? AND ID > ? AND XID IS NULL ORDER BY ID"; 495 } 496 return findNextMessagesStatement; 497 } 498 499 /** 500 * @return the findNextMessagesStatement 501 */ 502 public String getFindNextMessagesByPriorityStatement() { 503 if (findNextMessagesByPriorityStatement == null) { 504 findNextMessagesByPriorityStatement = "SELECT ID, MSG FROM " + getFullMessageTableName() 505 + " WHERE CONTAINER=?" 506 + " AND XID IS NULL" 507 + " AND ID < ? " 508 + " AND ( (ID > ? AND PRIORITY = 9) " 509 + " OR (ID > ? AND PRIORITY = 8) " 510 + " OR (ID > ? AND PRIORITY = 7) " 511 + " OR (ID > ? AND PRIORITY = 6) " 512 + " OR (ID > ? AND PRIORITY = 5) " 513 + " OR (ID > ? AND PRIORITY = 4) " 514 + " OR (ID > ? AND PRIORITY = 3) " 515 + " OR (ID > ? AND PRIORITY = 2) " 516 + " OR (ID > ? AND PRIORITY = 1) " 517 + " OR (ID > ? AND PRIORITY = 0) )" 518 + " ORDER BY PRIORITY DESC, ID"; 519 } 520 return findNextMessagesByPriorityStatement; 521 } 522 523 public void setFindNextMessagesByPriorityStatement(String val) { 524 findNextMessagesByPriorityStatement = val; 525 } 526 527 /** 528 * @return the lastAckedDurableSubscriberMessageStatement 529 */ 530 public String getLastAckedDurableSubscriberMessageStatement() { 531 if (lastAckedDurableSubscriberMessageStatement == null) { 532 lastAckedDurableSubscriberMessageStatement = "SELECT MAX(LAST_ACKED_ID) FROM " 533 + getFullAckTableName() 534 + " WHERE CONTAINER=? AND CLIENT_ID=? AND SUB_NAME=?"; 535 } 536 return lastAckedDurableSubscriberMessageStatement; 537 } 538 539 public String getSelectDurablePriorityAckStatement() { 540 if (selectDurablePriorityAckStatement == null) { 541 selectDurablePriorityAckStatement = "SELECT LAST_ACKED_ID FROM " + getFullAckTableName() 542 + " WHERE CONTAINER=? AND CLIENT_ID=? AND SUB_NAME=?" 543 + " AND PRIORITY = ?"; 544 } 545 return selectDurablePriorityAckStatement; 546 } 547 548 public String getInsertDurablePriorityAckStatement() { 549 if (insertDurablePriorityAckStatement == null) { 550 insertDurablePriorityAckStatement = "INSERT INTO " 551 + getFullAckTableName() 552 + "(CONTAINER, CLIENT_ID, SUB_NAME, PRIORITY)" 553 + " VALUES (?, ?, ?, ?)"; 554 } 555 return insertDurablePriorityAckStatement; 556 } 557 558 559 public String getUpdateDurableLastAckStatement() { 560 if (updateDurableLastAckStatement == null) { 561 updateDurableLastAckStatement = "UPDATE " + getFullAckTableName() 562 + " SET LAST_ACKED_ID=?, XID = NULL WHERE CONTAINER=? AND CLIENT_ID=? AND SUB_NAME=?"; 563 } 564 return updateDurableLastAckStatement; 565 } 566 567 public String getUpdateDurableLastAckInTxStatement() { 568 if (updateDurableLastAckInTxStatement == null) { 569 updateDurableLastAckInTxStatement = "UPDATE " + getFullAckTableName() 570 + " SET XID=? WHERE CONTAINER=? AND CLIENT_ID=? AND SUB_NAME=?"; 571 } 572 return updateDurableLastAckInTxStatement; 573 } 574 575 public String getUpdateDurableLastAckWithPriorityStatement() { 576 if (updateDurableLastAckWithPriorityStatement == null) { 577 updateDurableLastAckWithPriorityStatement = "UPDATE " + getFullAckTableName() 578 + " SET LAST_ACKED_ID=?, XID = NULL WHERE CONTAINER=? AND CLIENT_ID=? AND SUB_NAME=? AND PRIORITY=?"; 579 } 580 return updateDurableLastAckWithPriorityStatement; 581 } 582 583 public String getUpdateDurableLastAckWithPriorityInTxStatement() { 584 if (updateDurableLastAckWithPriorityInTxStatement == null) { 585 updateDurableLastAckWithPriorityInTxStatement = "UPDATE " + getFullAckTableName() 586 + " SET XID=? WHERE CONTAINER=? AND CLIENT_ID=? AND SUB_NAME=? AND PRIORITY=?"; 587 } 588 return updateDurableLastAckWithPriorityInTxStatement; 589 } 590 591 public String getClearDurableLastAckInTxStatement() { 592 if (clearDurableLastAckInTxStatement == null) { 593 clearDurableLastAckInTxStatement = "UPDATE " + getFullAckTableName() 594 + " SET XID = NULL WHERE CONTAINER=? AND CLIENT_ID=? AND SUB_NAME=? AND PRIORITY=?"; 595 } 596 return clearDurableLastAckInTxStatement; 597 } 598 599 public String getFindOpsPendingOutcomeStatement() { 600 if (findOpsPendingOutcomeStatement == null) { 601 findOpsPendingOutcomeStatement = "SELECT ID, XID, MSG FROM " + getFullMessageTableName() 602 + " WHERE XID IS NOT NULL ORDER BY ID"; 603 } 604 return findOpsPendingOutcomeStatement; 605 } 606 607 public String getFindAcksPendingOutcomeStatement() { 608 if (findAcksPendingOutcomeStatement == null) { 609 findAcksPendingOutcomeStatement = "SELECT XID," + 610 " CONTAINER, CLIENT_ID, SUB_NAME FROM " + getFullAckTableName() 611 + " WHERE XID IS NOT NULL"; 612 } 613 return findAcksPendingOutcomeStatement; 614 } 615 616 public String getUpdateXidFlagStatement() { 617 if (updateXidFlagStatement == null) { 618 updateXidFlagStatement = "UPDATE " + getFullMessageTableName() 619 + " SET XID = ? WHERE ID = ?"; 620 } 621 return updateXidFlagStatement; 622 } 623 624 public String getClearXidFlagStatement() { 625 if (clearXidFlagStatement == null) { 626 clearXidFlagStatement = "UPDATE " + getFullMessageTableName() 627 + " SET XID = NULL, ID = ? WHERE ID = ?"; 628 } 629 return clearXidFlagStatement; 630 } 631 632 public String getFullMessageTableName() { 633 return getTablePrefix() + getMessageTableName(); 634 } 635 636 public String getFullAckTableName() { 637 return getTablePrefix() + getDurableSubAcksTableName(); 638 } 639 640 public String getFullLockTableName() { 641 return getTablePrefix() + getLockTableName(); 642 } 643 644 /** 645 * @return Returns the containerNameDataType. 646 */ 647 public String getContainerNameDataType() { 648 return containerNameDataType; 649 } 650 651 /** 652 * @param containerNameDataType The containerNameDataType to set. 653 */ 654 public void setContainerNameDataType(String containerNameDataType) { 655 this.containerNameDataType = containerNameDataType; 656 } 657 658 /** 659 * @return Returns the messageDataType. 660 */ 661 public String getBinaryDataType() { 662 return binaryDataType; 663 } 664 665 /** 666 * @param messageDataType The messageDataType to set. 667 */ 668 public void setBinaryDataType(String messageDataType) { 669 this.binaryDataType = messageDataType; 670 } 671 672 /** 673 * @return Returns the messageTableName. 674 */ 675 public String getMessageTableName() { 676 return messageTableName; 677 } 678 679 /** 680 * @param messageTableName The messageTableName to set. 681 */ 682 public void setMessageTableName(String messageTableName) { 683 this.messageTableName = messageTableName; 684 } 685 686 /** 687 * @return Returns the msgIdDataType. 688 */ 689 public String getMsgIdDataType() { 690 return msgIdDataType; 691 } 692 693 /** 694 * @param msgIdDataType The msgIdDataType to set. 695 */ 696 public void setMsgIdDataType(String msgIdDataType) { 697 this.msgIdDataType = msgIdDataType; 698 } 699 700 /** 701 * @return Returns the sequenceDataType. 702 */ 703 public String getSequenceDataType() { 704 return sequenceDataType; 705 } 706 707 /** 708 * @param sequenceDataType The sequenceDataType to set. 709 */ 710 public void setSequenceDataType(String sequenceDataType) { 711 this.sequenceDataType = sequenceDataType; 712 } 713 714 /** 715 * @return Returns the tablePrefix. 716 */ 717 public String getTablePrefix() { 718 return tablePrefix; 719 } 720 721 /** 722 * @param tablePrefix The tablePrefix to set. 723 */ 724 public void setTablePrefix(String tablePrefix) { 725 this.tablePrefix = tablePrefix; 726 } 727 728 /** 729 * @return Returns the durableSubAcksTableName. 730 */ 731 public String getDurableSubAcksTableName() { 732 return durableSubAcksTableName; 733 } 734 735 /** 736 * @param durableSubAcksTableName The durableSubAcksTableName to set. 737 */ 738 public void setDurableSubAcksTableName(String durableSubAcksTableName) { 739 this.durableSubAcksTableName = durableSubAcksTableName; 740 } 741 742 public String getLockTableName() { 743 return lockTableName; 744 } 745 746 public void setLockTableName(String lockTableName) { 747 this.lockTableName = lockTableName; 748 } 749 750 public String getLongDataType() { 751 return longDataType; 752 } 753 754 public void setLongDataType(String longDataType) { 755 this.longDataType = longDataType; 756 } 757 758 public String getStringIdDataType() { 759 return stringIdDataType; 760 } 761 762 public void setStringIdDataType(String stringIdDataType) { 763 this.stringIdDataType = stringIdDataType; 764 } 765 766 public void setUseExternalMessageReferences(boolean useExternalMessageReferences) { 767 this.useExternalMessageReferences = useExternalMessageReferences; 768 } 769 770 public boolean isUseExternalMessageReferences() { 771 return useExternalMessageReferences; 772 } 773 774 public void setAddMessageStatement(String addMessageStatment) { 775 this.addMessageStatement = addMessageStatment; 776 } 777 778 public void setCreateDurableSubStatement(String createDurableSubStatment) { 779 this.createDurableSubStatement = createDurableSubStatment; 780 } 781 782 public void setCreateSchemaStatements(String[] createSchemaStatments) { 783 this.createSchemaStatements = createSchemaStatments; 784 } 785 786 public void setCreateLockSchemaStatements(String[] createLockSchemaStatments) { 787 this.createLockSchemaStatements = createLockSchemaStatments; 788 } 789 790 public void setDeleteOldMessagesStatementWithPriority(String deleteOldMessagesStatementWithPriority) { 791 this.deleteOldMessagesStatementWithPriority = deleteOldMessagesStatementWithPriority; 792 } 793 794 public void setDeleteSubscriptionStatement(String deleteSubscriptionStatment) { 795 this.deleteSubscriptionStatement = deleteSubscriptionStatment; 796 } 797 798 public void setDropSchemaStatements(String[] dropSchemaStatments) { 799 this.dropSchemaStatements = dropSchemaStatments; 800 } 801 802 public void setFindAllDestinationsStatement(String findAllDestinationsStatment) { 803 this.findAllDestinationsStatement = findAllDestinationsStatment; 804 } 805 806 public void setFindAllDurableSubMessagesStatement(String findAllDurableSubMessagesStatment) { 807 this.findAllDurableSubMessagesStatement = findAllDurableSubMessagesStatment; 808 } 809 810 public void setFindAllDurableSubsStatement(String findAllDurableSubsStatment) { 811 this.findAllDurableSubsStatement = findAllDurableSubsStatment; 812 } 813 814 public void setFindAllMessagesStatement(String findAllMessagesStatment) { 815 this.findAllMessagesStatement = findAllMessagesStatment; 816 } 817 818 public void setFindDurableSubStatement(String findDurableSubStatment) { 819 this.findDurableSubStatement = findDurableSubStatment; 820 } 821 822 public void setFindLastSequenceIdInAcksStatement(String findLastSequenceIdInAcks) { 823 this.findLastSequenceIdInAcksStatement = findLastSequenceIdInAcks; 824 } 825 826 public void setFindLastSequenceIdInMsgsStatement(String findLastSequenceIdInMsgs) { 827 this.findLastSequenceIdInMsgsStatement = findLastSequenceIdInMsgs; 828 } 829 830 public void setFindMessageSequenceIdStatement(String findMessageSequenceIdStatment) { 831 this.findMessageSequenceIdStatement = findMessageSequenceIdStatment; 832 } 833 834 public void setFindMessageStatement(String findMessageStatment) { 835 this.findMessageStatement = findMessageStatment; 836 } 837 838 public void setFindMessageByIdStatement(String findMessageByIdStatement) { 839 this.findMessageByIdStatement = findMessageByIdStatement; 840 } 841 842 public void setRemoveAllMessagesStatement(String removeAllMessagesStatment) { 843 this.removeAllMessagesStatement = removeAllMessagesStatment; 844 } 845 846 public void setRemoveAllSubscriptionsStatement(String removeAllSubscriptionsStatment) { 847 this.removeAllSubscriptionsStatement = removeAllSubscriptionsStatment; 848 } 849 850 public void setRemoveMessageStatment(String removeMessageStatement) { 851 this.removeMessageStatement = removeMessageStatement; 852 } 853 854 public void setUpdateLastPriorityAckRowOfDurableSubStatement(String updateLastPriorityAckRowOfDurableSubStatement) { 855 this.updateLastPriorityAckRowOfDurableSubStatement = updateLastPriorityAckRowOfDurableSubStatement; 856 } 857 858 public void setUpdateMessageStatement(String updateMessageStatment) { 859 this.updateMessageStatement = updateMessageStatment; 860 } 861 862 public boolean isUseLockCreateWhereClause() { 863 return useLockCreateWhereClause; 864 } 865 866 public void setUseLockCreateWhereClause(boolean useLockCreateWhereClause) { 867 this.useLockCreateWhereClause = useLockCreateWhereClause; 868 } 869 870 public void setLockCreateStatement(String lockCreateStatement) { 871 this.lockCreateStatement = lockCreateStatement; 872 } 873 874 public void setLockUpdateStatement(String lockUpdateStatement) { 875 this.lockUpdateStatement = lockUpdateStatement; 876 } 877 878 /** 879 * @param findDurableSubMessagesStatement the 880 * findDurableSubMessagesStatement to set 881 */ 882 public void setFindDurableSubMessagesStatement(String findDurableSubMessagesStatement) { 883 this.findDurableSubMessagesStatement = findDurableSubMessagesStatement; 884 } 885 886 /** 887 * @param nextDurableSubscriberMessageStatement the nextDurableSubscriberMessageStatement to set 888 */ 889 public void setNextDurableSubscriberMessageStatement(String nextDurableSubscriberMessageStatement) { 890 this.nextDurableSubscriberMessageStatement = nextDurableSubscriberMessageStatement; 891 } 892 893 /** 894 * @param durableSubscriberMessageCountStatement the durableSubscriberMessageCountStatement to set 895 */ 896 public void setDurableSubscriberMessageCountStatement(String durableSubscriberMessageCountStatement) { 897 this.durableSubscriberMessageCountStatement = durableSubscriberMessageCountStatement; 898 } 899 900 public void setDurableSubscriberMessageCountStatementWithPriority(String durableSubscriberMessageCountStatementWithPriority) { 901 this.durableSubscriberMessageCountStatementWithPriority = durableSubscriberMessageCountStatementWithPriority; 902 } 903 904 /** 905 * @param findNextMessagesStatement the findNextMessagesStatement to set 906 */ 907 public void setFindNextMessagesStatement(String findNextMessagesStatement) { 908 this.findNextMessagesStatement = findNextMessagesStatement; 909 } 910 911 /** 912 * @param destinationMessageCountStatement the destinationMessageCountStatement to set 913 */ 914 public void setDestinationMessageCountStatement(String destinationMessageCountStatement) { 915 this.destinationMessageCountStatement = destinationMessageCountStatement; 916 } 917 918 /** 919 * @param lastAckedDurableSubscriberMessageStatement the lastAckedDurableSubscriberMessageStatement to set 920 */ 921 public void setLastAckedDurableSubscriberMessageStatement( 922 String lastAckedDurableSubscriberMessageStatement) { 923 this.lastAckedDurableSubscriberMessageStatement = lastAckedDurableSubscriberMessageStatement; 924 } 925 926 927 public void setLastProducerSequenceIdStatement(String lastProducerSequenceIdStatement) { 928 this.lastProducerSequenceIdStatement = lastProducerSequenceIdStatement; 929 } 930 931 public void setSelectDurablePriorityAckStatement(String selectDurablePriorityAckStatement) { 932 this.selectDurablePriorityAckStatement = selectDurablePriorityAckStatement; 933 } 934 935 public void setInsertDurablePriorityAckStatement(String insertDurablePriorityAckStatement) { 936 this.insertDurablePriorityAckStatement = insertDurablePriorityAckStatement; 937 } 938 939 public void setUpdateDurableLastAckStatement(String updateDurableLastAckStatement) { 940 this.updateDurableLastAckStatement = updateDurableLastAckStatement; 941 } 942 943 public void setUpdateXidFlagStatement(String updateXidFlagStatement) { 944 this.updateXidFlagStatement = updateXidFlagStatement; 945 } 946 947 public void setFindOpsPendingOutcomeStatement(String findOpsPendingOutcomeStatement) { 948 this.findOpsPendingOutcomeStatement = findOpsPendingOutcomeStatement; 949 } 950 951 public void setClearXidFlagStatement(String clearXidFlagStatement) { 952 this.clearXidFlagStatement = clearXidFlagStatement; 953 } 954 955 public void setUpdateDurableLastAckInTxStatement(String updateDurableLastAckInTxStatement) { 956 this.updateDurableLastAckInTxStatement = updateDurableLastAckInTxStatement; 957 } 958 959 public void setFindAcksPendingOutcomeStatement(String findAcksPendingOutcomeStatement) { 960 this.findAcksPendingOutcomeStatement = findAcksPendingOutcomeStatement; 961 } 962 963 public void setClearDurableLastAckInTxStatement(String clearDurableLastAckInTxStatement) { 964 this.clearDurableLastAckInTxStatement = clearDurableLastAckInTxStatement; 965 } 966 967 public void setUpdateDurableLastAckWithPriorityStatement(String updateDurableLastAckWithPriorityStatement) { 968 this.updateDurableLastAckWithPriorityStatement = updateDurableLastAckWithPriorityStatement; 969 } 970 971 public void setUpdateDurableLastAckWithPriorityInTxStatement(String updateDurableLastAckWithPriorityInTxStatement) { 972 this.updateDurableLastAckWithPriorityInTxStatement = updateDurableLastAckWithPriorityInTxStatement; 973 } 974 975 public void setFindXidByIdStatement(String findXidByIdStatement) { 976 this.findXidByIdStatement = findXidByIdStatement; 977 } 978 979 public void setLeaseObtainStatement(String leaseObtainStatement) { 980 this.leaseObtainStatement = leaseObtainStatement; 981 } 982 983 public void setCurrentDateTimeStatement(String currentDateTimeStatement) { 984 this.currentDateTimeStatement = currentDateTimeStatement; 985 } 986 987 public void setLeaseUpdateStatement(String leaseUpdateStatement) { 988 this.leaseUpdateStatement = leaseUpdateStatement; 989 } 990 991 public void setLeaseOwnerStatement(String leaseOwnerStatement) { 992 this.leaseOwnerStatement = leaseOwnerStatement; 993 } 994}