Weather Component
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.
Note: The component currently only supports consuming weather - though we will continue to research ways to influence the weather reliably
Maven users will need to add the following dependency to their pom.xml
for this component:
<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 format
weather://<unused name>[?options]
Options
Property |
Default |
Description |
---|---|---|
|
|
If null Camel will try and determine your current location using the geolocation of your ip address, else specify the city,country. For well known city names, Open Weather Map will determine the best fit, but multiple results may be returned. Hence specifying and country as well will return more accurate data. |
|
|
the units for temperature measurement. The possible values are |
|
|
If null, the current weather will be returned, else use values of 5, 7, 14 days. Only the numeric value for the forecast period is actually parsed, so spelling, capitalisation of the time period is up to you (its ignored) |
|
|
Delay in millis between each poll (default is 1 hour) |
|
|
Millis before polling starts. |
|
|
If |
You can append query options to the URI in the following format, ?option=value&option=value&...
Exchange data format
Camel will deliver the body as a json formatted java.lang.String
Message Headers
Header |
Description |
---|---|
|
The original query URL sent to the Open Weather Map site |
Samples
In this sample we find the 7 day weather forecast for Madrid, Spain:
from("weather:foo?location=Madrid,Spain&period=7 days").to("jms:queue:weather");
To just find the current weather for your current location you can use this:
from("weather:foo").to("jms:queue:weather");