Is there an easy way to configure a Flow to read a single file from the classpath one time? I don\'t need to poll for a file. I just need to read a known file and set its co
For some reason I cannot make the solution proposed by David Dossot to work. I was inspired by this answer and came up with another solution
<spring:bean id="myResource" class="org.apache.commons.io.IOUtils" factory-method="toString">
<spring:constructor-arg value="classpath:path/to/myResource.txt" type="java.io.InputStream"/>
</spring:bean>
and then you can use set-payload in the following way
<set-payload value="#[app.registry.myResource]" doc:name="Set Payload"/>
which will result in setting the payload with the content of the file as a String.
This method has the advantage that the content of the resource file is loaded only once into a bean of type String. So if your set-payload statement is executed frequently, this could improve performance.
<parse-template location="my-resurce.txt" doc:name="Load resource as a String"/>
The file can perfectly contain no MEL expression whatsoever, in which case it's actually loaded as it is, and it becomes the payload.