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. It can also be used to query the weather API based on the parameters defined on the endpoint which is used as producer.
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 -->
Since the 9th of October 2015, an API Key is required to access the OpenWeather service. This key is passed as a parameter to the URI definition of the weather endpoint, using the
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&appid=APIKEY", String.class);
And to get the weather at the current location, then:
String json = template.requestBodyAndHeader("direct:start", "", "CamelWeatherLocation", "current&appid=APIKEY", String.class);