Reputation: 57
I am using java to get a json file through URL, in the web browser it works but from my java code:
//I have used also timer:foo?period=5000 but not working
from("direct:start")
.multicast()
.to("http://" + URL)
.to("file:" + path + "&fileName=report");
Even if it does not display errors, camel does not create the file "report".
Any sugestion?
Thank you in advance.
Upvotes: 2
Views: 1530
Reputation: 3870
Not sure I fully understand your goal, but it looks like you are trying to call a rest endpoint for a json response and then write that response to a file. In your example above camel is trying to write a file and call the http endpoint with the same message instead of getting a response from the http endpoint, then writing it to your report file. You can also update your timer to have the fixedRate property equal to true to keep calling.
You can do something like:
from("timer:foo?fixedRate=true&period=5000")
.to("http://" + URL)
.log("my response: ${body}")
.to("file:" + path + "&fileName=report");
Upvotes: 2