Add retry for in-memory databases in case they lock
This commit is contained in:
committed by
Michael Minella
parent
18eed8c5c7
commit
cfe666f7fe
@@ -1,6 +1,6 @@
|
||||
# Default database platform is HSQLDB:
|
||||
batch.jdbc.driver=org.h2.Driver
|
||||
batch.jdbc.url=jdbc:h2:file:target/data/h2
|
||||
batch.jdbc.url=jdbc:h2:file:target/data/h2;DB_CLOSE_ON_EXIT=FALSE
|
||||
batch.jdbc.user=sa
|
||||
batch.jdbc.password=
|
||||
batch.jdbc.testWhileIdle=false
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
<job id="job" xmlns="http://www.springframework.org/schema/batch">
|
||||
<step id="step">
|
||||
<tasklet>
|
||||
<chunk reader="reader" writer="writer" commit-interval="2" skip-limit="2">
|
||||
<chunk reader="reader" writer="writer" commit-interval="2" skip-limit="2" retry-limit="10">
|
||||
<retryable-exception-classes>
|
||||
<include class="org.springframework.dao.CannotAcquireLockException" />
|
||||
</retryable-exception-classes>
|
||||
<skippable-exception-classes>
|
||||
<include class="java.lang.IllegalStateException" />
|
||||
</skippable-exception-classes>
|
||||
@@ -54,6 +57,31 @@
|
||||
<property name="receiveTimeout" value="1000" />
|
||||
</bean>
|
||||
|
||||
<bean id="retryAdvice" class="org.springframework.batch.retry.interceptor.RetryOperationsInterceptor">
|
||||
<property name="retryOperations">
|
||||
<bean class="org.springframework.batch.retry.support.RetryTemplate">
|
||||
<property name="retryPolicy">
|
||||
<bean class="org.springframework.batch.retry.policy.SimpleRetryPolicy">
|
||||
<constructor-arg value="10" />
|
||||
<constructor-arg>
|
||||
<map key-type="java.lang.Class" value-type="java.lang.Boolean">
|
||||
<entry key="org.springframework.dao.CannotAcquireLockException" value="true" />
|
||||
</map>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
The chunk writer listens for results coming back, and can fail to acquire a lock. This is especially true for
|
||||
in-memory databases (MySql and Orackle seem to deal with locks better)
|
||||
-->
|
||||
<aop:config proxy-target-class="true">
|
||||
<aop:advisor advice-ref="retryAdvice" pointcut="execution(* org.springframework.integration.core.MessagingTemplate.receive(..))" />
|
||||
</aop:config>
|
||||
|
||||
<int-jdbc:message-store id="messageStore" data-source="dataSource" />
|
||||
|
||||
<integration:channel id="requests">
|
||||
@@ -65,7 +93,7 @@
|
||||
<integration:service-activator input-channel="requests" output-channel="replies" ref="chunkHandler">
|
||||
<integration:poller>
|
||||
<integration:interval-trigger interval="100" />
|
||||
<integration:transactional isolation="READ_COMMITTED"/>
|
||||
<integration:transactional isolation="READ_COMMITTED" />
|
||||
</integration:poller>
|
||||
</integration:service-activator>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user