/** * Cleanup method to remove any state associated with the given destination * @param destination Destination to forget */ @Override public void removeQueueMessageStore(ActiveMQQueue destination) { if (destination.isQueue() && getBrokerService().shouldRecordVirtualDestination(destination)) { try { removeConsumerDestination(destination); } catch (IOException ioe) { LOG.error("Failed to remove consumer destination: " + destination, ioe); } } storeCache.remove(destination); }
if (persistenceAdapter.getBrokerService() != null) { persistenceAdapter.getBrokerService().handleIOException(ioe);
public void close() throws IOException { if (!inTx) { try { // can be null for topic ops that bypass the store via existing cursor state if (connection != null) { final boolean needsCommit = !connection.getAutoCommit(); executeBatch(); if (needsCommit) { connection.commit(); } } } catch (SQLException e) { JDBCPersistenceAdapter.log("Error while closing connection: ", e); IOException ioe = IOExceptionSupport.create(e); persistenceAdapter.getBrokerService().handleIOException(ioe); throw ioe; } finally { silentClose(); for (Runnable completion: completions) { completion.run(); } completions.clear(); } } }
public JDBCMessageStore(JDBCPersistenceAdapter persistenceAdapter, JDBCAdapter adapter, WireFormat wireFormat, ActiveMQDestination destination, ActiveMQMessageAudit audit) throws IOException { super(destination); this.persistenceAdapter = persistenceAdapter; this.adapter = adapter; this.wireFormat = wireFormat; this.audit = audit; if (destination.isQueue() && persistenceAdapter.getBrokerService().shouldRecordVirtualDestination(destination)) { recordDestinationCreation(destination); } resetBatching(); }
public void commit() throws IOException { if (!inTx) { throw new IOException("Not started."); } try { final boolean needsCommit = !connection.getAutoCommit(); executeBatch(); if (needsCommit) { connection.commit(); } } catch (SQLException e) { JDBCPersistenceAdapter.log("Commit failed: ", e); try { doRollback(); } catch (Exception ignored) {} IOException ioe = IOExceptionSupport.create(e); persistenceAdapter.getBrokerService().handleIOException(ioe); throw ioe; } finally { inTx = false; close(); } }
public Connection getConnection() throws IOException { if (connection == null) { try { connection = dataSource.getConnection(); boolean autoCommit = !inTx; if (connection.getAutoCommit() != autoCommit) { connection.setAutoCommit(autoCommit); } } catch (SQLException e) { JDBCPersistenceAdapter.log("Could not get JDBC connection: ", e); IOException ioe = IOExceptionSupport.create(e); persistenceAdapter.getBrokerService().handleIOException(ioe); throw ioe; } try { connection.setTransactionIsolation(transactionIsolation); } catch (Throwable e) { } } return connection; }
/** * Cleanup method to remove any state associated with the given destination * @param destination Destination to forget */ @Override public void removeQueueMessageStore(ActiveMQQueue destination) { if (destination.isQueue() && getBrokerService().shouldRecordVirtualDestination(destination)) { try { removeConsumerDestination(destination); } catch (IOException ioe) { LOG.error("Failed to remove consumer destination: " + destination, ioe); } } }
/** * Cleanup method to remove any state associated with the given destination * @param destination Destination to forget */ @Override public void removeQueueMessageStore(ActiveMQQueue destination) { if (destination.isQueue() && getBrokerService().shouldRecordVirtualDestination(destination)) { try { removeConsumerDestination(destination); } catch (IOException ioe) { LOG.error("Failed to remove consumer destination: " + destination, ioe); } } }
/** * Cleanup method to remove any state associated with the given destination * @param destination Destination to forget */ @Override public void removeQueueMessageStore(ActiveMQQueue destination) { if (destination.isQueue() && getBrokerService().shouldRecordVirtualDestination(destination)) { try { removeConsumerDestination(destination); } catch (IOException ioe) { LOG.error("Failed to remove consumer destination: " + destination, ioe); } } }
if (persistenceAdapter.getBrokerService() != null) { persistenceAdapter.getBrokerService().handleIOException(ioe);
if (persistenceAdapter.getBrokerService() != null) { persistenceAdapter.getBrokerService().handleIOException(ioe);
public JDBCMessageStore(JDBCPersistenceAdapter persistenceAdapter, JDBCAdapter adapter, WireFormat wireFormat, ActiveMQDestination destination, ActiveMQMessageAudit audit) throws IOException { super(destination); this.persistenceAdapter = persistenceAdapter; this.adapter = adapter; this.wireFormat = wireFormat; this.audit = audit; if (destination.isQueue() && persistenceAdapter.getBrokerService().shouldRecordVirtualDestination(destination)) { recordDestinationCreation(destination); } resetBatching(); }
public void commit() throws IOException { if (!inTx) { throw new IOException("Not started."); } try { executeBatch(); if (!connection.getAutoCommit()) { connection.commit(); } } catch (SQLException e) { JDBCPersistenceAdapter.log("Commit failed: ", e); try { doRollback(); } catch (Exception ignored) {} IOException ioe = IOExceptionSupport.create(e); persistenceAdapter.getBrokerService().handleIOException(ioe); throw ioe; } finally { inTx = false; close(); } }
public JDBCMessageStore(JDBCPersistenceAdapter persistenceAdapter, JDBCAdapter adapter, WireFormat wireFormat, ActiveMQDestination destination, ActiveMQMessageAudit audit) throws IOException { super(destination); this.persistenceAdapter = persistenceAdapter; this.adapter = adapter; this.wireFormat = wireFormat; this.audit = audit; if (destination.isQueue() && persistenceAdapter.getBrokerService().shouldRecordVirtualDestination(destination)) { recordDestinationCreation(destination); } resetBatching(); }
public void commit() throws IOException { if (!inTx) { throw new IOException("Not started."); } try { executeBatch(); if (!connection.getAutoCommit()) { connection.commit(); } } catch (SQLException e) { JDBCPersistenceAdapter.log("Commit failed: ", e); try { doRollback(); } catch (Exception ignored) {} IOException ioe = IOExceptionSupport.create(e); persistenceAdapter.getBrokerService().handleIOException(ioe); throw ioe; } finally { inTx = false; close(); } }
public JDBCMessageStore(JDBCPersistenceAdapter persistenceAdapter, JDBCAdapter adapter, WireFormat wireFormat, ActiveMQDestination destination, ActiveMQMessageAudit audit) throws IOException { super(destination); this.persistenceAdapter = persistenceAdapter; this.adapter = adapter; this.wireFormat = wireFormat; this.audit = audit; if (destination.isQueue() && persistenceAdapter.getBrokerService().shouldRecordVirtualDestination(destination)) { recordDestinationCreation(destination); } resetBatching(); }
public void commit() throws IOException { if (!inTx) { throw new IOException("Not started."); } try { executeBatch(); if (!connection.getAutoCommit()) { connection.commit(); } } catch (SQLException e) { JDBCPersistenceAdapter.log("Commit failed: ", e); try { doRollback(); } catch (Exception ignored) {} IOException ioe = IOExceptionSupport.create(e); persistenceAdapter.getBrokerService().handleIOException(ioe); throw ioe; } finally { inTx = false; close(); } }
@Override protected void onRecovered(Tx tx) { for (RemoveMessageCommand removeMessageCommand: tx.acks) { if (removeMessageCommand instanceof LastAckCommand) { LastAckCommand lastAckCommand = (LastAckCommand) removeMessageCommand; JDBCTopicMessageStore jdbcTopicMessageStore = (JDBCTopicMessageStore) topicStores.get(lastAckCommand.getMessageAck().getDestination()); jdbcTopicMessageStore.pendingCompletion(lastAckCommand.getClientId(), lastAckCommand.getSubName(), lastAckCommand.getSequence(), lastAckCommand.getPriority()); lastAckCommand.setMessageStore(jdbcTopicMessageStore); } else { // when reading the store we ignore messages with non null XIDs but should include those with XIDS starting in - (pending acks in an xa transaction), // but the sql is non portable to match BLOB with LIKE etc // so we make up for it when we recover the ack ((JDBCPersistenceAdapter)persistenceAdapter).getBrokerService().getRegionBroker().getDestinationMap().get(removeMessageCommand.getMessageAck().getDestination()).getDestinationStatistics().getMessages().increment(); } } for (AddMessageCommand addMessageCommand : tx.messages) { ActiveMQDestination destination = addMessageCommand.getMessage().getDestination(); addMessageCommand.setMessageStore(destination.isQueue() ? queueStores.get(destination) : topicStores.get(destination)); } }
@Override protected void onRecovered(Tx tx) { for (RemoveMessageCommand removeMessageCommand: tx.acks) { if (removeMessageCommand instanceof LastAckCommand) { LastAckCommand lastAckCommand = (LastAckCommand) removeMessageCommand; JDBCTopicMessageStore jdbcTopicMessageStore = (JDBCTopicMessageStore) topicStores.get(lastAckCommand.getMessageAck().getDestination()); jdbcTopicMessageStore.pendingCompletion(lastAckCommand.getClientId(), lastAckCommand.getSubName(), lastAckCommand.getSequence(), lastAckCommand.getPriority()); lastAckCommand.setMessageStore(jdbcTopicMessageStore); } else { // when reading the store we ignore messages with non null XIDs but should include those with XIDS starting in - (pending acks in an xa transaction), // but the sql is non portable to match BLOB with LIKE etc // so we make up for it when we recover the ack ((JDBCPersistenceAdapter)persistenceAdapter).getBrokerService().getRegionBroker().getDestinationMap().get(removeMessageCommand.getMessageAck().getDestination()).getDestinationStatistics().getMessages().increment(); } } for (AddMessageCommand addMessageCommand : tx.messages) { ActiveMQDestination destination = addMessageCommand.getMessage().getDestination(); addMessageCommand.setMessageStore(destination.isQueue() ? queueStores.get(destination) : topicStores.get(destination)); } }
@Override protected void onRecovered(Tx tx) { for (RemoveMessageCommand removeMessageCommand: tx.acks) { if (removeMessageCommand instanceof LastAckCommand) { LastAckCommand lastAckCommand = (LastAckCommand) removeMessageCommand; JDBCTopicMessageStore jdbcTopicMessageStore = (JDBCTopicMessageStore) topicStores.get(lastAckCommand.getMessageAck().getDestination()); jdbcTopicMessageStore.pendingCompletion(lastAckCommand.getClientId(), lastAckCommand.getSubName(), lastAckCommand.getSequence(), lastAckCommand.getPriority()); lastAckCommand.setMessageStore(jdbcTopicMessageStore); } else { // when reading the store we ignore messages with non null XIDs but should include those with XIDS starting in - (pending acks in an xa transaction), // but the sql is non portable to match BLOB with LIKE etc // so we make up for it when we recover the ack ((JDBCPersistenceAdapter)persistenceAdapter).getBrokerService().getRegionBroker().getDestinationMap().get(removeMessageCommand.getMessageAck().getDestination()).getDestinationStatistics().getMessages().increment(); } } for (AddMessageCommand addMessageCommand : tx.messages) { ActiveMQDestination destination = addMessageCommand.getMessage().getDestination(); addMessageCommand.setMessageStore(destination.isQueue() ? queueStores.get(destination) : topicStores.get(destination)); } }