Skip to content
Open
Show file tree
Hide file tree
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 @@ -103,18 +103,30 @@ public GetResponse consume() {
return responseQueue.poll();
}

public void acknowledge(final GetResponse response) {
public void acknowledge(final long deliveryTag, final boolean multiple) {
if (autoAcknowledge) {
return;
}

try {
getChannel().basicAck(response.getEnvelope().getDeliveryTag(), true);
getChannel().basicAck(deliveryTag, multiple);
} catch (Exception e) {
throw new AMQPException("Failed to acknowledge message", e);
}
}

public void negativeAcknowledge(final long deliveryTag, final boolean multiple, final boolean requeue) {
if (autoAcknowledge) {
return;
}

try {
getChannel().basicNack(deliveryTag, multiple, requeue);
} catch (Exception e) {
throw new AMQPException("Failed to negatively acknowledge message", e);
}
}

@Override
public void close() throws TimeoutException, IOException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,19 @@ protected void processResource(final Connection connection, final AMQPConsumer c
}

if (lastReceived != null) {
final GetResponse finalGetResponse = lastReceived;
session.commitAsync(() -> consumer.acknowledge(finalGetResponse), null);
final long lastDeliveryTag = lastReceived.getEnvelope().getDeliveryTag();

session.commitAsync(
() -> consumer.acknowledge(lastDeliveryTag, true),
failure -> {
getLogger().warn(
"ProcessSession commit failed after consuming AMQP messages up to delivery tag {}; negatively acknowledging with requeue",
lastDeliveryTag,
failure
);
consumer.negativeAcknowledge(lastDeliveryTag, true, true);
}
);
}
}

Expand Down
Loading