@Override public String toString() { return getQualifiedName(); }
protected static void appendToString(StringBuffer buffer, Object key, Object value) { if (value instanceof ActiveMQDestination) { ActiveMQDestination destination = (ActiveMQDestination)value; buffer.append(destination.getQualifiedName()); } else if (key.toString().toLowerCase(Locale.ENGLISH).contains("password")){ buffer.append("*****"); } else { buffer.append(value); } }
public static String nameFromDestinationFilter(ActiveMQDestination destination) { if (destination.getQualifiedName().length() > IOHelper.getMaxFileNameLength()) { LOG.warn("Destination name is longer than 'MaximumFileNameLength' system property, " + "potential problem with recovery can result from name truncation."); } return IOHelper.toFileSystemSafeName(destination.getQualifiedName()); }
@Override public void doRecordDestination(TransactionContext c, ActiveMQDestination destination) throws SQLException, IOException { PreparedStatement s = null; try { s = c.getConnection().prepareStatement(this.statements.getCreateDurableSubStatement()); s.setString(1, destination.getQualifiedName()); s.setString(2, destination.getQualifiedName()); s.setString(3, destination.getQualifiedName()); s.setString(4, null); s.setLong(5, 0); s.setString(6, destination.getQualifiedName()); s.setLong(7, 11); // entry out of priority range if (s.executeUpdate() != 1) { throw new IOException("Could not create ack record for destination: " + destination); } } finally { close(s); } }
@Override public void doDeleteSubscription(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName) throws SQLException, IOException { PreparedStatement s = null; try { s = c.getConnection().prepareStatement(this.statements.getDeleteSubscriptionStatement()); s.setString(1, destination.getQualifiedName()); s.setString(2, clientId); s.setString(3, subscriptionName); s.executeUpdate(); } finally { close(s); } }
@Override public void doClearLastAck(TransactionContext c, ActiveMQDestination destination, byte priority, String clientId, String subName) throws SQLException, IOException { PreparedStatement s = null; try { s = c.getConnection().prepareStatement(this.statements.getClearDurableLastAckInTxStatement()); s.setString(1, destination.getQualifiedName()); s.setString(2, clientId); s.setString(3, subName); s.setLong(4, priority); if (s.executeUpdate() != 1) { throw new IOException("Could not remove prepared transaction state from message ack for: " + clientId + ":" + subName); } } finally { close(s); } }
@Override public void doRemoveAllMessages(TransactionContext c, ActiveMQDestination destinationName) throws SQLException, IOException { PreparedStatement s = null; try { s = c.getConnection().prepareStatement(this.statements.getRemoveAllMessagesStatement()); s.setString(1, destinationName.getQualifiedName()); s.executeUpdate(); s.close(); s = c.getConnection().prepareStatement(this.statements.getRemoveAllSubscriptionsStatement()); s.setString(1, destinationName.getQualifiedName()); s.executeUpdate(); } finally { close(s); } }
@Override public String toString() { return destination.getQualifiedName() + ", subscriptions=" + consumers.size() + ", memory=" + memoryUsage.getPercentUsage() + "%, size=" + destinationStatistics.getMessages().getCount() + ", pending=" + indexOrderedCursorUpdates.size(); }
public void setCompositeDestinations(ActiveMQDestination[] destinations) { this.compositeDestinations = destinations; this.destinationPaths = null; this.hashValue = 0; this.isPattern = false; StringBuffer sb = new StringBuffer(); for (int i = 0; i < destinations.length; i++) { if (i != 0) { sb.append(COMPOSITE_SEPERATOR); } if (getDestinationType() == destinations[i].getDestinationType()) { sb.append(destinations[i].getPhysicalName()); } else { sb.append(destinations[i].getQualifiedName()); } } physicalName = sb.toString(); }
private void expireMessages() { LOG.debug("{} expiring messages ..", getActiveMQDestination().getQualifiedName()); // just track the insertion count List<Message> browsedMessages = new InsertionCountList<Message>(); doBrowse(browsedMessages, this.getMaxExpirePageSize()); asyncWakeup(); LOG.debug("{} expiring messages done.", getActiveMQDestination().getQualifiedName()); }
@Override public int doGetMessageCount(TransactionContext c, ActiveMQDestination destination) throws SQLException, IOException { PreparedStatement s = null; ResultSet rs = null; int result = 0; try { s = c.getConnection().prepareStatement(this.statements.getDestinationMessageCountStatement()); s.setString(1, destination.getQualifiedName()); rs = s.executeQuery(); if (rs.next()) { result = rs.getInt(1); } } finally { close(rs); close(s); } return result; }
@Override public long[] getStoreSequenceId(TransactionContext c, ActiveMQDestination destination, MessageId messageID) throws SQLException, IOException { PreparedStatement s = null; ResultSet rs = null; try { s = c.getConnection().prepareStatement(this.statements.getFindMessageSequenceIdStatement()); s.setString(1, messageID.getProducerId().toString()); s.setLong(2, messageID.getProducerSequenceId()); s.setString(3, destination.getQualifiedName()); rs = s.executeQuery(); if (!rs.next()) { return new long[]{0,0}; } return new long[]{rs.getLong(1), rs.getLong(2)}; } finally { close(rs); close(s); } }
private PersistenceAdapter getMatchingPersistenceAdapter(ActiveMQDestination destination) throws IOException { Object result = destinationMap.chooseValue(destination); if (result == null) { throw new RuntimeException("No matching persistence adapter configured for destination: " + destination + ", options:" + adapters); } FilteredKahaDBPersistenceAdapter filteredAdapter = (FilteredKahaDBPersistenceAdapter) result; if (filteredAdapter.getDestination() == matchAll && filteredAdapter.isPerDestination()) { filteredAdapter = addAdapter(filteredAdapter, destination); if (LOG.isTraceEnabled()) { LOG.info("created per destination adapter for: " + destination + ", " + result); } } startAdapter(filteredAdapter.getPersistenceAdapter(), destination.getQualifiedName()); LOG.debug("destination {} matched persistence adapter {}", new Object[]{destination.getQualifiedName(), filteredAdapter.getPersistenceAdapter()}); return filteredAdapter.getPersistenceAdapter(); }
@Override public void doUpdateMessage(TransactionContext c, ActiveMQDestination destination, MessageId id, byte[] data) throws SQLException, IOException { PreparedStatement s = null; try { s = c.getConnection().prepareStatement(this.statements.getUpdateMessageStatement()); setBinaryData(s, 1, data); s.setString(2, id.getProducerId().toString()); s.setLong(3, id.getProducerSequenceId()); s.setString(4, destination.getQualifiedName()); if (s.executeUpdate() != 1) { throw new IOException("Could not update message: " + id + " in " + destination); } } finally { close(s); } }
private void recordDestinationCreation(ActiveMQDestination destination) throws IOException { TransactionContext c = persistenceAdapter.getTransactionContext(); try { if (adapter.doGetLastAckedDurableSubscriberMessageId(c, destination, destination.getQualifiedName(), destination.getQualifiedName()) < 0) { adapter.doRecordDestination(c, destination); } } catch (SQLException e) { JDBCPersistenceAdapter.log("JDBC Failure: ", e); throw IOExceptionSupport.create("Failed to record destination: " + destination + ". Reason: " + e, e); } finally { c.close(); } }
@Override public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { if (!AdvisorySupport.isAdvisoryTopic(info.getDestination()) && !info.getDestination().isTemporary()) { if (singleSelectorPerDestination) { String destinationName = info.getDestination().getQualifiedName(); Set<String> selectors = subSelectorCache.get(destinationName); if (info.getSelector() == null && selectors.size() > 1) { boolean removed = selectors.remove(MATCH_EVERYTHING); LOG.debug("A non-selector consumer has dropped. Removing the catchall matching pattern 'TRUE'. Successful? " + removed); } } } super.removeConsumer(context, info); }
public synchronized void purge() throws Exception { final long originalMessageCount = destination.getDestinationStatistics().getMessages().getCount(); ((Queue)destination).purge(); LOG.info("{} purge of {} messages", destination.getActiveMQDestination().getQualifiedName(), originalMessageCount); }
@Override public void dispose(ConnectionContext context) throws IOException { if (this.destinationStatistics.getMessages().getCount() > 0) { LOG.info("{} on dispose, purge of {} pending messages: {}", new Object[]{ getActiveMQDestination().getQualifiedName(), this.destinationStatistics.getMessages().getCount(), messages }); // we may want to capture these message ids in an advisory } try { purge(); } catch (Exception e) { LOG.warn("Caught an exception purging Queue: {}", destination, e); } super.dispose(context); } }
private void checkUsage(ConnectionContext context,ProducerBrokerExchange producerBrokerExchange, Message message) throws ResourceAllocationException, IOException, InterruptedException { if (message.isPersistent()) { if (store != null && systemUsage.getStoreUsage().isFull(getStoreUsageHighWaterMark())) { final String logMessage = "Persistent store is Full, " + getStoreUsageHighWaterMark() + "% of " + systemUsage.getStoreUsage().getLimit() + ". Stopping producer (" + message.getProducerId() + ") to prevent flooding " + getActiveMQDestination().getQualifiedName() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info"; waitForSpace(context, producerBrokerExchange, systemUsage.getStoreUsage(), getStoreUsageHighWaterMark(), logMessage); } } else if (messages.getSystemUsage() != null && systemUsage.getTempUsage().isFull()) { final String logMessage = "Temp Store is Full (" + systemUsage.getTempUsage().getPercentUsage() + "% of " + systemUsage.getTempUsage().getLimit() +"). Stopping producer (" + message.getProducerId() + ") to prevent flooding " + getActiveMQDestination().getQualifiedName() + "." + " See http://activemq.apache.org/producer-flow-control.html for more info"; waitForSpace(context, producerBrokerExchange, messages.getSystemUsage().getTempUsage(), logMessage); } }
@Override public void messageConsumed(ConnectionContext context, MessageReference messageReference) { super.messageConsumed(context, messageReference); try { if (!messageReference.isAdvisory()) { BaseDestination baseDestination = (BaseDestination) messageReference.getMessage().getRegionDestination(); ActiveMQTopic topic = AdvisorySupport.getMessageConsumedAdvisoryTopic(baseDestination.getActiveMQDestination()); Message payload = messageReference.getMessage().copy(); if (!baseDestination.isIncludeBodyForAdvisory()) { payload.clearBody(); } ActiveMQMessage advisoryMessage = new ActiveMQMessage(); advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString()); advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_DESTINATION, baseDestination.getActiveMQDestination().getQualifiedName()); fireAdvisory(context, topic, payload, null, advisoryMessage); } } catch (Exception e) { handleFireFailure("consumed", e); } }