allthingssecurity opened a new pull request, #28465:
URL: https://github.com/apache/camel/pull/28465

   # Description
   
   [CAMEL-25947](https://issues.apache.org/jira/browse/CAMEL-25947)
   
   With the default `confirm=auto`, the InOnly producer waits for publisher 
confirms only when `ConnectionFactory.isPublisherConfirms()` is true. In 
spring-rabbit 4.1.1 that is the case only for `ConfirmType.CORRELATED`. A 
connection factory with `ConfirmType.SIMPLE` answers 
`isSimplePublisherConfirms()` instead. Examples are Spring Boot's 
`spring.rabbitmq.publisher-confirm-type=simple`, and `SIMPLE` is the type meant 
for `RabbitTemplate.invoke` + `waitForConfirms`. So the producer never waited: 
a message RabbitMQ negatively acknowledged (for example a full 
`x-overflow=reject-publish` queue) or never confirmed was lost without an 
error. The option doc says "auto = Camel detects if the connection factory uses 
confirms or not".
   
   Changes:
   - `SpringRabbitMQProducer.processInOnly`: `confirm=auto` waits when 
`isPublisherConfirms() || isSimplePublisherConfirms()`.
   - The `TimeoutException` of a negative acknowledgement now says "Message 
negatively acknowledged by RabbitMQ" (it said "Message not sent within N 
millis"). In spring-rabbit 4.1.1, `RabbitTemplate.waitForConfirms(long)` 
returns `false` only for a nack. When no confirm arrives within 
`confirmTimeout`, amqp-client 5.31.0 `ChannelN.waitForConfirms` throws 
`java.util.concurrent.TimeoutException`, and `RabbitTemplate` turns it into an 
`AmqpTimeoutException` (javap of both). The producer's catch puts that on the 
exchange, as it already did for `confirm=enabled`.
   - Upgrade guide (4.24): producers on a `SIMPLE` connection factory now wait 
up to `confirmTimeout` per message. A nack fails the exchange with a 
`TimeoutException`, and a missing confirm with an `AmqpTimeoutException` (cause 
`java.util.concurrent.TimeoutException`). `confirm=disabled` sends without 
waiting, as before.
   - No option or generated file change; the option description was already 
right.
   - Backport: camel-4.23.x, 4.22.x, 4.18.x and 4.14.x have the same check. I 
read the code on those branches but did not run the tests there. It changes 
what users see (a wait, and failures), so I suggest main only unless the 
reviewers prefer otherwise.
   
   Tests:
   - New `SpringRabbitMQProducerConfirmTest` (JUnit assertions, as in the 
module). It uses a real `CachingConnectionFactory` over a mocked RabbitMQ 
client, so Spring itself decides the confirm type and puts the channel in 
confirm mode. The mocked `Channel.waitForConfirms(long)` answers as the 
RabbitMQ client does: `true` when all messages were acknowledged, `false` for a 
nack, and a `TimeoutException` when the timeout elapses (comment on the class).
   - Fail on main:
     - `negativeAcknowledgementFailsTheExchangeWithSimplePublisherConfirms`: 
`expected: <java.util.concurrent.TimeoutException> but was: <null>`;
     - `missingConfirmFailsTheExchangeWithSimplePublisherConfirms`: `expected: 
<org.springframework.amqp.AmqpTimeoutException> but was: <null>`;
     - `acknowledgedMessageIsSentWithSimplePublisherConfirms`: `Wanted but not 
invoked: channel.waitForConfirms(5000L)`.
   - Controls that pass on main and with the fix: 
`acknowledgedMessageIsSentWithCorrelatedPublisherConfirms` and 
`noConfirmIsAwaitedWithoutPublisherConfirms`.
   - camel-spring-rabbitmq unit tests: 11 run, 0 failures. The formatter and 
import-sort plugins ran. I built offline with `-Dasm-version=9.11`. The ITs 
were not run locally; CI runs them. `RabbitMQProducerInvalidExchangeIT` uses 
`CORRELATED` and is unchanged.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it): 
[CAMEL-25947](https://issues.apache.org/jira/browse/CAMEL-25947).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built camel-spring-rabbitmq and ran its tests, including the formatter 
and import-sort plugins. No generated file changes. I did not run the full root 
build.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5). The commit 
carries a `Co-Authored-By` trailer.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to