Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enriching Header with the value from the Transformer

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

like image 411
Makky Avatar asked Dec 17 '25 17:12

Makky


1 Answers

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”)
like image 163
Artem Bilan Avatar answered Dec 20 '25 09:12

Artem Bilan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!