From 1b0a2e85c35ec2880ab56eb79c4b3c970f999f08 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Tue, 9 Aug 2011 09:34:59 -0400 Subject: [PATCH] INT-2029 added initial implementation of RedisMessageStore. Upgraded Jackson to version 1.8.3 which is used by spring-data-redis. Regenerated POM files --- build.gradle | 15 +++- spring-integration-amqp/pom.xml | 24 +++--- spring-integration-core/pom.xml | 14 ++-- spring-integration-event/pom.xml | 12 +-- spring-integration-feed/pom.xml | 12 +-- spring-integration-file/pom.xml | 12 +-- spring-integration-ftp/pom.xml | 12 +-- spring-integration-gemfire/pom.xml | 12 +-- spring-integration-http/pom.xml | 12 +-- spring-integration-ip/pom.xml | 24 +++--- spring-integration-jdbc/pom.xml | 16 ++-- spring-integration-jmx/pom.xml | 12 +-- spring-integration-mail/pom.xml | 12 +-- spring-integration-mongodb/pom.xml | 12 +-- spring-integration-redis/pom.xml | 46 ++++++++++- .../redis/store/RedisMessageStore.java | 80 +++++++++++++++++++ .../redis/store/RedisMessageStoreTests.java | 44 ++++++++++ spring-integration-rmi/pom.xml | 20 ++--- spring-integration-scripting/pom.xml | 12 +-- spring-integration-sftp/pom.xml | 24 +++--- spring-integration-twitter/pom.xml | 12 +-- spring-integration-xmpp/pom.xml | 12 +-- 22 files changed, 311 insertions(+), 140 deletions(-) create mode 100644 spring-integration-redis/src/main/java/org/springframework/integration/redis/store/RedisMessageStore.java create mode 100644 spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisMessageStoreTests.java diff --git a/build.gradle b/build.gradle index 89878160a2..c74b348048 100644 --- a/build.gradle +++ b/build.gradle @@ -116,7 +116,7 @@ configure(javaprojects) { cglibVersion = '2.2' commonsNetVersion = '2.0' easymockVersion = '2.3' - jacksonVersion = '1.4.3' + jacksonVersion = '1.8.3' javaxActivationVersion = '1.1.1' junitVersion = '4.8.2' log4jVersion = '1.2.12' @@ -363,8 +363,17 @@ project('spring-integration-redis') { dependencies { compile project(":spring-integration-core") compile "org.springframework:spring-context:$springVersion" - compile "org.springframework.data:spring-data-redis:$springDataRedisVersion" - compile "org.springframework.data:spring-data-commons-core:$springDataCommonsVersion" + compile "org.springframework:spring-dao:2.0.3" + compile("org.codehaus.jackson:jackson-mapper-asl:$jacksonVersion") + compile("org.codehaus.jackson:jackson-core-asl:$jacksonVersion") + compile ("org.springframework.data:spring-data-redis:$springDataRedisVersion"){ + exclude group: 'org.springframework', module: 'spring-beans' + exclude group: 'org.springframework', module: 'spring-tx' + } + compile ("org.springframework.data:spring-data-commons-core:$springDataCommonsVersion"){ + exclude group: 'org.springframework', module: 'spring-beans' + exclude group: 'org.springframework', module: 'spring-tx' + } testCompile project(":spring-integration-test") } } diff --git a/spring-integration-amqp/pom.xml b/spring-integration-amqp/pom.xml index 23f7a44b4b..478cd6bca0 100644 --- a/spring-integration-amqp/pom.xml +++ b/spring-integration-amqp/pom.xml @@ -138,6 +138,12 @@ + + org.springframework.integration + spring-integration-stream + 2.1.0.BUILD-SNAPSHOT + test + cglib cglib-nodep @@ -156,6 +162,12 @@ 2.1.0.BUILD-SNAPSHOT test + + org.springframework.integration + spring-integration-core + 2.1.0.BUILD-SNAPSHOT + compile + org.easymock easymock @@ -180,12 +192,6 @@ 1.1 test - - org.springframework.integration - spring-integration-stream - 2.1.0.BUILD-SNAPSHOT - test - org.mockito mockito-all @@ -198,12 +204,6 @@ 3.1.0.M2 compile - - org.springframework.integration - spring-integration-core - 2.1.0.BUILD-SNAPSHOT - compile - junit junit-dep diff --git a/spring-integration-core/pom.xml b/spring-integration-core/pom.xml index f610bb7282..21eb396cd0 100644 --- a/spring-integration-core/pom.xml +++ b/spring-integration-core/pom.xml @@ -142,19 +142,19 @@ 2.3 test - - org.codehaus.jackson - jackson-mapper-asl - 1.4.3 - compile - true - org.springframework spring-test 3.1.0.M2 test + + org.codehaus.jackson + jackson-mapper-asl + 1.8.3 + compile + true + org.hamcrest hamcrest-all diff --git a/spring-integration-event/pom.xml b/spring-integration-event/pom.xml index 08550702ac..dcf5f12f79 100644 --- a/spring-integration-event/pom.xml +++ b/spring-integration-event/pom.xml @@ -100,12 +100,6 @@ - - org.springframework.integration - spring-integration-test - 2.1.0.BUILD-SNAPSHOT - test - org.easymock easymock @@ -118,6 +112,12 @@ 2.1.0.BUILD-SNAPSHOT compile + + org.springframework.integration + spring-integration-test + 2.1.0.BUILD-SNAPSHOT + test + org.easymock easymockclassextension diff --git a/spring-integration-feed/pom.xml b/spring-integration-feed/pom.xml index b246994445..81d81f47d5 100644 --- a/spring-integration-feed/pom.xml +++ b/spring-integration-feed/pom.xml @@ -136,18 +136,18 @@ 2.1.0.BUILD-SNAPSHOT test - - org.easymock - easymock - 2.3 - test - org.springframework.integration spring-integration-core 2.1.0.BUILD-SNAPSHOT compile + + org.easymock + easymock + 2.3 + test + org.easymock easymockclassextension diff --git a/spring-integration-file/pom.xml b/spring-integration-file/pom.xml index 0db05fdb64..8be171db85 100644 --- a/spring-integration-file/pom.xml +++ b/spring-integration-file/pom.xml @@ -100,12 +100,6 @@ - - org.springframework.integration - spring-integration-test - 2.1.0.BUILD-SNAPSHOT - test - org.easymock easymock @@ -118,6 +112,12 @@ 2.1.0.BUILD-SNAPSHOT compile + + org.springframework.integration + spring-integration-test + 2.1.0.BUILD-SNAPSHOT + test + org.easymock easymockclassextension diff --git a/spring-integration-ftp/pom.xml b/spring-integration-ftp/pom.xml index 5c7173c793..1f1a2dd97a 100644 --- a/spring-integration-ftp/pom.xml +++ b/spring-integration-ftp/pom.xml @@ -112,6 +112,12 @@ 1.2.12 test + + org.springframework.integration + spring-integration-file + 2.1.0.BUILD-SNAPSHOT + compile + org.springframework.integration spring-integration-test @@ -167,12 +173,6 @@ 1.8.4 test - - org.springframework.integration - spring-integration-file - 2.1.0.BUILD-SNAPSHOT - compile - junit junit-dep diff --git a/spring-integration-gemfire/pom.xml b/spring-integration-gemfire/pom.xml index 7745a62680..8f4bb8ae30 100644 --- a/spring-integration-gemfire/pom.xml +++ b/spring-integration-gemfire/pom.xml @@ -146,18 +146,18 @@ 1.1 test - - org.springframework.integration - spring-integration-stream - 2.1.0.BUILD-SNAPSHOT - test - org.mockito mockito-all 1.8.4 test + + org.springframework.integration + spring-integration-stream + 2.1.0.BUILD-SNAPSHOT + test + log4j log4j diff --git a/spring-integration-http/pom.xml b/spring-integration-http/pom.xml index 0e7ea628e9..940cc25f39 100644 --- a/spring-integration-http/pom.xml +++ b/spring-integration-http/pom.xml @@ -130,18 +130,18 @@ 2.1.0.BUILD-SNAPSHOT test - - org.easymock - easymock - 2.3 - test - org.springframework.integration spring-integration-core 2.1.0.BUILD-SNAPSHOT compile + + org.easymock + easymock + 2.3 + test + commons-httpclient commons-httpclient diff --git a/spring-integration-ip/pom.xml b/spring-integration-ip/pom.xml index 62d48f1463..d5545cf133 100644 --- a/spring-integration-ip/pom.xml +++ b/spring-integration-ip/pom.xml @@ -100,12 +100,6 @@ - - org.springframework.integration - spring-integration-test - 2.1.0.BUILD-SNAPSHOT - test - org.easymock easymock @@ -118,6 +112,12 @@ 2.1.0.BUILD-SNAPSHOT compile + + org.springframework.integration + spring-integration-test + 2.1.0.BUILD-SNAPSHOT + test + org.easymock easymockclassextension @@ -142,18 +142,18 @@ 1.1 test - - org.springframework.integration - spring-integration-stream - 2.1.0.BUILD-SNAPSHOT - runtime - org.mockito mockito-all 1.8.4 test + + org.springframework.integration + spring-integration-stream + 2.1.0.BUILD-SNAPSHOT + runtime + log4j log4j diff --git a/spring-integration-jdbc/pom.xml b/spring-integration-jdbc/pom.xml index 9fc8952551..caa737a5cd 100644 --- a/spring-integration-jdbc/pom.xml +++ b/spring-integration-jdbc/pom.xml @@ -140,18 +140,18 @@ 2.2 test - - org.springframework.integration - spring-integration-test - 2.1.0.BUILD-SNAPSHOT - test - com.h2database h2 1.2.125 test + + org.springframework.integration + spring-integration-core + 2.1.0.BUILD-SNAPSHOT + compile + org.easymock easymock @@ -160,9 +160,9 @@ org.springframework.integration - spring-integration-core + spring-integration-test 2.1.0.BUILD-SNAPSHOT - compile + test org.springframework diff --git a/spring-integration-jmx/pom.xml b/spring-integration-jmx/pom.xml index 4672150566..ecafc1e209 100644 --- a/spring-integration-jmx/pom.xml +++ b/spring-integration-jmx/pom.xml @@ -130,18 +130,18 @@ 2.1.0.BUILD-SNAPSHOT test - - org.easymock - easymock - 2.3 - test - org.springframework.integration spring-integration-core 2.1.0.BUILD-SNAPSHOT compile + + org.easymock + easymock + 2.3 + test + org.easymock easymockclassextension diff --git a/spring-integration-mail/pom.xml b/spring-integration-mail/pom.xml index 9ffcdb7e5d..95991f53f4 100644 --- a/spring-integration-mail/pom.xml +++ b/spring-integration-mail/pom.xml @@ -118,18 +118,18 @@ 2.1.0.BUILD-SNAPSHOT test - - org.easymock - easymock - 2.3 - test - org.springframework.integration spring-integration-core 2.1.0.BUILD-SNAPSHOT compile + + org.easymock + easymock + 2.3 + test + org.easymock easymockclassextension diff --git a/spring-integration-mongodb/pom.xml b/spring-integration-mongodb/pom.xml index ebe7df24cf..54a9c9c579 100644 --- a/spring-integration-mongodb/pom.xml +++ b/spring-integration-mongodb/pom.xml @@ -136,18 +136,18 @@ 2.1.0.BUILD-SNAPSHOT test - - org.easymock - easymock - 2.3 - test - org.springframework.integration spring-integration-core 2.1.0.BUILD-SNAPSHOT compile + + org.easymock + easymock + 2.3 + test + org.easymock easymockclassextension diff --git a/spring-integration-redis/pom.xml b/spring-integration-redis/pom.xml index 041babd6c2..d159420436 100644 --- a/spring-integration-redis/pom.xml +++ b/spring-integration-redis/pom.xml @@ -105,12 +105,32 @@ spring-data-commons-core 1.2.0.BUILD-SNAPSHOT compile + + + spring-tx + org.springframework + + + spring-beans + org.springframework + + org.springframework.data spring-data-redis 1.0.0.BUILD-SNAPSHOT compile + + + spring-tx + org.springframework + + + spring-beans + org.springframework + + org.springframework @@ -119,10 +139,10 @@ compile - cglib - cglib-nodep - 2.2 - test + org.springframework + spring-dao + 2.0.3 + compile log4j @@ -130,6 +150,18 @@ 1.2.12 test + + org.codehaus.jackson + jackson-core-asl + 1.8.3 + compile + + + cglib + cglib-nodep + 2.2 + test + org.springframework.integration spring-integration-test @@ -160,6 +192,12 @@ 3.1.0.M2 test + + org.codehaus.jackson + jackson-mapper-asl + 1.8.3 + compile + org.hamcrest hamcrest-all diff --git a/spring-integration-redis/src/main/java/org/springframework/integration/redis/store/RedisMessageStore.java b/spring-integration-redis/src/main/java/org/springframework/integration/redis/store/RedisMessageStore.java new file mode 100644 index 0000000000..19fc9e51ad --- /dev/null +++ b/spring-integration-redis/src/main/java/org/springframework/integration/redis/store/RedisMessageStore.java @@ -0,0 +1,80 @@ +/* + * Copyright 2007-2011 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.integration.redis.store; + +import java.util.UUID; + +import org.springframework.dao.DataAccessException; +import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.BoundValueOperations; +import org.springframework.data.redis.core.RedisCallback; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.JacksonJsonRedisSerializer; +import org.springframework.integration.Message; +import org.springframework.integration.store.MessageStore; + +/** + * @author Oleg Zhurakousky + * @since 2.1 + * + */ +public class RedisMessageStore implements MessageStore { + + private final RedisTemplate> redisTemplate; + + public RedisMessageStore(RedisConnectionFactory connectionFactory){ + this.redisTemplate = new RedisTemplate>(); + this.redisTemplate.setConnectionFactory(connectionFactory); + this.redisTemplate.setKeySerializer(new JacksonJsonRedisSerializer(UUID.class)); + } + + public Message getMessage(final UUID id) { + boolean exists = redisTemplate.execute(new RedisCallback() { + + public Boolean doInRedis(RedisConnection connection) + throws DataAccessException { + return connection.exists(id.toString().getBytes()); + } + }); + if (!exists){ + return null; + } + else { + BoundValueOperations> ops = redisTemplate.boundValueOps(id); + return ops.get(); + } + } + + + public Message addMessage(Message message) { + // TODO Auto-generated method stub + return null; + } + + + public Message removeMessage(UUID id) { + // TODO Auto-generated method stub + return null; + } + + + public int getMessageCount() { + // TODO Auto-generated method stub + return 0; + } + +} diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisMessageStoreTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisMessageStoreTests.java new file mode 100644 index 0000000000..21e9f2b75a --- /dev/null +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/store/RedisMessageStoreTests.java @@ -0,0 +1,44 @@ +/* + * Copyright 2007-2011 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.integration.redis.store; + +import java.util.UUID; + +import org.junit.Ignore; +import org.junit.Test; +import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; +import org.springframework.integration.Message; + +import static org.junit.Assert.assertNull; + +/** + * @author Oleg Zhurakousky + * + */ +public class RedisMessageStoreTests { + + @Test + @Ignore + public void testGetNonExistingMessage(){ + + JedisConnectionFactory jcf = new JedisConnectionFactory(); + jcf.setPort(6379); + jcf.afterPropertiesSet(); + RedisMessageStore store = new RedisMessageStore(jcf); + Message message = store.getMessage(UUID.randomUUID()); + assertNull(message); + } +} diff --git a/spring-integration-rmi/pom.xml b/spring-integration-rmi/pom.xml index 91a589b943..6e6ddd11ee 100644 --- a/spring-integration-rmi/pom.xml +++ b/spring-integration-rmi/pom.xml @@ -100,12 +100,6 @@ - - org.springframework.integration - spring-integration-test - 2.1.0.BUILD-SNAPSHOT - test - org.easymock easymock @@ -113,15 +107,21 @@ test - org.springframework - spring-aop - 3.1.0.M2 + org.springframework.integration + spring-integration-core + 2.1.0.BUILD-SNAPSHOT compile org.springframework.integration - spring-integration-core + spring-integration-test 2.1.0.BUILD-SNAPSHOT + test + + + org.springframework + spring-aop + 3.1.0.M2 compile diff --git a/spring-integration-scripting/pom.xml b/spring-integration-scripting/pom.xml index 0bd1ca9da2..04a6c65120 100644 --- a/spring-integration-scripting/pom.xml +++ b/spring-integration-scripting/pom.xml @@ -100,12 +100,6 @@ - - org.springframework.integration - spring-integration-test - 2.1.0.BUILD-SNAPSHOT - test - org.easymock easymock @@ -118,6 +112,12 @@ 2.1.0.BUILD-SNAPSHOT compile + + org.springframework.integration + spring-integration-test + 2.1.0.BUILD-SNAPSHOT + test + org.easymock easymockclassextension diff --git a/spring-integration-sftp/pom.xml b/spring-integration-sftp/pom.xml index a0179d4a33..8bb3e7bc63 100644 --- a/spring-integration-sftp/pom.xml +++ b/spring-integration-sftp/pom.xml @@ -106,6 +106,12 @@ 0.1.42 compile + + org.springframework.integration + spring-integration-stream + 2.1.0.BUILD-SNAPSHOT + compile + log4j log4j @@ -118,6 +124,12 @@ 2.2 test + + org.springframework.integration + spring-integration-file + 2.1.0.BUILD-SNAPSHOT + compile + org.springframework.integration spring-integration-test @@ -167,24 +179,12 @@ 1.1 test - - org.springframework.integration - spring-integration-stream - 2.1.0.BUILD-SNAPSHOT - compile - org.mockito mockito-all 1.8.4 test - - org.springframework.integration - spring-integration-file - 2.1.0.BUILD-SNAPSHOT - compile - junit junit-dep diff --git a/spring-integration-twitter/pom.xml b/spring-integration-twitter/pom.xml index a4eda82895..333c1d0f1a 100644 --- a/spring-integration-twitter/pom.xml +++ b/spring-integration-twitter/pom.xml @@ -124,18 +124,18 @@ 2.1.0.BUILD-SNAPSHOT test - - org.easymock - easymock - 2.3 - test - org.springframework.integration spring-integration-core 2.1.0.BUILD-SNAPSHOT compile + + org.easymock + easymock + 2.3 + test + org.easymock easymockclassextension diff --git a/spring-integration-xmpp/pom.xml b/spring-integration-xmpp/pom.xml index 9d9eec247a..0740d3a629 100644 --- a/spring-integration-xmpp/pom.xml +++ b/spring-integration-xmpp/pom.xml @@ -100,6 +100,12 @@ + + org.springframework.integration + spring-integration-stream + 2.1.0.BUILD-SNAPSHOT + test + cglib cglib-nodep @@ -173,12 +179,6 @@ 1.1 test - - org.springframework.integration - spring-integration-stream - 2.1.0.BUILD-SNAPSHOT - test - org.mockito mockito-all