Reputation: 13585
I am writing a utility to record user's HTTP request. Using Camel's File Component to achieve it.
Write now because of the override default value File component is writing new file for each HTTPRequest.
I can change it to Append
but wouldn't it give me single file for all the user sessions?
I want separate files for each user session. But request will appended for same user.
Route is like:
<route>
<from uri="seda:saveRequestMessageForTesting"/>
<log message="Request Message is ${body}"/>
<to uri="file://src?fileName=req.txt?fileExist=Append"/>
</route>
Upvotes: 0
Views: 1265
Reputation: 55555
You can either
1) Set a header with the file name to write, which would take precedence over the configured file name you have with req.txt. You would need to set this header before you reach the with the file.
For example we can call a method on a bean to compute the file name:
<setHeader headerName="CamelFileName">
<method ref="myBean" method="myMethod"/>
</setHeader>
Or use a Camel processor, where you set the header on the Exchange IN message.
<process ref="myProcessor"/>
2) Use the dynamic recipient list eip where you compute the endpoint dynamically. See this FAQ: http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html
Upvotes: 2