Headerenricher Spring Integration and java dsl
I am using Spring Integration and java dsl specs to implement my IntegrationFlow. I want to use a custom header to add some filenames to the header, it would be something like:
public class FileHeaderNamingEnricher {
public Message<File> enrichHeader(Message<File> fileMessage) {
// getting some details fom the database ...
return messageBuilder
.setHeader("filename", "somestuff")
.build();
}
}
And my integration flow will look like this:
public IntegrationFlow myflow() {
return IntegrationFlows.from("input")
.enrich // here I want to enrich the header using my class
}
Can anyone help me with this?
source to share
You can expand FileHeaderNamingEnricher
AbstractReplyProducingMesageHandler
(put your code in handleRequestMessage()
).
Or implement GenericHandler<T>
(its method handle
receives payload and headers as parameters and can return a message).
Then use the method .handle
...
...
.handle(myEnricher())
...
@Bean
public void MessageHandler myEnricher() {
return new FileHeaderNamingEnricher();
}
source to share