MQTT: Throw Runtime Exception when manual ack fails#22117
MQTT: Throw Runtime Exception when manual ack fails#22117nkokitkar wants to merge 3 commits intoapache:mainfrom
Conversation
gnodet
left a comment
There was a problem hiding this comment.
Review — Claude Code on behalf of Guillaume Nodet
Verdict: REQUEST CHANGES (recommend closing)
This PR has a fundamental design flaw that makes the change ineffective.
CRITICAL: RuntimeException is silently swallowed
The onComplete() callback is invoked by UnitOfWorkHelper.doneSynchronization(), which catches all exceptions:
// UnitOfWorkHelper.java
try {
synchronization.onComplete(exchange);
} catch (Exception e) {
// logged and swallowed
}This means the RuntimeException("Exchange was not acknowledged") thrown by this PR is silently caught and discarded. The MQTT message is still NOT acknowledged (same behavior as before the change), but now there's a misleading exception in the logs with no actionable outcome.
The change provides zero functional benefit.
Other issues
- No tests — No unit or integration tests demonstrate or verify the intended behavior.
- No JIRA issue — A behavioral change in message acknowledgement should have a tracking issue.
- No documentation — No docs explaining when
ACKNOWLEDGE_ALLOWEDwould befalseor what the expected behavior should be.
Suggested alternative approaches
If the goal is to signal that acknowledgement was denied:
- Log a warning directly (simplest — don't throw, just log)
- Set the exchange as failed (
exchange.setException(...)) before the synchronization callback - Use the
onFailure()path instead ofonComplete() - Use a custom error handler to handle the denial
The current approach of throwing from onComplete() is architecturally incompatible with how Camel processes synchronization callbacks.
|
If we change the behavior this require a JIRA isssue. |
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
| @Override | ||
| public void onFailure(Exchange exchange) { | ||
| LOG.error("Rollback due to error processing Exchange ID: {}", exchange.getExchangeId(), | ||
| LOG.debug("Rollback due to error processing Exchange ID: {}", exchange.getExchangeId(), |
Revert the log level in onFailure from debug back to error, as this callback handles exchange processing failures which should not be silently swallowed at debug level. Addresses review comment from @Croway. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Description
Small fix to throw an exception when manual ack failed instead of a warning log.
Target
mainbranch)Tracking
Apache Camel coding standards and style
mvn clean install -DskipTestslocally from root folder and I have committed all auto-generated changes.