簡體   English   中英

如何在 Spring Integration DSL 中將對象放入 Gemfire Cache?

[英]How to put object to Gemfire Cache in Spring Integration DSL?

我有集成流程,我想在步驟之間將流程中的實體寫入我的 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

然而,由於這是one-way ,它只是為了寫作,沒有直接的方法將它插入流的中間。 另一方面,您只想使用相同的有效負載存儲和繼續下游。 為此,我建議使用具有兩個訂閱者的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 成功后才能工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM