|
Spring Integration | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.integration.context.IntegrationObjectSupport org.springframework.integration.handler.AbstractMessageHandler org.springframework.integration.redis.outbound.RedisCollectionPopulatingMessageHandler
public class RedisCollectionPopulatingMessageHandler
Implementation of MessageHandler
which writes Message data into a Redis store
identified by a key String
.
It supports the collection types identified by RedisCollectionFactoryBean.CollectionType
.
It also supports batch updates and single item entry.
"Batch updates" means that the payload of the Message may be a Map or Collection.
With such a payload, individual items from it are added to the corresponding Redis store.
See AbstractMessageHandler.handleMessage(Message)
for more details.
You can also choose to persist such a payload as a single item if the extractPayloadElements
property is set to false (default is true).
Field Summary |
---|
Fields inherited from interface org.springframework.core.Ordered |
---|
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE |
Constructor Summary | |
---|---|
RedisCollectionPopulatingMessageHandler(org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory)
Will construct this instance using the provided RedisConnectionFactory . |
|
RedisCollectionPopulatingMessageHandler(org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory,
org.springframework.expression.Expression keyExpression)
Will construct this instance using the provided RedisConnectionFactory and keyExpression
It will create an instance of RedisTemplate with default serializers unless those
are overridden via this instance's corresponding setters. |
|
RedisCollectionPopulatingMessageHandler(org.springframework.data.redis.core.RedisTemplate<java.lang.String,?> redisTemplate)
Will construct this instance using fully created and initialized instance of provided RedisTemplate
The default expression 'headers.RedisHeaders.KEY '
will be used. |
|
RedisCollectionPopulatingMessageHandler(org.springframework.data.redis.core.RedisTemplate<java.lang.String,?> redisTemplate,
org.springframework.expression.Expression keyExpression)
Will construct this instance using provided RedisTemplate and keyExpression . |
Method Summary | |
---|---|
java.lang.String |
getComponentType()
Subclasses may implement this method to provide component type information. |
protected void |
handleMessageInternal(Message<?> message)
Will extract payload from the Message storing it in the collection identified by the collectionType . |
protected void |
onInit()
Subclasses may implement this for initialization logic. |
void |
setCollectionType(org.springframework.data.redis.support.collections.RedisCollectionFactoryBean.CollectionType collectionType)
Sets the collection type for this handler as per RedisCollectionFactoryBean.CollectionType |
void |
setExtractPayloadElements(boolean extractPayloadElements)
Sets the flag signifying that if the payload is a "multivalue" (i.e., Collection or Map), it should be saved using addAll/putAll semantics. |
void |
setHashKeySerializer(org.springframework.data.redis.serializer.RedisSerializer<?> hashKeySerializer)
|
void |
setHashValueSerializer(org.springframework.data.redis.serializer.RedisSerializer<?> hashValueSerializer)
|
void |
setKeySerializer(org.springframework.data.redis.serializer.RedisSerializer<?> keySerializer)
|
void |
setMapKeyExpression(org.springframework.expression.Expression mapKeyExpression)
Sets the expression used as the key for Map and Properties entries. |
void |
setValueSerializer(org.springframework.data.redis.serializer.RedisSerializer<?> valueSerializer)
|
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler |
---|
getOrder, handleMessage, setOrder, setShouldTrack |
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport |
---|
afterPropertiesSet, getBeanFactory, getComponentName, getConversionService, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.springframework.integration.context.NamedComponent |
---|
getComponentName |
Constructor Detail |
---|
public RedisCollectionPopulatingMessageHandler(org.springframework.data.redis.core.RedisTemplate<java.lang.String,?> redisTemplate)
RedisTemplate
The default expression 'headers.RedisHeaders.KEY
'
will be used.
redisTemplate
- public RedisCollectionPopulatingMessageHandler(org.springframework.data.redis.core.RedisTemplate<java.lang.String,?> redisTemplate, org.springframework.expression.Expression keyExpression)
RedisTemplate
and keyExpression
. The RedisTemplate must
be fully initialized.
If keyExpression
is null, the default expression 'headers.RedisHeaders.KEY
'
will be used.
redisTemplate
- keyExpression
- public RedisCollectionPopulatingMessageHandler(org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory)
RedisConnectionFactory
.
It will create an instance of RedisTemplate
with default serializers unless those
are overridden via this instance's corresponding setters.
The default expression 'headers.RedisHeaders.KEY
'
will be used.
connectionFactory
- public RedisCollectionPopulatingMessageHandler(org.springframework.data.redis.connection.RedisConnectionFactory connectionFactory, org.springframework.expression.Expression keyExpression)
RedisConnectionFactory
and keyExpression
It will create an instance of RedisTemplate
with default serializers unless those
are overridden via this instance's corresponding setters.
If keyExpression
is null, the default expression 'headers.RedisHeaders.KEY
'
will be used.
connectionFactory
- keyExpression
- Method Detail |
---|
public void setKeySerializer(org.springframework.data.redis.serializer.RedisSerializer<?> keySerializer)
public void setValueSerializer(org.springframework.data.redis.serializer.RedisSerializer<?> valueSerializer)
public void setHashKeySerializer(org.springframework.data.redis.serializer.RedisSerializer<?> hashKeySerializer)
public void setHashValueSerializer(org.springframework.data.redis.serializer.RedisSerializer<?> hashValueSerializer)
public void setCollectionType(org.springframework.data.redis.support.collections.RedisCollectionFactoryBean.CollectionType collectionType)
RedisCollectionFactoryBean.CollectionType
collectionType
- public void setExtractPayloadElements(boolean extractPayloadElements)
extractPayloadElements
- setExtractPayloadElements(boolean)
public void setMapKeyExpression(org.springframework.expression.Expression mapKeyExpression)
RedisHeaders.MAP_KEY
'
mapKeyExpression
- public java.lang.String getComponentType()
IntegrationObjectSupport
getComponentType
in interface NamedComponent
getComponentType
in class AbstractMessageHandler
protected void onInit() throws java.lang.Exception
IntegrationObjectSupport
onInit
in class IntegrationObjectSupport
java.lang.Exception
protected void handleMessageInternal(Message<?> message) throws java.lang.Exception
collectionType
. The default CollectinType is LIST.
The rules for storing payload are:
LIST/SET
If payload is of type Collection and extractPayloadElements
is 'true' (default),
the payload will be added using the addAll() method. If extractPayloadElements
is set to 'false' then,
regardless of the payload type, the payload will be added using add();
ZSET
In addition to rules described for LIST/SET, ZSET allows 'score' information
to be provided. The score can be provided using the RedisHeaders.ZSET_SCORE
message header,
when the payload is a Collection, or
by sending a Map as the payload, where the Map 'key' is the value to be saved and the 'value' is
the score assigned to this value.
If extractPayloadElements
is set to 'false' the map will be stored as a single entry.
If the 'score' can not be determined, the default value (1) will be used.
MAP/PROPERTIES
You can also store a payload of type Map or Properties following the same rules as above.
If payload itself needs to be stored as a value of the map/property then the map key must be
specified via the mapKeyExpression (default RedisHeaders.MAP_KEY
Message header).
handleMessageInternal
in class AbstractMessageHandler
java.lang.Exception
|
Spring Integration | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |