camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > GAE
Date Tue, 17 Nov 2009 05:25: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/GAE">GAE</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="GAE-CamelComponentsforGoogleAppEngine"></a>Camel Components
for Google App Engine</h2>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/check.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td><b>Tutorial</b><br
/><p>A good starting point for using Camel on GAE is the <a href="/confluence/display/CAMEL/Tutorial+for+Camel+on+Google+App+Engine"
title="Tutorial for Camel on Google App Engine">Tutorial for Camel on Google App Engine</a></p></td></tr></table></div>

<p>The Camel components for <a href="http://code.google.com/appengine/" rel="nofollow">Google
App Engine</a> (GAE) are part of the <tt>camel-gae</tt> project and provide
connectivity to GAE's <a href="http://code.google.com/appengine/docs/java/apis.html" rel="nofollow">cloud
computing services</a>. They make the GAE cloud computing environment accessible to
applications via Camel interfaces. Following this pattern for other cloud computing environments
could make it easier to port Camel applications from one cloud computing provider to another.
The following table lists the cloud computing services provided by Google App Engine and the
supporting Camel components. The documentation of each component can be found by following
the link in the <em>Camel Component</em> column.</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>GAE service</th>
<th class='confluenceTh'>Camel component</th>
<th class='confluenceTh'>Component description</th>
</tr>
<tr>
<td class='confluenceTd'><a href="http://code.google.com/appengine/docs/java/urlfetch/"
rel="nofollow">URL fetch service</a></td>
<td class='confluenceTd'><a href="/confluence/display/CAMEL/ghttp" title="ghttp">ghttp</a></td>
<td class='confluenceTd'>Provides connectivity to the GAE URL fetch service but can
also be used to receive messages from servlets.</td>
</tr>
<tr>
<td class='confluenceTd'><a href="http://code.google.com/appengine/docs/java/taskqueue/"
rel="nofollow">Task queueing service</a></td>
<td class='confluenceTd'><a href="/confluence/display/CAMEL/gtask" title="gtask">gtask</a></td>
<td class='confluenceTd'>Supports asynchronous message processing on GAE by using the
task queueing service as message queue.</td>
</tr>
<tr>
<td class='confluenceTd'><a href="http://code.google.com/appengine/docs/java/mail/"
rel="nofollow">Mail service</a></td>
<td class='confluenceTd'><a href="/confluence/display/CAMEL/gmail" title="gmail">gmail</a></td>
<td class='confluenceTd'>Supports sending of emails via the GAE mail service. Receiving
mails is not supported yet but will be added later.</td>
</tr>
<tr>
<td class='confluenceTd'><a href="http://code.google.com/appengine/docs/java/memcache/"
rel="nofollow">Memcache service</a></td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>Not supported yet.</td>
</tr>
<tr>
<td class='confluenceTd'><a href="http://code.google.com/appengine/docs/java/xmpp/"
rel="nofollow">XMPP service</a></td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>Not supported yet.</td>
</tr>
<tr>
<td class='confluenceTd'><a href="http://code.google.com/appengine/docs/java/images/"
rel="nofollow">Images service</a></td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>Not supported yet.</td>
</tr>
<tr>
<td class='confluenceTd'><a href="http://code.google.com/appengine/docs/java/datastore/"
rel="nofollow">Datastore service</a></td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>Not supported yet.</td>
</tr>
<tr>
<td class='confluenceTd'><a href="http://code.google.com/appengine/docs/java/users/"
rel="nofollow">Authentication service</a></td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'>Not supported yet.</td>
</tr>
</tbody></table>

<h3><a name="GAE-Camelcontext"></a>Camel context</h3>

<p>Usage of the <tt>CamelContext</tt> implementations <tt>org.apache.camel.impl.DefaultCamelContext</tt>
and <tt>org.apache.camel.spring.SpringCamelContext</tt> on GAE is not possible
out of the box. JMX must be disabled because the <tt>javax.management</tt> package
is not part of the GAE JRE. Usage of the Camel-specific Spring configuration XML schema from
the <tt><a href="http://camel.apache.org/schema/spring" rel="nofollow">http://camel.apache.org/schema/spring</a></tt>
namespace doesn't work either. Camel uses a JAXB-dependent bean definition parser but JAXB
is (currently) not supported by GAE. To work around these restrictions <tt>camel-gae</tt>
provides the following <tt>CamelContext</tt> implementations.</p>

<ul>
	<li><tt>org.apache.camel.component.gae.context.GaeDefaultCamelContext</tt>
(extends <tt>org.apache.camel.impl.DefaultCamelContext</tt>)</li>
	<li><tt>org.apache.camel.component.gae.context.GaeSpringCamelContext</tt>
(extends <tt>org.apache.camel.spring.SpringCamelContext</tt>)</li>
</ul>


<p>Both disable JMX before startup. The <tt>GaeSpringCamelContext</tt> additionally
provides setter methods adding route builders as shown in the next example.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>appctx.xml</b></div><div class="codeContent
panelContent">
<pre class="code-xml">
&lt;beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
       <span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
       xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&gt;
    
    &lt;bean id=<span class="code-quote">"camelContext"</span> 
        class=<span class="code-quote">"org.apache.camel.component.gae.context.GaeSpringCamelContext"</span>&gt;
        <span class="code-tag">&lt;property name=<span class="code-quote">"routeBuilder"</span>
ref=<span class="code-quote">"myRouteBuilder"</span> /&gt;</span>
    <span class="code-tag">&lt;/bean&gt;</span>
    
    &lt;bean id=<span class="code-quote">"myRouteBuilder"</span>
        class=<span class="code-quote">"org.example.MyRouteBuilder"</span>&gt;
    <span class="code-tag">&lt;/bean&gt;</span>
    
<span class="code-tag">&lt;/beans&gt;</span>
</pre>
</div></div> 

<p>Alternatively, use the <tt>routeBuilders</tt> property of the <tt>GaeSpringCamelContext</tt>
for setting a list of route builders.</p>

<p><a name="GAE-webxml"></a></p>
<h3><a name="GAE-Theweb.xml"></a>The web.xml</h3>

<p>Running Camel on GAE requires usage of the <tt>CamelHttpTransportServlet</tt>
from <tt>camel-servlet</tt>. The following example shows how to configure this
servlet together with a Spring application context XML file. </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">
&lt;web-app 
xmlns=<span class="code-quote">"http://java.sun.com/xml/ns/javaee"</span>
<span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
<span class="code-keyword">xmlns:web</span>=<span class="code-quote">"http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"</span>
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd<span class="code-quote">" version="</span>2.5"&gt;
    
    <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;init-param&gt;</span>
            <span class="code-tag">&lt;param-name&gt;</span>contextConfigLocation<span
class="code-tag">&lt;/param-name&gt;</span>
            <span class="code-tag">&lt;param-value&gt;</span>appctx.xml<span
class="code-tag">&lt;/param-value&gt;</span>
        <span class="code-tag">&lt;/init-param&gt;</span>
    <span class="code-tag">&lt;/servlet&gt;</span>

    &lt;!--
        Mapping used for external requests
     --&gt;
    <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>/camel/*<span
class="code-tag">&lt;/url-pattern&gt;</span>
    <span class="code-tag">&lt;/servlet-mapping&gt;</span>
    
    &lt;!--
        Mapping used for web hooks accessed by task queueing service.
     --&gt;
    <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>

<span class="code-tag">&lt;/web-app&gt;</span>
</pre>
</div></div>

<p>The location of the Spring application context XML file is given by the <tt>contextConfigLocation</tt>
init parameter. The <tt>appctx.xml</tt> file must be on the classpath. The servlet
mapping makes the Camel application accessible under <tt>http://&lt;appname&gt;.appspot.com/camel/...</tt>
when deployed to Google App Engine where <tt>&lt;appname&gt;</tt> must
be replaced by a real GAE application name. The second servlet mapping is used internally
by the task queueing service for background processing via <a href="http://www.webhooks.org/"
rel="nofollow">web hooks</a>. This mapping is relevant for the <a href="/confluence/display/CAMEL/gtask"
title="gtask">gtask</a> component and is explained there in more detail. </p>


     </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/GAE">View Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=5965065&revisedVersion=3&originalVersion=2">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CAMEL/GAE?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message