Available as of Camel 2.12
component is used for polling weather information from Open Weather Map
- a site that provides free global weather and forecast information. The information is returned as a json String object.
Camel will poll for updates to the current weather and forecasts once per hour by default.
Maven users will need to add the following dependency to their
pom.xml for this component:
<!-- use the same version as your Camel core version -->
In this sample we find the 7 day weather forecast for Madrid, Spain:
To just find the current weather for your current location you can use this:
And to find the weather using the producer we do:
And we can send in a message with a header to get the weather for any location as shown:
String json = template.requestBodyAndHeader("direct:start", "", "CamelWeatherLocation", "Paris,France", String.class);
And to get the weather at the current location, then:
String json = template.requestBodyAndHeader("direct:start", "", "CamelWeatherLocation", "current", String.class);