作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有集成流程,我想在步骤之间将流程中的实体写入我的 Gemfire 缓存,但我不知道如何执行。
@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();
}
谢谢
最佳答案
要写入 Gemfire 缓存,您需要使用 Spring Integration Gemfire 中的 CacheWritingMessageHandler
支持。
但是,由于这是单向
,它仅用于写入,因此没有直接的方法将其插入到流程的中间。另一方面,您只想使用相同的有效负载存储并继续下游。为此,我建议使用具有两个订阅者的 PublishSubscribeChannel:提到的 CacheWritingMessageHandler 以及流程的其余部分。像这样的事情:
return IntegrationFlows.from("inChannel")
.transform(t) //returns the entity
.publishSubscribeChannel(c -> c
.subscribe(sf -> sf
.handle(new CacheWritingMessageHandler(gemfireRegion()))
.filter(f)
.channel("outChannel")
.get();
因此,您可以通过这种方式发送到 Gemfire 并移至主流程,其中下一个 filter()
将作为第二个订阅者,在 Gemfire 的第一个订阅者成功之前,该订阅者不会工作。
关于java - 如何在 Spring Integration DSL 中将对象放入 Gemfire 缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51875915/
我是一名优秀的程序员,十分优秀!