Skip to content

NIFI-15892 Add negative acknowledgement handling for ConsumeAMQP batches#11191

Open
ing-mattioni wants to merge 1 commit into
apache:mainfrom
ing-mattioni:NIFI-15892-consumeamqp-batch-nack
Open

NIFI-15892 Add negative acknowledgement handling for ConsumeAMQP batches#11191
ing-mattioni wants to merge 1 commit into
apache:mainfrom
ing-mattioni:NIFI-15892-consumeamqp-batch-nack

Conversation

@ing-mattioni
Copy link
Copy Markdown

@ing-mattioni ing-mattioni commented Apr 30, 2026

Summary

NIFI-15892

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000
  • Pull request contains commits signed with a registered key indicating Verified status

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using ./mvnw clean install -P contrib-check
    • JDK 21
    • JDK 25

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

Summary

NIFI-15892

This pull request updates ConsumeAMQP manual acknowledgement handling for batched deliveries.

When Auto-Acknowledge Messages is set to false and Batch Size is greater than 1, ConsumeAMQP acknowledges the last delivery tag after a successful ProcessSession commit using cumulative acknowledgement.

The previous implementation registered only the successful commit callback. If the ProcessSession commit failed or could not complete successfully, outstanding AMQP deliveries could remain unacknowledged until the broker closed the channel, for example due to RabbitMQ consumer_timeout.

This change adds explicit negative acknowledgement handling for the commit failure path.

Changes

  • Preserves the existing successful commit behavior:
    • basicAck(lastDeliveryTag, true)
  • Adds commit failure handling:
    • basicNack(lastDeliveryTag, true, true)
  • Keeps the existing behavior unchanged for Auto-Acknowledge Messages = true
  • Preserves cumulative acknowledgement behavior for batched manual acknowledgements
  • Improves reliability when using:
    • Auto-Acknowledge Messages = false
    • Batch Size > 1
    • RabbitMQ / AMQP 0.9.1 brokers with consumer acknowledgement timeout enabled

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000
  • Pull request contains commits signed with a registered key indicating Verified status

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using ./mvnw clean install -P contrib-check
    • JDK 21
    • JDK 25

Module-level verification performed:

./mvnw -pl nifi-extension-bundles/nifi-amqp-bundle/nifi-amqp-processors -am clean test

or on Windows PowerShell:

.\mvnw.cmd -pl nifi-extension-bundles\nifi-amqp-bundle\nifi-amqp-processors -am clean test

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

No new dependencies were added.

Documentation

  • Documentation formatting appears as expected in rendered files

No user-facing documentation files were changed.

@ing-mattioni ing-mattioni force-pushed the NIFI-15892-consumeamqp-batch-nack branch from be57df2 to 5a217b0 Compare April 30, 2026 13:15
Copy link
Copy Markdown
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @ing-mattioni. The change looks straightforward. Have you evaluated options for testing this change in behavior? If you can rebase the pull request to the latest main branch, that would be helpful.

@turcsanyip
Copy link
Copy Markdown
Contributor

It looks good to me too. Just one minor question: why do acknowledge() and negativeAcknowledge() methods expose the boolean flag parameters when only true is ever passed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants