oscerd commented on code in PR #26523:
URL: https://github.com/apache/camel/pull/26523#discussion_r4035441951


##########
components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaProducerTest.java:
##########
@@ -189,6 +192,39 @@ public void processAsyncSendsMessageWithException() {
         assertRecordMetadataExists();
     }
 
+    @Test
+    public void processAsyncCompletesCallbackWhenBeginTransactionFails() 
throws Exception {
+        // CAMEL-24780: a failure to begin the transaction must set the 
exception and complete the async
+        // callback rather than escaping process(), and it must not leave the 
unit of work flagged as
+        // transacted without a synchronization to commit or roll it back.
+        setTransactionId(producer, "test-tx");

Review Comment:
   Applied in `ae932f8` — replaced the reflection with 
`endpoint.getConfiguration().setTransactionalId("test-tx")` + 
`producer.doStart()`, so `transactionId` is derived through the real init path. 
As you noted, `doStart()` doesn't recreate the producer (the mock is already 
set via `setKafkaProducer`), `initTransactions()` is a no-op on the mock, and 
the worker pool is pre-set — so the test stays self-contained and the 
`setTransactionId` helper + `java.lang.reflect.Field` import are gone. Thanks 
for the cleaner approach!
   
   _Claude Code on behalf of @oscerd_
   



-- 
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