davsclaus commented on code in PR #28205:
URL: https://github.com/apache/camel/pull/28205#discussion_r4333295912
##########
components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java:
##########
@@ -112,27 +112,24 @@ public void run() {
}
try {
final TransactionContext txc = transactionCtx;
- // process using the asynchronous routing engine
- processor.process(exchange, new AsyncCallback() {
- public void done(boolean asyncDone) {
- // a rollback only exchange (without an
exception) did not complete successfully either
- boolean rollback = exchange.getException() !=
null || exchange.isRollbackOnly()
- || exchange.isRollbackOnlyLast();
- if (rollback && txc != null) {
- LOG.trace("Rollback transaction: {}",
txc.getTxnId());
- txc.rollbackTransaction();
- }
- if (exchange.getException() != null) {
-
getExceptionHandler().handleException("Error processing exchange", exchange,
- exchange.getException());
- }
- // It's OK, I commit
- if (!rollback && txc != null) {
- LOG.trace("Commit transaction: {}",
txc.getTxnId());
- txc.commitTransaction();
- }
+ if (txc != null) {
+ // a Hazelcast transaction belongs to the thread
that began it, and cannot be committed
+ // or rolled back from another thread: wait for
the exchange to complete, also when the
+ // route continues on another thread, and end the
transaction on this thread
+ try {
+ processor.process(exchange);
+ } catch (Exception e) {
+ exchange.setException(e);
}
- });
+ onExchangeDone(exchange, txc);
Review Comment:
Optional: the exchange is created with `createExchange(true)`, so with the
pooled exchange factory it is reset when its unit of work is done, before this
reads `getException()`. Now that this branch is synchronous,
`createExchange(false)` plus `releaseExchange(exchange, false)` after
`onExchangeDone` would close that gap, like `JpaConsumer` and `SqlConsumer` do.
Fine as a follow-up.
--
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]