@Override public void commitTransaction(ConnectionContext context) throws IOException { TransactionContext transactionContext = getTransactionContext(context); transactionContext.commit(); }
@Override public void run(ConnectionContext context) throws IOException { ((JDBCPersistenceAdapter)persistenceAdapter).commitLastAck(context, lastAck, priority, destination, subName, clientId); jdbcTopicMessageStore.complete(clientId, subName); }
@Override public void rollback(ConnectionContext context) throws IOException { JDBCTopicMessageStore jdbcTopicMessageStore = (JDBCTopicMessageStore)topicMessageStore; ((JDBCPersistenceAdapter)persistenceAdapter).rollbackLastAck(context, jdbcTopicMessageStore, ack, subscriptionName, clientId); jdbcTopicMessageStore.complete(clientId, subscriptionName); }
public void rollbackLastAck(ConnectionContext context, JDBCTopicMessageStore store, MessageAck ack, String subName, String clientId) throws IOException { TransactionContext c = getTransactionContext(context); try { byte priority = (byte) store.getCachedStoreSequenceId(c, store.getDestination(), ack.getLastMessageId())[1]; getAdapter().doClearLastAck(c, store.getDestination(), priority, clientId, subName); } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create("Failed to rollback last ack: " + ack + " on " + store.getDestination() + " for " + subName + ":" + clientId + ". Reason: " + e,e); } finally { c.close(); } }
@Override public long getLastProducerSequenceId(ProducerId id) throws IOException { TransactionContext c = getTransactionContext(); try { return getAdapter().doGetLastProducerSequenceId(c, id); } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create("Failed to get last broker message id: " + e, e); } finally { c.close(); } }
public void commitLastAck(ConnectionContext context, long xidLastAck, long priority, ActiveMQDestination destination, String subName, String clientId) throws IOException { TransactionContext c = getTransactionContext(context); try { getAdapter().doSetLastAck(c, destination, null, clientId, subName, xidLastAck, priority); } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create("Failed to commit last ack with priority: " + priority + " on " + destination + " for " + subName + ":" + clientId + ". Reason: " + e,e); } finally { c.close(); } }
public void recover(JdbcMemoryTransactionStore jdbcMemoryTransactionStore) throws IOException { TransactionContext c = getTransactionContext(); try { getAdapter().doRecoverPreparedOps(c, jdbcMemoryTransactionStore); } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create("Failed to recover from: " + jdbcMemoryTransactionStore + ". Reason: " + e,e); } finally { c.close(); } }
public void commitAdd(ConnectionContext context, final MessageId messageId, final long preparedSequenceId, final long newSequence) throws IOException { TransactionContext c = getTransactionContext(context); try { getAdapter().doCommitAddOp(c, preparedSequenceId, newSequence); } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create("Failed to commit add: " + messageId + ". Reason: " + e, e); } finally { c.close(); } }
public void setAdapter(JDBCAdapter adapter) { this.adapter = adapter; this.adapter.setStatements(getStatements()); this.adapter.setMaxRows(getMaxRows()); }
@Override public void rollback(ConnectionContext context) throws IOException { ((JDBCPersistenceAdapter)persistenceAdapter).rollbackLastAck(context, priority, jdbcTopicMessageStore.getDestination(), subName, clientId); jdbcTopicMessageStore.complete(clientId, subName); }
@Override public TopicMessageStore createTopicMessageStore(ActiveMQTopic destination) throws IOException { TopicMessageStore rc = (TopicMessageStore) storeCache.get(destination); if (rc == null) { TopicMessageStore store = transactionStore.proxy(new JDBCTopicMessageStore(this, getAdapter(), wireFormat, destination, audit)); rc = (TopicMessageStore) storeCache.putIfAbsent(destination, store); if (rc == null) { rc = store; } } return rc; }
@Override public MessageStore createQueueMessageStore(ActiveMQQueue destination) throws IOException { MessageStore rc = storeCache.get(destination); if (rc == null) { MessageStore store = transactionStore.proxy(new JDBCMessageStore(this, getAdapter(), wireFormat, destination, audit)); rc = storeCache.putIfAbsent(destination, store); if (rc == null) { rc = store; } } return rc; }
@Override public void rollbackTransaction(ConnectionContext context) throws IOException { TransactionContext transactionContext = getTransactionContext(context); transactionContext.rollback(); }
@Override public void beginTransaction(ConnectionContext context) throws IOException { TransactionContext transactionContext = getTransactionContext(context); transactionContext.begin(); }
public void setStatements(Statements statements) { this.statements = statements; if (adapter != null) { this.adapter.setStatements(getStatements()); } }
LastRecovered() { for (int i=0; i<perPriority.length; i++) { perPriority[i] = new LastRecoveredEntry(i); } }
@Override public void run() { cleanup(); } }, 0, cleanupPeriod, TimeUnit.MILLISECONDS);
public String getFindLastSequenceIdInAcksStatement() { if (findLastSequenceIdInAcksStatement == null) { findLastSequenceIdInAcksStatement = "SELECT MAX(LAST_ACKED_ID) FROM " + getFullAckTableName(); } return findLastSequenceIdInAcksStatement; }
public void configure(PersistenceAdapter adapter) throws IOException { if (adapter instanceof JDBCPersistenceAdapter) { this.jdbcAdapter = (JDBCPersistenceAdapter) adapter; this.dataSource = ((JDBCPersistenceAdapter) adapter).getLockDataSource(); // we cannot get the statements (yet) as they may be configured later } }
protected long initTimeDiff(Connection connection) throws SQLException { if (Long.MAX_VALUE == diffFromCurrentTime) { if (maxAllowableDiffFromDBTime > 0) { diffFromCurrentTime = determineTimeDifference(connection); } else { diffFromCurrentTime = 0l; } } return diffFromCurrentTime; }