How to read and delete int-redis:store-inbound-channel-adapter messages on each poll
Using this basic configuration :
<int-redis:store-inbound-channel-adapter id="listAdapter" connection-factory="redisConnectionFactory" key="messages" channel="redisChannel" collection-type="LIST" > <int:poller fixed-rate="2000" /> </int-redis:store-inbound-channel-adapter>
Messages that are read and put to redisChannel are also left in Redis. Is there a way to read and delete messages from Redis at the same time and put them to redisChannel, using this configuration? I can do it manually using scheduler and executing redis commands that I need, but that feels like hacking around spring integration.
<int-redis:store-inbound-channel-adapter> returns the RedisStore object. In your case it is a List implementation. So, you can simple call remove() or clear() methods of List, when it is necesary for you. Another technique to use Transaction Synchronization Factory, but I'm not sure that it help you, as you may use a <splitter> after your <int-redis:store-inbound-channel-adapter>. However you should place that RedisStore to headers before splitter.
According to your last comment:
<int:service-activator input-channel="redisChannel"> <int-groovy:script> def data =  + payload payload.clear() data </int-groovy:script> </int:service-activator>
As far as our payload is a RedisStoreList we can simply copy it to another list, clear() it and return that new list. The clear() operation will be delegated to the Redis.