INT-2260: JdbcPollingChA: rename prop to maxRows

JIRA: https://jira.spring.io/browse/INT-2260

Having a feedback about confusing with the `max-rows-per-poll` property
name and its responsibility it would be better do not mention `per-poll`
at all

* Deprecate `max-rows-per-poll` in favor of new `max-rows`
* Some code style polishing, tests improvements
* Docs polishing on the matter

* Add `What's New` bullet

* Optimize `maxRows` logic
* Document vendor-specific native SELECT limiting options
* Raise warning in the parsers about deprecated `max-rows-per-poll`

Doc polishing
This commit is contained in:
Artem Bilan
2018-06-14 17:53:25 -04:00
committed by Gary Russell
parent 5a362b62ff
commit 32030c3233
12 changed files with 247 additions and 158 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,14 +60,14 @@ public class JdbcOutboundGatewayTests {
JdbcOutboundGateway jdbcOutboundGateway = new JdbcOutboundGateway(dataSource, "update something");
try {
jdbcOutboundGateway.setMaxRowsPerPoll(10);
jdbcOutboundGateway.setMaxRows(10);
jdbcOutboundGateway.setBeanFactory(mock(BeanFactory.class));
jdbcOutboundGateway.afterPropertiesSet();
fail("Expected an IllegalArgumentException to be thrown.");
}
catch (IllegalArgumentException e) {
assertEquals("If you want to set 'maxRowsPerPoll', then you must provide a 'selectQuery'.", e.getMessage());
assertEquals("If you want to set 'maxRows', then you must provide a 'selectQuery'.", e.getMessage());
}
dataSource.shutdown();
@@ -99,7 +99,8 @@ public class JdbcOutboundGatewayTests {
fail("Expected an IllegalArgumentException to be thrown.");
}
catch (IllegalArgumentException e) {
Assert.assertEquals("The 'updateQuery' and the 'selectQuery' must not both be null or empty.", e.getMessage());
Assert.assertEquals("The 'updateQuery' and the 'selectQuery' must not both be null or empty.",
e.getMessage());
}
}
@@ -108,12 +109,12 @@ public class JdbcOutboundGatewayTests {
JdbcOutboundGateway jdbcOutboundGateway = new JdbcOutboundGateway(dataSource, "select * from DOES_NOT_EXIST");
try {
jdbcOutboundGateway.setMaxRowsPerPoll(null);
jdbcOutboundGateway.setMaxRows(null);
fail("Expected an IllegalArgumentException to be thrown.");
}
catch (IllegalArgumentException e) {
assertEquals("MaxRowsPerPoll must not be null.", e.getMessage());
assertEquals("'maxRows' must not be null.", e.getMessage());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -204,7 +204,7 @@ public class JdbcPollingChannelAdapterIntegrationTests {
"select * from item where id not in (select id from copy)");
adapter.setUpdateSql("insert into copy values(:id,10)");
adapter.setUpdatePerRow(true);
adapter.setMaxRowsPerPoll(1);
adapter.setMaxRows(1);
adapter.setRowMapper(new ItemRowMapper());
adapter.setBeanFactory(mock(BeanFactory.class));
adapter.afterPropertiesSet();
@@ -234,7 +234,7 @@ public class JdbcPollingChannelAdapterIntegrationTests {
"select * from item where status=2");
adapter.setUpdateSql("update item set status = 10 where id = :id");
adapter.setUpdatePerRow(true);
adapter.setMaxRowsPerPoll(1);
adapter.setMaxRows(1);
adapter.setRowMapper(new ItemRowMapper());
adapter.setBeanFactory(mock(BeanFactory.class));
adapter.afterPropertiesSet();

View File

@@ -209,7 +209,7 @@ public class JdbcOutboundGatewayParserTests {
accessor = new DirectFieldAccessor(source);
source = accessor.getPropertyValue("poller"); //JdbcPollingChannelAdapter
accessor = new DirectFieldAccessor(source);
Integer maxRowsPerPoll = (Integer) accessor.getPropertyValue("maxRowsPerPoll");
Integer maxRowsPerPoll = (Integer) accessor.getPropertyValue("maxRows");
assertEquals("maxRowsPerPoll should default to 1", Integer.valueOf(1), maxRowsPerPoll);
}
@@ -225,7 +225,7 @@ public class JdbcOutboundGatewayParserTests {
accessor = new DirectFieldAccessor(source);
source = accessor.getPropertyValue("poller"); //JdbcPollingChannelAdapter
accessor = new DirectFieldAccessor(source);
Integer maxRowsPerPoll = (Integer) accessor.getPropertyValue("maxRowsPerPoll");
Integer maxRowsPerPoll = (Integer) accessor.getPropertyValue("maxRows");
assertEquals("maxRowsPerPoll should default to 10", Integer.valueOf(10), maxRowsPerPoll);
}

View File

@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
xmlns:jdbc="http://www.springframework.org/schema/jdbc">
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
xmlns:jdbc="http://www.springframework.org/schema/jdbc">
<int:channel id="target">
@@ -15,26 +15,28 @@
</int:channel>
<int:channel id="output">
<int:queue />
<int:queue/>
</int:channel>
<int-jdbc:outbound-gateway query="select * from bazz where id=:headers[id]" update="insert into bazz (id, status, name) values (:headers[id], 0, :payload[foo])"
request-channel="target" reply-channel="output" data-source="dataSource" auto-startup="true" max-rows-per-poll="10">
<int-jdbc:outbound-gateway query="select * from bazz where id=:headers[id]"
update="insert into bazz (id, status, name) values (:headers[id], 0, :payload[foo])"
request-channel="target" reply-channel="output" data-source="dataSource"
auto-startup="true" max-rows="10">
<int:poller fixed-rate="1000"/>
</int-jdbc:outbound-gateway>
<jdbc:embedded-database id="dataSource" type="H2"/>
<jdbc:embedded-database id="dataSource" type="H2"/>
<jdbc:initialize-database data-source="dataSource">
<jdbc:script location="classpath:org/springframework/integration/jdbc/config/outboundPollerSchema.sql"/>
</jdbc:initialize-database>
<jdbc:initialize-database data-source="dataSource">
<jdbc:script location="classpath:org/springframework/integration/jdbc/config/outboundPollerSchema.sql"/>
</jdbc:initialize-database>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg ref="dataSource" />
<constructor-arg ref="dataSource"/>
</bean>
</beans>

View File

@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration/jdbc"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration/jdbc
http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd">
<beans:import resource="jdbcInboundChannelAdapterCommonConfig.xml" />
<beans:import resource="jdbcInboundChannelAdapterCommonConfig.xml"/>
<inbound-channel-adapter query="select * from item where status=2"
channel="target" data-source="dataSource" max-rows-per-poll="2"
update="update item set status=10 where id in (:id)" />
channel="target" data-source="dataSource" max-rows="2"
update="update item set status=10 where id in (:id)"/>
</beans:beans>