@Override public synchronized List<MessageReference> getListOnConsumer(long consumerID) { List<MessageReference> list = new LinkedList<>(); for (MessageReference ref : refsToAck) { if (ref.hasConsumerId() && ref.getConsumerId() == consumerID) { list.add(ref); } } return list; }
/** * Openwire will redeliver rolled back references. * We need to return those here. */ private void returnReferences(Transaction tx, AMQSession session) throws Exception { if (session == null || session.isClosed()) { return; } RefsOperation oper = (RefsOperation) tx.getProperty(TransactionPropertyIndexes.REFS_OPERATION); if (oper != null) { List<MessageReference> ackRefs = oper.getReferencesToAcknowledge(); for (ListIterator<MessageReference> referenceIterator = ackRefs.listIterator(ackRefs.size()); referenceIterator.hasPrevious(); ) { MessageReference ref = referenceIterator.previous(); ServerConsumer consumer = null; if (ref.hasConsumerId()) { consumer = session.getCoreSession().locateConsumer(ref.getConsumerId()); } if (consumer != null) { referenceIterator.remove(); ref.incrementDeliveryCount(); consumer.backToDelivering(ref); final AMQConsumer amqConsumer = (AMQConsumer) consumer.getProtocolData(); amqConsumer.addRolledback(ref); } } } }
@Override public void messageExpired(MessageReference message, SimpleString messageExpiryAddress, ServerConsumer consumer) { final ManagementService managementService = getManagementService(); if (managementService != null && sendExpiredNotifications) { try { if (!message.getQueue().getAddress().equals(managementService.getManagementNotificationAddress())) { final TypedProperties props = new TypedProperties(); props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, message.getQueue().getAddress()); props.putByteProperty(ManagementHelper.HDR_ROUTING_TYPE, message.getQueue().getRoutingType().getType()); props.putSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME, message.getQueue().getName()); props.putLongProperty(ManagementHelper.HDR_MESSAGE_ID, message.getMessageID()); if (message.hasConsumerId()) { props.putLongProperty(ManagementHelper.HDR_CONSUMER_NAME, message.getConsumerId()); } managementService.sendNotification(new Notification(null, CoreNotificationType.MESSAGE_EXPIRED, props)); } } catch (Exception e) { logger.warn("Error sending notification: " + CoreNotificationType.MESSAGE_EXPIRED, e.getMessage(), e); } } }