adapter.doAddMessage(c, sequenceId, messageId, destination, data, message.getExpiration(), this.isPrioritizedMessages() ? message.getPriority() : 0, xaXid); } catch (SQLException e) {
public void addMessageReference(ConnectionContext context, MessageId messageId, long expirationTime, String messageRef) throws IOException { // Get a connection and insert the message into the DB. TransactionContext c = persistenceAdapter.getTransactionContext(context); try { adapter.doAddMessageReference(c, persistenceAdapter.getNextSequenceId(), messageId, destination, expirationTime, messageRef); } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create("Failed to broker message: " + messageId + " in container: " + e, e); } finally { c.close(); } }
@Override public void deleteAllMessages() throws IOException { TransactionContext c = getTransactionContext(); c.getExclusiveConnection(); try { getAdapter().doDropTables(c); getAdapter().setUseExternalMessageReferences(isUseExternalMessageReferences()); getAdapter().doCreateTables(c); LOG.info("Persistence store purged."); } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create(e); } finally { c.close(); } }
@Override public void init() throws Exception { getAdapter().setUseExternalMessageReferences(isUseExternalMessageReferences()); if (isCreateTablesOnStartup()) { TransactionContext transactionContext = getTransactionContext(); transactionContext.getExclusiveConnection(); transactionContext.begin(); try { try { getAdapter().doCreateTables(transactionContext); } catch (SQLException e) { LOG.warn("Cannot create tables due to: " + e); JDBCPersistenceAdapter.log("Failure Details: ", e); } } finally { transactionContext.commit(); } } }
@Override public long getLastMessageBrokerSequenceId() throws IOException { TransactionContext c = getTransactionContext(); try { long seq = getAdapter().doGetLastMessageStoreSequenceId(c); sequenceGenerator.setLastSequenceId(seq); long brokerSeq = 0; if (seq != 0) { byte[] msg = getAdapter().doGetMessageById(c, seq); if (msg != null) { Message last = (Message)wireFormat.unmarshal(new ByteSequence(msg)); brokerSeq = last.getMessageId().getBrokerSequenceId(); } else { LOG.warn("Broker sequence id wasn't recovered properly, possible duplicates!"); } } return brokerSeq; } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create("Failed to get last broker message id: " + e, e); } finally { c.close(); } }
@Override public void deleteSubscription(String clientId, String subscriptionName) throws IOException { TransactionContext c = persistenceAdapter.getTransactionContext(); try { adapter.doDeleteSubscription(c, destination, clientId, subscriptionName); } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create("Failed to remove subscription for: " + clientId + ". Reason: " + e, e); } finally { c.close(); resetBatching(clientId, subscriptionName); } }
@Override public SubscriptionInfo[] getAllSubscriptions() throws IOException { TransactionContext c = persistenceAdapter.getTransactionContext(); try { return adapter.doGetAllSubscriptions(c, destination); } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create("Failed to lookup subscriptions. Reason: " + e, e); } finally { c.close(); } }
@Override public Set<ActiveMQDestination> getDestinations() { TransactionContext c = null; try { c = getTransactionContext(); return getAdapter().doGetDestinations(c); } catch (IOException e) { return emptyDestinationSet(); } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); return emptyDestinationSet(); } finally { if (c != null) { try { c.close(); } catch (Throwable e) { } } } }
@Override public int getMessageCount(String clientId, String subscriberName) throws IOException { //Duration duration = new Duration("getMessageCount"); int result = 0; TransactionContext c = persistenceAdapter.getTransactionContext(); try { result = adapter.doGetDurableSubscriberMessageCount(c, destination, clientId, subscriberName, isPrioritizedMessages()); } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create("Failed to get Message Count: " + clientId + ". Reason: " + e, e); } finally { c.close(); } if (LOG.isTraceEnabled()) { LOG.trace(clientId + ":" + subscriberName + ", messageCount: " + result); } //duration.end(); return result; }
public void cleanup() { TransactionContext c = null; try { LOG.debug("Cleaning up old messages."); c = getTransactionContext(); c.getExclusiveConnection(); getAdapter().doDeleteOldMessages(c); } catch (IOException e) { LOG.warn("Old message cleanup failed due to: " + e, e); } catch (SQLException e) { LOG.warn("Old message cleanup failed due to: " + e); JDBCPersistenceAdapter.log("Failure Details: ", e); } finally { if (c != null) { try { c.close(); } catch (Throwable e) { } } LOG.debug("Cleanup done."); } }
@Override public void init() throws Exception { getAdapter().setUseExternalMessageReferences(isUseExternalMessageReferences()); if (isCreateTablesOnStartup()) { TransactionContext transactionContext = getTransactionContext(); transactionContext.getExclusiveConnection(); transactionContext.begin(); try { try { getAdapter().doCreateTables(transactionContext); } catch (SQLException e) { LOG.warn("Cannot create tables due to: " + e); JDBCPersistenceAdapter.log("Failure Details: ", e); } } finally { transactionContext.commit(); } } }
public long getLastMessageBrokerSequenceId() throws IOException { TransactionContext c = getTransactionContext(); try { long seq = getAdapter().doGetLastMessageStoreSequenceId(c); sequenceGenerator.setLastSequenceId(seq); long brokerSeq = 0; if (seq != 0) { byte[] msg = getAdapter().doGetMessageById(c, seq); if (msg != null) { Message last = (Message)wireFormat.unmarshal(new ByteSequence(msg)); brokerSeq = last.getMessageId().getBrokerSequenceId(); } else { LOG.warn("Broker sequence id wasn't recovered properly, possible duplicates!"); } } return brokerSeq; } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create("Failed to get last broker message id: " + e, e); } finally { c.close(); } }
private void removeConsumerDestination(ActiveMQQueue destination) throws IOException { TransactionContext c = getTransactionContext(); try { String id = destination.getQualifiedName(); getAdapter().doDeleteSubscription(c, destination, id, id); } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create("Failed to remove consumer destination: " + destination, e); } finally { c.close(); } }
@Override public SubscriptionInfo[] getAllSubscriptions() throws IOException { TransactionContext c = persistenceAdapter.getTransactionContext(); try { return adapter.doGetAllSubscriptions(c, destination); } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create("Failed to lookup subscriptions. Reason: " + e, e); } finally { c.close(); } }
@Override public Set<ActiveMQDestination> getDestinations() { TransactionContext c = null; try { c = getTransactionContext(); return getAdapter().doGetDestinations(c); } catch (IOException e) { return emptyDestinationSet(); } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); return emptyDestinationSet(); } finally { if (c != null) { try { c.close(); } catch (Throwable e) { } } } }
@Override public int getMessageCount(String clientId, String subscriberName) throws IOException { //Duration duration = new Duration("getMessageCount"); int result = 0; TransactionContext c = persistenceAdapter.getTransactionContext(); try { result = adapter.doGetDurableSubscriberMessageCount(c, destination, clientId, subscriberName, isPrioritizedMessages()); } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create("Failed to get Message Count: " + clientId + ". Reason: " + e, e); } finally { c.close(); } if (LOG.isTraceEnabled()) { LOG.trace(clientId + ":" + subscriberName + ", messageCount: " + result); } //duration.end(); return result; }
public void cleanup() { TransactionContext c = null; try { LOG.debug("Cleaning up old messages."); c = getTransactionContext(); getAdapter().doDeleteOldMessages(c, false); getAdapter().doDeleteOldMessages(c, true); } catch (IOException e) { LOG.warn("Old message cleanup failed due to: " + e, e); } catch (SQLException e) { LOG.warn("Old message cleanup failed due to: " + e); JDBCPersistenceAdapter.log("Failure Details: ", e); } finally { if (c != null) { try { c.close(); } catch (Throwable e) { } } LOG.debug("Cleanup done."); } }
public void deleteAllMessages() throws IOException { TransactionContext c = getTransactionContext(); try { getAdapter().doDropTables(c); getAdapter().setUseExternalMessageReferences(isUseExternalMessageReferences()); getAdapter().doCreateTables(c); LOG.info("Persistence store purged."); } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create(e); } finally { c.close(); } }
@Override public void init() throws Exception { getAdapter().setUseExternalMessageReferences(isUseExternalMessageReferences()); if (isCreateTablesOnStartup()) { TransactionContext transactionContext = getTransactionContext(); transactionContext.getExclusiveConnection(); transactionContext.begin(); try { try { getAdapter().doCreateTables(transactionContext); } catch (SQLException e) { LOG.warn("Cannot create tables due to: " + e); JDBCPersistenceAdapter.log("Failure Details: ", e); } } finally { transactionContext.commit(); } } }
@Override public long getLastMessageBrokerSequenceId() throws IOException { TransactionContext c = getTransactionContext(); try { long seq = getAdapter().doGetLastMessageStoreSequenceId(c); sequenceGenerator.setLastSequenceId(seq); long brokerSeq = 0; if (seq != 0) { byte[] msg = getAdapter().doGetMessageById(c, seq); if (msg != null) { Message last = (Message)wireFormat.unmarshal(new ByteSequence(msg)); brokerSeq = last.getMessageId().getBrokerSequenceId(); } else { LOG.warn("Broker sequence id wasn't recovered properly, possible duplicates!"); } } return brokerSeq; } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create("Failed to get last broker message id: " + e, e); } finally { c.close(); } }