Since we're on a major migration process of this website, some component documents here are out of sync right now. In the meantime you may want to look at the early version of the new website
https://camel.apache.org/staging/
We would very much like to receive any feedback on the new site, please join the discussion on the Camel user mailing list.
Weather ComponentAvailable as of Camel 2.12 The weather: 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 <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-weather</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency> URI formatweather://<unused name>[?options] REMARKSince the 9th of October, an Api Key is required to access the openweather service. This key is passed as parameter to the URI definition of the weather endpoint using the appid param ! Options
You can append query options to the URI in the following format, Exchange data formatCamel will deliver the body as a json formatted java.lang.String (see the Message Headers
SamplesIn this sample we find the 7 day weather forecast for Madrid, Spain: from("weather:foo?location=Madrid,Spain&period=7 days&appid=APIKEY").to("jms:queue:weather"); To just find the current weather for your current location you can use this: from("weather:foo?appid=APIKEY").to("jms:queue:weather"); And to find the weather using the producer we do: from("direct:start") .to("weather:foo?location=Madrid,Spain&appid=APIKEY"); 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); |