简体   繁体   中英

sharing object in multiple run of spring integration flow

I want to share a variable or object, amongst spring integration components such that once the flow reaches splitter, after that the variable/object should be accessible for each splitted flow. Please suggest how can we do it??

The best way to do that in the Messaging stateless world is headers. So you should use a HeaderEnricher to store your object in the custom header before splitting. This way all the splitted items will get the same headers. But you should keep in mind if your object is mutable, any changes in any item process will affect all other items. Just because the object is the same.

https://docs.spring.io/spring-integration/docs/5.0.1.RELEASE/reference/html/messaging-transformation-chapter.html#header-enricher

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM