INT-4050: Refactoring for JDBC Schema Scripts

JIRA: https://jira.spring.io/browse/INT-2625,
https://jira.spring.io/browse/INT-4050,
https://jira.spring.io/browse/INT-4052

Make some refactoring for consistency:

- Move `JdbcMessageStore` to the `store` package
- Make `JdbcMessageStore` only ctor-based configuration for the `JdbcOperations`
- Remove `/channel/` SQL scripts in favor of combined in the `/jdbc/` directory
- Make scripts for the `INT_CHANNEL_MESSAGE` table and indexes generated via VPP

Fix drop script generation

Fix `schema-derby.sql` for suspicious `[]`

Looks like `foundrylogic.vpp` tool generates somehow wrong SQL

Further fix for the `drop` scripts generation

Address PR comments:

* Remove deprecated code in the `JdbcMessageStore`
* Remove separate MySQL script in favor of only one for latest version
* Remove the note in the `jdbc.adoc` about recommendation to use new MySQL version
This commit is contained in:
Artem Bilan
2017-04-12 14:06:19 -04:00
committed by Gary Russell
parent 34db64c832
commit 5224779a04
68 changed files with 464 additions and 482 deletions

View File

@@ -7,7 +7,8 @@
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">
<beans:bean id="messageStore"
class="org.springframework.integration.jdbc.DelayerHandlerRescheduleIntegrationTests$TestJdbcMessageStore">
class="org.springframework.integration.jdbc.store.JdbcMessageStore">
<beans:constructor-arg value="#{T (org.springframework.integration.jdbc.DelayerHandlerRescheduleIntegrationTests).dataSource}"/>
<beans:property name="lazyLoadMessageGroups" value="false"/>
</beans:bean>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@@ -172,15 +172,6 @@ public class DelayerHandlerRescheduleIntegrationTests {
context.close();
}
@SuppressWarnings("unused")
private static class TestJdbcMessageStore extends JdbcMessageStore {
TestJdbcMessageStore() {
this.setDataSource(dataSource);
}
}
@SuppressWarnings("unused")
private static class ExceptionMessageHandler implements MessageHandler {

View File

@@ -31,7 +31,7 @@ import org.springframework.core.serializer.DefaultSerializer;
import org.springframework.core.serializer.Deserializer;
import org.springframework.core.serializer.Serializer;
import org.springframework.messaging.Message;
import org.springframework.integration.jdbc.JdbcMessageStore;
import org.springframework.integration.jdbc.store.JdbcMessageStore;
import org.springframework.integration.store.MessageStore;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.test.util.TestUtils;

View File

@@ -44,7 +44,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.jdbc.JdbcMessageStore;
import org.springframework.integration.jdbc.store.JdbcMessageStore;
import org.springframework.integration.jdbc.store.JdbcMessageStoreTests;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.util.UUIDConverter;
@@ -64,7 +65,7 @@ import org.springframework.transaction.support.TransactionTemplate;
/**
* Based on the test for Derby:
*
* {@link org.springframework.integration.jdbc.JdbcMessageStoreTests}
* {@link JdbcMessageStoreTests}
*
* This tests requires at least MySql 5.6.4 as it uses the fractional second support
* in that version. For more information, please see:

View File

@@ -1,74 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.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/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<jdbc:embedded-database id="dataSource" type="DERBY"/>
<jdbc:initialize-database data-source="dataSource" ignore-failures="DROPS">
<jdbc:script location="${int.drop.script}"/>
<jdbc:script location="${int.schema.script}"/>
</jdbc:initialize-database>
<int-jdbc:message-store id="messageStore" data-source="dataSource"/>
<channel id="input" xmlns="http://www.springframework.org/schema/integration">
<queue ref="storeQueue"/>
</channel>
<bean id="storeQueue" class="org.springframework.integration.store.MessageGroupQueue">
<constructor-arg ref="messageStore"/>
<constructor-arg value="JdbcMessageStoreChannelIntegrationTests"/>
<constructor-arg ref="lock"/>
</bean>
<int:channel id="output"/>
<int:logging-channel-adapter channel="output"/>
<service-activator id="service-activator"
input-channel="input" output-channel="output"
xmlns="http://www.springframework.org/schema/integration">
<beans:bean
class="org.springframework.integration.jdbc.JdbcMessageStoreChannelIntegrationTests$Service"/>
<poller fixed-rate="200">
<advice-chain>
<ref bean="txAdvice"/>
<ref bean="lock"/>
</advice-chain>
</poller>
</service-activator>
<bean id="lock" class="org.springframework.integration.jdbc.LockInterceptor"/>
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
<context:property-placeholder location="int-${ENVIRONMENT:derby}.properties"
system-properties-mode="OVERRIDE"
ignore-unresolvable="true"
order="1"/>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<int:header-enricher input-channel="routingSlip" output-channel="input">
<int:routing-slip value="@myService.nextPath(request, reply)"/>
</int:header-enricher>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.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/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<jdbc:embedded-database id="dataSource" type="DERBY"/>
<jdbc:initialize-database data-source="dataSource" ignore-failures="DROPS">
<jdbc:script location="${int.drop.script}"/>
<jdbc:script location="${int.schema.script}"/>
</jdbc:initialize-database>
<int-jdbc:message-store id="messageStore" data-source="dataSource"/>
<channel id="input" xmlns="http://www.springframework.org/schema/integration">
<queue ref="storeQueue"/>
</channel>
<bean id="storeQueue" class="org.springframework.integration.store.MessageGroupQueue">
<constructor-arg ref="messageStore"/>
<constructor-arg value="JdbcMessageStoreChannelIntegrationTests"/>
<constructor-arg ref="lock"/>
</bean>
<int:channel id="output"/>
<int:logging-channel-adapter channel="output"/>
<service-activator id="service-activator"
input-channel="input" output-channel="output"
xmlns="http://www.springframework.org/schema/integration">
<beans:bean
class="org.springframework.integration.jdbc.store.JdbcMessageStoreChannelIntegrationTests$Service"/>
<poller fixed-rate="200">
<advice-chain>
<ref bean="txAdvice"/>
<ref bean="lock"/>
</advice-chain>
</poller>
</service-activator>
<bean id="lock" class="org.springframework.integration.jdbc.LockInterceptor"/>
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
<context:property-placeholder location="int-${ENVIRONMENT:derby}.properties"
system-properties-mode="OVERRIDE"
ignore-unresolvable="true"
order="1"/>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<int:header-enricher input-channel="routingSlip" output-channel="input">
<int:routing-slip value="@myService.nextPath(request, reply)"/>
</int:header-enricher>
</beans>

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.jdbc;
package org.springframework.integration.jdbc.store;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.instanceOf;

View File

@@ -1,64 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.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/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<jdbc:embedded-database id="dataSource" type="DERBY" />
<jdbc:initialize-database data-source="dataSource"
ignore-failures="DROPS">
<jdbc:script location="${int.drop.script}" />
<jdbc:script location="${int.schema.script}" />
</jdbc:initialize-database>
<int-jdbc:message-store id="messageStore"
data-source="dataSource" />
<channel id="relay" xmlns="http://www.springframework.org/schema/integration">
<queue message-store="messageStore" />
</channel>
<channel id="durable" xmlns="http://www.springframework.org/schema/integration">
<queue message-store="messageStore" />
</channel>
<service-activator id="service-relay" input-channel="relay"
output-channel="durable" xmlns="http://www.springframework.org/schema/integration">
<beans:bean
class="org.springframework.integration.jdbc.JdbcMessageStoreChannelOnePollerIntegrationTests$Service" />
<poller fixed-rate="200">
<advice-chain>
<ref bean="txAdvice" />
<ref bean="lock" />
</advice-chain>
</poller>
</service-activator>
<bean id="lock" class="org.springframework.integration.jdbc.LockInterceptor" />
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="*" />
</tx:attributes>
</tx:advice>
<context:property-placeholder location="int-${ENVIRONMENT:derby}.properties"
system-properties-mode="OVERRIDE"
ignore-unresolvable="true"
order="1"/>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.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/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<jdbc:embedded-database id="dataSource" type="DERBY" />
<jdbc:initialize-database data-source="dataSource"
ignore-failures="DROPS">
<jdbc:script location="${int.drop.script}" />
<jdbc:script location="${int.schema.script}" />
</jdbc:initialize-database>
<int-jdbc:message-store id="messageStore"
data-source="dataSource" />
<channel id="relay" xmlns="http://www.springframework.org/schema/integration">
<queue message-store="messageStore" />
</channel>
<channel id="durable" xmlns="http://www.springframework.org/schema/integration">
<queue message-store="messageStore" />
</channel>
<service-activator id="service-relay" input-channel="relay"
output-channel="durable" xmlns="http://www.springframework.org/schema/integration">
<beans:bean
class="org.springframework.integration.jdbc.store.JdbcMessageStoreChannelOnePollerIntegrationTests$Service" />
<poller fixed-rate="200">
<advice-chain>
<ref bean="txAdvice" />
<ref bean="lock" />
</advice-chain>
</poller>
</service-activator>
<bean id="lock" class="org.springframework.integration.jdbc.LockInterceptor" />
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="*" />
</tx:attributes>
</tx:advice>
<context:property-placeholder location="int-${ENVIRONMENT:derby}.properties"
system-properties-mode="OVERRIDE"
ignore-unresolvable="true"
order="1"/>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
</beans>

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.jdbc;
package org.springframework.integration.jdbc.store;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

View File

@@ -40,7 +40,7 @@
</bean>
<service-activator id="service-activator" input-channel="input" output-channel="output" xmlns="http://www.springframework.org/schema/integration">
<beans:bean class="org.springframework.integration.jdbc.JdbcMessageStoreChannelTests$Service" />
<beans:bean class="org.springframework.integration.jdbc.store.JdbcMessageStoreChannelTests$Service" />
<poller fixed-rate="2000">
<transactional />
</poller>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.jdbc;
package org.springframework.integration.jdbc.store;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -26,10 +26,11 @@ import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.store.MessageGroup;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.integration.store.MessageGroup;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.jdbc;
package org.springframework.integration.jdbc.store;
import static org.junit.Assert.assertEquals;

View File

@@ -1,26 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<jdbc:embedded-database id="dataSource" type="DERBY"/>
<jdbc:initialize-database data-source="dataSource" ignore-failures="DROPS">
<jdbc:script location="${int.drop.script}"/>
<jdbc:script location="${int.schema.script}"/>
</jdbc:initialize-database>
<context:property-placeholder location="int-${ENVIRONMENT:derby}.properties"
system-properties-mode="OVERRIDE"
ignore-unresolvable="true"
order="1"/>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<jdbc:embedded-database id="dataSource" type="DERBY"/>
<jdbc:initialize-database data-source="dataSource" ignore-failures="DROPS">
<jdbc:script location="${int.drop.script}"/>
<jdbc:script location="${int.schema.script}"/>
</jdbc:initialize-database>
<context:property-placeholder location="int-${ENVIRONMENT:derby}.properties"
system-properties-mode="OVERRIDE"
ignore-unresolvable="true"
order="1"/>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
</beans>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.jdbc;
package org.springframework.integration.jdbc.store;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

View File

@@ -24,7 +24,7 @@
/> </bean> -->
<jdbc:initialize-database data-source="dataSource">
<jdbc:script location="classpath:org/springframework/integration/jdbc/store/channel/schema-derby.sql" />
<jdbc:script location="classpath:org/springframework/integration/jdbc/schema-derby.sql" />
</jdbc:initialize-database>
<bean id="queryProvider"

View File

@@ -17,8 +17,8 @@
</bean>
<jdbc:initialize-database data-source="dataSource" ignore-failures="DROPS">
<jdbc:script location="classpath:org/springframework/integration/jdbc/store/channel/schema-drop-h2.sql" />
<jdbc:script location="classpath:org/springframework/integration/jdbc/store/channel/schema-h2.sql" />
<jdbc:script location="classpath:org/springframework/integration/jdbc/schema-drop-h2.sql" />
<jdbc:script location="classpath:org/springframework/integration/jdbc/schema-h2.sql" />
</jdbc:initialize-database>
<bean id="queryProvider"

View File

@@ -17,8 +17,8 @@
</bean>
<jdbc:initialize-database data-source="dataSource" ignore-failures="DROPS">
<jdbc:script location="classpath:org/springframework/integration/jdbc/store/channel/schema-drop-hsql.sql"/>
<jdbc:script location="classpath:org/springframework/integration/jdbc/store/channel/schema-hsql.sql"/>
<jdbc:script location="classpath:org/springframework/integration/jdbc/schema-drop-hsqldb.sql"/>
<jdbc:script location="classpath:org/springframework/integration/jdbc/schema-hsqldb.sql"/>
</jdbc:initialize-database>
<bean id="queryProvider" class="org.springframework.integration.jdbc.store.channel.HsqlChannelMessageStoreQueryProvider"/>