camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > Weather
Date Sun, 26 May 2013 20:19:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/Weather">Weather</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~muellerc">Christian
Mueller</a>
    </h4>
        <br/>
                         <h4>Changes (3)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{div:class=confluenceTableSmall} <br>||
Property || Default || Description || <br></td></tr>
            <tr><td class="diff-unchanged" >| {{location}} | {{null}} |  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. | <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">|
{{units}} | {{metric}} | the units for temperature measurement|  <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">|
{{units}} | {{metric}} | the units for temperature measurement. Valid values are:\\ <br>{{imperial}}\\
<br>{{metric}} |  <br></td></tr>
            <tr><td class="diff-unchanged" >| {{period}} | {{null}} | 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) |  <br>| {{consumer.delay}} | {{3600000}} | Delay in millis
between each poll (default is 1 hour) | <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >To just find the current weather for
your current location you can use this: <br>{code} <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">from(&quot;weather:foo&quot;).to(&quot;&quot;jms:queue:weather&quot;&quot;);</span>
<span class="diff-added-words"style="background-color: #dfd;">from(&quot;weather:foo&quot;).to(&quot;jms:queue:weather&quot;);</span>
<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="Weather-WeatherComponent"></a>Weather Component</h2>

<p>The <b>weather:</b> component is used for polling weather information
from <a href="http://openweathermap.org" class="external-link" rel="nofollow">Open Weather
Map</a> - a site that provides free global weather and forecast information. The information
is returned as a json String object.</p>

<p>Camel will poll for updates to the current weather and forecasts once per hour by
default.<br/>
<b>Note:</b> The component currently only supports consuming weather - though
we will continue to research ways to <a href="http://en.wikipedia.org/wiki/Rainmaking_(ritual)"
class="external-link" rel="nofollow">influence the weather reliably</a></p>

<p>Maven users will need to add the following dependency to their <tt>pom.xml</tt>
for this component:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;dependency&gt;</span>
    <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
    <span class="code-tag">&lt;artifactId&gt;</span>camel-weather<span
class="code-tag">&lt;/artifactId&gt;</span>
    <span class="code-tag">&lt;version&gt;</span>x.x.x<span class="code-tag">&lt;/version&gt;</span>
    <span class="code-tag"><span class="code-comment">&lt;!-- use the same
version as your Camel core version --&gt;</span></span>
<span class="code-tag">&lt;/dependency&gt;</span>
</pre>
</div></div>

<h3><a name="Weather-URIformat"></a>URI format</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
weather:<span class="code-comment">//&lt;unused name&gt;[?options]</span>
</pre>
</div></div>


<h3><a name="Weather-Options"></a>Options</h3>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Property </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>location</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'>  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. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>units</tt> </td>
<td class='confluenceTd'> <tt>metric</tt> </td>
<td class='confluenceTd'> the units for temperature measurement. Valid values are:<br
class="atl-forced-newline" />
<tt>imperial</tt><br class="atl-forced-newline" />
<tt>metric</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>period</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> 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) </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>consumer.delay</tt> </td>
<td class='confluenceTd'> <tt>3600000</tt> </td>
<td class='confluenceTd'> Delay in millis between each poll (default is 1 hour) </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>consumer.initialDelay</tt> </td>
<td class='confluenceTd'> <tt>1000</tt> </td>
<td class='confluenceTd'> Millis before polling starts. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>consumer.userFixedDelay</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> If <tt>true</tt>, use fixed delay between polls,
otherwise fixed rate is used. See <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html"
class="external-link" rel="nofollow">ScheduledExecutorService</a> in JDK for details.
</td>
</tr>
</tbody></table>
</div>
</div>

<p>You can append query options to the URI in the following format, <tt>?option=value&amp;option=value&amp;...</tt></p>

<h3><a name="Weather-Exchangedataformat"></a>Exchange data format</h3>

<p>Camel will deliver the body as a json formatted java.lang.String</p>


<h3><a name="Weather-MessageHeaders"></a>Message Headers</h3>
<p>Camel atom uses these headers.</p>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Header </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>query</tt> </td>
<td class='confluenceTd'> The original query URL sent to the Open Weather Map site </td>
</tr>
</tbody></table>
</div>
</div>

<h3><a name="Weather-Samples"></a>Samples</h3>
<p>In this sample we find the 7 day weather forecast for Madrid, Spain:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"weather:foo?location=Madrid,Spain&amp;period=7 days"</span>).to(<span
class="code-quote">"jms:queue:weather"</span>);
</pre>
</div></div>

<p>To just find the current weather for your current location you can use this:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
from(<span class="code-quote">"weather:foo"</span>).to(<span class="code-quote">"jms:queue:weather"</span>);
</pre>
</div></div>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Weather">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=31822906&revisedVersion=2&originalVersion=1">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Weather?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message