Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Support Nack functionality for AMQP implementation - avoid consumers … #199

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,43 @@ public void ackMsg(Message message) throws Exception {
}
}

@Override
public void nack(List<Message> messages) {
for (final Message message : messages) {
int retryIndex = 1;
while (true) {
try {
LOGGER.info("NACK message with delivery tag {}", message.getReceipt());
Channel chn =
amqpConnection.getOrCreateChannel(
ConnectionType.SUBSCRIBER,
getSettings().getQueueOrExchangeName());
chn.basicNack(Long.parseLong(message.getReceipt()), false, false);
LOGGER.info("Nack'ed the message with delivery tag {}", message.getReceipt());
break;
} catch (final Exception e) {
AMQPRetryPattern retry = retrySettings;
if (retry == null) {
LOGGER.error(
"Cannot NACK message with delivery tag {}",
message.getReceipt(),
e);
}
try {
retry.continueOrPropogate(e, retryIndex);
} catch (Exception ex) {
LOGGER.error(
"Retries completed. Cannot NACK message with delivery tag {}",
message.getReceipt(),
e);
break;
}
retryIndex++;
}
}
}
}

private static AMQP.BasicProperties buildBasicProperties(
final Message message, final AMQPSettings settings) {
return new AMQP.BasicProperties.Builder()
Expand Down