简体   繁体   English

在多次运行的 spring 集成流中共享对象

[英]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.我想在 spring 集成组件之间共享一个变量或对象,这样一旦流到达拆分器,之后每个拆分的流都应该可以访问变量/对象。 Please suggest how can we do it??请建议我们怎么做?

The best way to do that in the Messaging stateless world is headers.在 Messaging 无状态世界中做到这一点的最佳方式是标头。 So you should use a HeaderEnricher to store your object in the custom header before splitting.因此,您应该在拆分之前使用HeaderEnricher将您的对象存储在自定义标头中。 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 https://docs.spring.io/spring-integration/docs/5.0.1.RELEASE/reference/html/messaging-transformation-chapter.html#header-enricher

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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