【问题标题】:Enriching Header with the value from the Transformer使用 Transformer 中的值丰富 Header
【发布时间】:2019-04-20 23:21:44
【问题描述】:
我有一个spring integration flow. 它读取文件。该文件可以属于消费者。一旦我找到消费者,我想将 CONSUMER 添加到标题中,以便稍后我可以使用例如在错误处理中,我可以检查我是否得到了consumer 查看标题。
IntegrationsFlows.from(directorySource)
.transform(new ConsumerFinderTransformer()
.enrichHeaders(h -> h.header("CONSUMER" ,payload)
如何获取enrichHeaders 中由ConsumerFinderTransformer 返回的有效负载。
我找不到办法。任何帮助将不胜感激
【问题讨论】:
标签:
java-8
spring-integration
spring-integration-dsl
【解决方案1】:
这个是为你准备的:
/**
* Add a single header specification where the value is a String representation of a
* SpEL {@link Expression}. If the header exists, it will <b>not</b> be overwritten
* unless {@link #defaultOverwrite(boolean)} is true.
* @param name the header name.
* @param expression the expression.
* @return the header enricher spec.
*/
public HeaderEnricherSpec headerExpression(String name, String expression) {
所以,你的代码应该是这样的:
.enrichHeaders(h -> h.headerExpression(“CONSUMER" , “payload”)