3

I have a spring integration flow. It reads the file. The file can belong to the consumer.Once I find the consumer I want to add that CONSUMER to the header so later on I can use e.g. In error handling I can check that did I even get the consumer looking at the header.

IntegrationsFlows.from(directorySource)
.transform(new ConsumerFinderTransformer()
.enrichHeaders(h -> h.header("CONSUMER" ,payload)

How do I get the payload in the enrichHeaders that's returned by the ConsumerFinderTransformer here.

I cannot find a way. Any help will be appreacited

Makky
  • 17,117
  • 17
  • 63
  • 86

1 Answers1

3

This one is there for you:

    /**
 * 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) {

So, your code should be like:

.enrichHeaders(h -> h.headerExpression(“CONSUMER" , “payload”)
Artem Bilan
  • 113,505
  • 11
  • 91
  • 118