Reputation: 85
I have integration flow and I want to write the entity in the flow to my Gemfire cache between the steps but I am not figuring out how to do it.
@Bean
public IntegrationFlow myFlow(CacheEntityDAL cacheDAL,Transformer t,
MyFilter f) {
return IntegrationFlows.from("inChannel")
.transform(t) //returns the entity
//I want to put to my cacheDAL.put(entity) here
.filter(f)
.channel("outChannel")
.get();
}
Thanks
Upvotes: 1
Views: 130
Reputation: 121282
To write to the Gemfire cache, you need to use a CacheWritingMessageHandler
from the Spring Integration Gemfire support.
However since this one is one-way
, it is just for writing, there is no straight forward way to insert it in the middle of the flow. On the other you just would like to store and proceed downstream with the same payload. For this purpose I suggest to use a PublishSubscribeChannel
with two subscribers: a mentioned CacheWritingMessageHandler
and then rest of the flow. Something like this:
return IntegrationFlows.from("inChannel")
.transform(t) //returns the entity
.publishSubscribeChannel(c -> c
.subscribe(sf -> sf
.handle(new CacheWritingMessageHandler(gemfireRegion()))
.filter(f)
.channel("outChannel")
.get();
So, this way you send to the Gemfire and move to the main flow, where the next filter()
is going to be as a second subscriber which won't work until a success of the first one for Gemfire.
Upvotes: 1