diff --git a/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisStoreMessageSource.java b/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisStoreMessageSource.java index 0aade29bac..d0c0bec1ad 100644 --- a/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisStoreMessageSource.java +++ b/spring-integration-redis/src/main/java/org/springframework/integration/redis/inbound/RedisStoreMessageSource.java @@ -32,9 +32,7 @@ import org.springframework.integration.Message; import org.springframework.integration.context.IntegrationObjectSupport; import org.springframework.integration.core.MessageSource; import org.springframework.integration.support.MessageBuilder; -import org.springframework.integration.transaction.MessageSourceResourceHolder; import org.springframework.integration.util.ExpressionUtils; -import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.util.Assert; /** * Inbound channel adapter which returns a Message representing a view into @@ -152,12 +150,6 @@ public class RedisStoreMessageSource extends IntegrationObjectSupport RedisStore store = this.createStoreView(key); - Object holder = TransactionSynchronizationManager.getResource(this); - if (holder != null) { - Assert.isInstanceOf(MessageSourceResourceHolder.class, holder); - ((MessageSourceResourceHolder) holder).addAttribute("store", store); - } - if (store instanceof Collection && ((Collection)store).size() < 1){ return null; } diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/zset-inbound-adapter.xml b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/zset-inbound-adapter.xml index f410d05033..5b2e28e8a4 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/zset-inbound-adapter.xml +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/zset-inbound-adapter.xml @@ -46,7 +46,7 @@ - + diff --git a/src/reference/docbook/mongodb.xml b/src/reference/docbook/mongodb.xml index 61e324686b..3f8855fd01 100644 --- a/src/reference/docbook/mongodb.xml +++ b/src/reference/docbook/mongodb.xml @@ -204,7 +204,7 @@ This element can reference a real transaction manager (for example if some other part of your flow invokes JDBC). If you don't have a 'real' transaction, you can use a org.springframework.integration.transaction.PseudoTransactionManager which is an implementation - of the Spring's PlatformTransactionManager and enables the use of the transaction synchronization + of Spring's PlatformTransactionManager and enables the use of the transaction synchronization features of the mongo adapter when there is no actual transaction. @@ -244,7 +244,7 @@ As you can see from the configuration above, you configure a MongoDb Outbound Channel Adapter using - the outbound-channel-adapter element while also providing values for various attributes such as: + the outbound-channel-adapter element, providing values for various attributes such as: collection-name or collection-name-expression - diff --git a/src/reference/docbook/redis.xml b/src/reference/docbook/redis.xml index 8022ef84a7..8d75c6b3ab 100644 --- a/src/reference/docbook/redis.xml +++ b/src/reference/docbook/redis.xml @@ -220,5 +220,192 @@ rt.setConnectionFactory(redisConnectionFactory);]]> the valueSerializer property of the RedisMessageStore. + +
+ RedisStore Inbound Channel Adapter + + + The RedisStore Inbound Channel Adapter is a polling consumer that reads data + from a Redis collection and sends it as a Message payload. + + + + +]]> + + + As you can see from the configuration above you configure a Redis Store Inbound Channel Adapter using + the store-inbound-channel-adapter element, providing values for various attributes such as: + + + key or key-expression - The name of the key for the collection being used. + + + collection-type - enumeration of the Collection types supported by this adapter. Supported Collections are: LIST, SET, ZSET, PROPERTIES, MAP + + + key-serializer - reference to an instance of org.springframework.data.redis.serializer.RedisSerializer + to be used while serializing keys + + + value-serializer - reference to an instance of org.springframework.data.redis.serializer.RedisSerializer + to be used while serializing values + + + hash-key-serializer - reference to an instance of org.springframework.data.redis.serializer.RedisSerializer + to be used while serializing hash keys + + + hash-value-serializer - reference to an instance of org.springframework.data.redis.serializer.RedisSerializer + to be used while serializing hash values + + + connection-factory - + reference to an instance of org.springframework.data.redis.connection.RedisConnectionFactory + + + redis-template - + reference to an instance of org.springframework.data.redis.core.RedisTemplate + + + + and other attributes that are common across all other inbound adapters (e.g., 'channel'). + + + You cannot set both redis-template and connection-factory. + + + The example above is relatively simple and static since it has a literal value for the key. + Sometimes, you may need to change the value of the key at runtime based on some condition. + To do that, simply use key-expression instead, where the provided expression can be any valid SpEL expression. + + + Also, you may wish to perform some post-processing to the successfully processed data that was read from the Redis collection. + For example; you may want to move or remove the value after its been processed. + You can do this using the Transaction Synchronization feature that was added with Spring Integration 2.2. + + + + + + + + + + + +]]> + + + + As you can see from the above all, you need to do is declare your poller to be transactional with a transactional element. + This element can reference a real transaction manager (for example if some other part of your flow invokes JDBC). + If you don't have a 'real' transaction, you can use a + org.springframework.integration.transaction.PseudoTransactionManager which is an implementation + of Spring's PlatformTransactionManager and enables the use of the transaction synchronization + features of the redis adapter when there is no actual transaction. + + + This does NOT make the Redis activities themselves transactional, it simply allows the synchronization of actions to be taken before/after success (commit) + or after failure (rollback). + + + Once your poller is transactional all you need to do is set an instance of the + org.springframework.integration.transaction.TransactionSynchronizationFactory on the transactional element. + TransactionSynchronizationFactory will create an instance of the TransactionSynchronization. + For your convenience we've exposed a default SpEL-based TransactionSynchronizationFactory which allows + you to configure SpEL expressions, with their execution being coordinated (synchronized) with a transaction. + Expressions for before-commit, after-commit, and after-rollback are supported, together with a channel for each where the + evaluation result (if any) will be sent. For each sub-element you can specify expression and/or channel + attributes. If only the channel attribute is present the received Message will be sent there as part of the particular + synchronization scenario. If only the expression attribute is present and the result of an expression is a non-Null + value, a Message with the result as the payload will be generated and sent to a default channel (NullChannel) and will appear in the + logs (DEBUG). If you want the evaluation result to go to a specific channel add a channel attribute. If the result of an + expression is null or void, no Message will be generated. + + + For more information about transaction synchronization, see . + +
+ +
+ RedisStore Outbound Channel Adapter + + + The RedisStore Outbound Channel Adapter allows you to write a Message payload to a Redis collection + + + ]]> + + + As you can see from the configuration above, you configure a Redis Store Outbound Channel Adapter using + the store-inbound-channel-adapter element, providing values for various attributes such as: + + + key or key-expression - The name of the key for the collection being used. + + + extract-payload-elements - If set to true (Default) and the payload is an instance of a "multi- + value" object (i.e., Collection or Map) it will be stored using addAll/ + putAll semantics. Otherwise, if set to false the payload will be stored + as a single entry regardless of its type. If the payload is not an instance + of a "multi-value" object, the value of this attribute is ignored and the + payload will always be stored as a single entry. + + + collection-type - enumeration of the Collection types supported by this adapter. Supported Collections are: LIST, SET, ZSET, PROPERTIES, MAP + + + key-serializer - reference to an instance of the org.springframework.data.redis.serializer.RedisSerializer + to be used while serializing keys + + + value-serializer - reference to an instance of the org.springframework.data.redis.serializer.RedisSerializer + to be used while serializing values + + + hash-key-serializer - reference to an instance of the org.springframework.data.redis.serializer.RedisSerializer + to be used while serializing hash keys + + + hash-value-serializer - reference to an instance of the org.springframework.data.redis.serializer.RedisSerializer + to be used while serializing hash values + + + map-key-expression - SpEL expression that returns the name of the key for entry being + stored. Only applies if the collection-type is MAP or PROPERTIES and + 'extract-payload-elements' is false. + + + connection-factory - + reference to an instance of org.springframework.data.redis.connection.RedisConnectionFactory + + + redis-template - + reference to an instance of org.springframework.data.redis.core.RedisTemplate + (NOTE: you can not have both redis-template and connection-factory set) + + + and other attributes that are common across all other inbound adapters (e.g., 'channel'). + + + The example above is relatively simple and static since it has a literal values for the key and other attributes. + Sometimes you may need to change the values dynamically at runtime based on some condition. + To do that simply use their -expression equivalents (key-expression, map-key-expression etc.) where + the provided expression can be any valid SpEL expression. + +
\ No newline at end of file