allthingssecurity commented on code in PR #30531:
URL: https://github.com/apache/camel/pull/30531#discussion_r4651462551
##########
components/camel-jpa/src/main/java/org/apache/camel/processor/idempotent/jpa/JpaMessageIdRepository.java:
##########
@@ -109,26 +163,40 @@ public boolean add(final Exchange exchange, final String
messageId) {
}
} catch (Exception ex) {
if (isConstraintViolation(ex)) {
- // concurrent insert of the same messageId detected via
unique constraint
- // treat as duplicate rather than failing the exchange
- LOG.debug("Duplicate message detected during concurrent
insert: {}", messageId);
- rc[0] = Boolean.FALSE;
+ // possibly a concurrent insert of the same messageId: add
checks it in a new transaction
+ violation[0] = ex;
} else {
String contextInfo = String.format(SOMETHING_WENT_WRONG,
ex.getMessage());
throw new PersistenceException(contextInfo, ex);
}
} finally {
- try {
- if (entityManager.isOpen()) {
- entityManager.close();
- }
- } catch (Exception e) {
- // ignore
- }
+ closeEntityManager(entityManager);
}
});
+ }
- LOG.debug("add {} -> {}", messageId, rc[0]);
+ /**
+ * Whether the message id is in the repository, read in a new transaction
after the one of the insert, or in the
Review Comment:
Thanks, split into the two cases in 2a37347df0eb (javadoc only). I kept the
wording closer to what the method does: outside a caller's transaction it reads
in a new transaction, and inside one it uses that transaction, with the shared
EntityManager when there is one.
_Claude Code on behalf of allthingssecurity_
--
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]