This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository

The following commit(s) were added to refs/heads/master by this push:
     new f3f31be  Regen
f3f31be is described below

commit f3f31beb6f9619958171e7695aefab2956d3545b
Author: Andrea Cosentino <>
AuthorDate: Tue Sep 10 10:46:23 2019 +0200

 .../modules/ROOT/pages/sql-component.adoc          | 48 +++++++++++++++++++++-
 1 file changed, 46 insertions(+), 2 deletions(-)

diff --git a/docs/components/modules/ROOT/pages/sql-component.adoc 
index bcb3a47..5cc40f2 100644
--- a/docs/components/modules/ROOT/pages/sql-component.adoc
+++ b/docs/components/modules/ROOT/pages/sql-component.adoc
@@ -776,9 +776,9 @@ JDBC vendor.
 <bean id="repo"
   <property name="transactionManager" ref="transactionManager"/>
-  <propertyname="repositoryName" value="aggregation"/>
+  <property name="repositoryName" value="aggregation"/>
   <property name="dataSource" ref="dataSource"/>
-  <property name"jdbcOptimisticLockingExceptionMapper" 
+  <property name="jdbcOptimisticLockingExceptionMapper" 
 <!-- use the default mapper with extraFQN class names from our JDBC driver -->
 <bean id="myExceptionMapper" 
@@ -791,6 +791,50 @@ 
+=== Propagation behavior
+`JdbcAggregationRepository` uses two distinct _transaction templates_ from 
Spring-TX. One is read-only
+and one is used for read-write operations.
+However, when using `JdbcAggregationRepository` within a route that itself 
uses `<transacted />` and there's
+common `PlatformTransactionManager` used, there may be a need to configure 
_propagation behavior_ used by
+transaction templates inside `JdbcAggregationRepository`.
+Here's a way to do it:
+<bean id="repo"
+  <property name="propagationBehaviorName" value="PROPAGATION_NESTED" />
+Propagation is specified by constants of 
`org.springframework.transaction.TransactionDefinition` interface,
+so `propagationBehaviorName` is convenient setter that allows to use names of 
the constants.
+=== PostgreSQL case
+There's special database that may cause problems with optimistic locking used 
by `JdbcAggregationRepository`.
+PostgreSQL marks connection as invalid in case of data integrity violation 
exception (the one with SQLState 23505).
+This makes the connection effectively unusable within nested transaction.
+Details can be found
 this document].
extends `JdbcAggregationRepository` and
+uses special `INSERT .. ON CONFLICT ..` statement to provide optimistic 
locking behavior.
+This statement is (with default aggregation table definition):
+INSERT INTO aggregation (id, exchange) values (?, ?) ON CONFLICT DO NOTHING
+Details can be found[in 
PostgreSQL documentation].
+When this clause is used, `java.sql.PreparedStatement.executeUpdate()` call 
returns `0` instead of throwing
+SQLException with SQLState=23505. Further handling is exactly the same as with 
generic `JdbcAggregationRepository`,
+but without marking PostgreSQL connection as invalid.
 == Camel Sql Starter
 A starter module is available to spring-boot users. When using the starter,

Reply via email to