camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > gtask
Date Sun, 04 Apr 2010 12:53:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/CAMEL/gtask">gtask</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~mrt1nz">Martin
Krasser</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <h2><a name="gtask-%7B%7Bgtask%7D%7DComponent"></a><tt>gtask</tt>
Component</h2>

<p>The <tt>gtask</tt> component contributes to the <a href="/confluence/display/CAMEL/GAE"
title="GAE">Camel Components for Google App Engine</a> (GAE). It supports asynchronous
message processing on GAE by using the <a href="http://code.google.com/appengine/docs/java/taskqueue/"
rel="nofollow">task queueing service</a> as message queue. For adding messages to
a queue it uses the task queue API. For receiving messages from a queue it installs an HTTP
callback handler. The handler is called by an HTTP POST callback (a <a href="http://www.webhooks.org/"
rel="nofollow">web hook</a>) initiated by the task queueing service. Whenever a new
task is added to a queue a callback will be sent. The <tt>gtask</tt> component
abstracts from these details and supports endpoint URIs that make message queueing on GAE
as easy as message queueing with <a href="/confluence/display/CAMEL/JMS" title="JMS">JMS</a>
or <a href="/confluence/display/CAMEL/SEDA" title="SEDA">SEDA</a>.</p>

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

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
gtask:<span class="code-comment">//queue-name</span>
</pre>
</div></div>

<h3><a name="gtask-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Context </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>workerRoot</tt> </td>
<td class='confluenceTd'> <tt>worker</tt> </td>
<td class='confluenceTd'> Producer </td>
<td class='confluenceTd'> The servlet mapping for callback handlers. By default, this
component requires a callback servlet mapping of <tt>/worker/&#42;</tt>. If
another servlet mapping is used e.g. <tt>/myworker/&#42;</tt> it must be set
as option on the producer side: <tt>to("gtask:myqueue?workerRoot=myworker")</tt>.</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>inboundBindingRef</tt> </td>
<td class='confluenceTd'> reference to <tt>GTaskBinding</tt> </td>
<td class='confluenceTd'> Consumer </td>
<td class='confluenceTd'>Reference to an <tt>InboundBinding&lt;GTaskEndpoint,
HttpServletRequest, HttpServletResponse&gt;</tt> in the <a href="/confluence/display/CAMEL/Registry"
title="Registry">Registry</a> for customizing the binding of an <tt>Exchange</tt>
to the Servlet API. The referenced binding is used as post-processor to <tt>org.apache.camel.component.http.HttpBinding</tt>.</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>outboundBindingRef</tt> </td>
<td class='confluenceTd'> reference to <tt>GTaskBinding</tt> </td>
<td class='confluenceTd'> Producer </td>
<td class='confluenceTd'>Reference to an <tt>OutboundBinding&lt;GTaskEndpoint,
TaskOptions, void&gt;</tt> in the <a href="/confluence/display/CAMEL/Registry"
title="Registry">Registry</a> for customizing the binding of an <tt>Exchange</tt>
to the task queueing service.</td>
</tr>
</tbody></table>

<p>On the consumer-side, all options of the <a href="/confluence/display/CAMEL/SERVLET"
title="SERVLET">Servlet component</a> are supported.</p>

<h3><a name="gtask-Messageheaders"></a>Message headers</h3>

<p>On the consumer-side all headers of the <a href="/confluence/display/CAMEL/SERVLET"
title="SERVLET">Servlet component</a> component are supported plus the following.</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Context </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>GTaskBinding.GTASK_QUEUE_NAME</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> Consumer </td>
<td class='confluenceTd'> Name of the task queue.</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>GTaskBinding.GTASK_TASK_NAME</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> Consumer </td>
<td class='confluenceTd'> Name of the task (generated value).</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>GTaskBinding.GTASK_RETRY_COUNT</tt> </td>
<td class='confluenceTd'> <tt>int</tt> </td>
<td class='confluenceTd'> Consumer </td>
<td class='confluenceTd'>  Number of callback retries.</td>
</tr>
</tbody></table>

<h3><a name="gtask-Messagebody"></a>Message body</h3>

<p>On the producer side the <tt>in</tt> message body is converted to a <tt>byte[]</tt>
and is POSTed to the callback handler as content-type <tt>application/octet-stream</tt>.</p>

<h3><a name="gtask-Usage"></a>Usage</h3>

<p>Setting up tasks queues is an administrative task on Google App Engine. Only one
queue is pre-configured and can be referenced by name out-of-the-box: the <tt>default</tt>
queue. This queue will be used in the following examples. Please note that when using task
queues on the local development server, tasks must be executed manually from the <a href="http://code.google.com/appengine/docs/java/taskqueue/overview.html#Task_Queues_and_the_Development_Server"
rel="nofollow">developer console</a>.</p>

<h4><a name="gtask-Defaultqueue"></a>Default queue </h4>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
...
.to(gtask:<span class="code-keyword">default</span>) <span class="code-comment">//
add message to <span class="code-keyword">default</span> queue
</span>
from(gtask:<span class="code-keyword">default</span>) <span class="code-comment">//
receive message from <span class="code-keyword">default</span> queue (via a web
hook)
</span>...
</pre>
</div></div>

<p>This example requires the following servlet mapping.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>web.xml</b></div><div class="codeContent
panelContent">
<pre class="code-xml">
    ...
    <span class="code-tag">&lt;servlet&gt;</span>
        <span class="code-tag">&lt;servlet-name&gt;</span>CamelServlet<span
class="code-tag">&lt;/servlet-name&gt;</span>
        <span class="code-tag">&lt;servlet-class&gt;</span>org.apache.camel.component.servlet.CamelHttpTransportServlet<span
class="code-tag">&lt;/servlet-class&gt;</span>
        ...
    <span class="code-tag">&lt;/servlet&gt;</span>
    ...
    <span class="code-tag">&lt;servlet-mapping&gt;</span>
        <span class="code-tag">&lt;servlet-name&gt;</span>CamelServlet<span
class="code-tag">&lt;/servlet-name&gt;</span>
        <span class="code-tag">&lt;url-pattern&gt;</span>/worker/*<span
class="code-tag">&lt;/url-pattern&gt;</span>
    <span class="code-tag">&lt;/servlet-mapping&gt;</span>
    ...
</pre>
</div></div>

<h3><a name="gtask-Dependencies"></a>Dependencies</h3>

<p>Maven users will need to add the following dependency to their <tt>pom.xml</tt>.
</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>pom.xml</b></div><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-gae<span
class="code-tag">&lt;/artifactId&gt;</span>
    <span class="code-tag">&lt;version&gt;</span>${camel-version}<span
class="code-tag">&lt;/version&gt;</span>
<span class="code-tag">&lt;/dependency&gt;</span>
</pre>
</div></div>

<p>where <tt>${camel-version</tt>} must be replaced by the actual version
of Camel (2.1.0 or higher).</p>

<h3><a name="gtask-SeeAlso"></a>See Also</h3>
<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting
Started</a></li>
</ul>

<ul class="alternate" type="square">
	<li><a href="/confluence/display/CAMEL/HTTP" title="HTTP">Http component</a></li>
	<li><a href="/confluence/display/CAMEL/SERVLET" title="SERVLET">Servlet component</a></li>
</ul>

     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/CAMEL/gtask">View Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=5965072&revisedVersion=4&originalVersion=3">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CAMEL/gtask?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message