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, 19 Jan 2010 13:02: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 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/apis/accounts/docs/AuthForWebApps.html"
rel="nofollow">Authentication service</a></td>
<td class='confluenceTd'>gauth</td>
<td class='confluenceTd'>Provides access to the Google authentication services 
<ul>
	<li>Allow Camel client applications to login to Google App Engine services</li>
	<li>Allow Camel GAE applications to login to other Google services (e.g. calendar)</li>
</ul>
</td>
</tr>
</tbody></table>

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

<p>Setting up a <tt>SpringCamelContext</tt> on Google App Engine differs
between Camel 2.1 and Camel 2.2. The problem is that 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 requires JAXB and Camel 2.1 depends on a Google App Engine SDK version that doesn't
support JAXB yet.</p>

<ul>
	<li>Camel 2.1 depends on the Google App Engine SDK 1.2.6 which doesn't support JAXB.
Refer to the <a href="#GAE-Camel2.1">Camel 2.1</a> subsection for instructions
how to set up a <tt>SpringCamelContext</tt> with Camel 2.1 on GAE.</li>
	<li>Camel 2.2 depends on the Google App Engine SDK 1.2.8, the first version that introduces
support for JAXB. Refer to the <a href="#GAE-Camel2.2">Camel 2.2</a> subsection
for instructions how to set up a <tt>SpringCamelContext</tt> with Camel 2.2 on
GAE.</li>
</ul>


<p>With both versions, JMX must be disabled because the <tt>javax.management</tt>
package isn't on the App Engine JRE whitelist.</p>

<h4><a name="GAE-Camel2.1"></a>Camel 2.1</h4>

<p><tt>camel-gae</tt> 2.1 comes with 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. Using this approach, a <tt>SpringCamelContext</tt>
can be configured on GAE without the need for JAXB.</p>

<h4><a name="GAE-Camel2.2"></a>Camel 2.2</h4>

<p>With Camel 2.2, applications can use the <tt><a href="http://camel.apache.org/schema/spring"
rel="nofollow">http://camel.apache.org/schema/spring</a></tt> namespace for
configuring a <tt>SpringCamelContext</tt> but still need to disable JMX. Here's
an 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>
       <span class="code-keyword">xmlns:camel</span>=<span class="code-quote">"http://camel.apache.org/schema/spring"</span>
       xsi:schemaLocation="
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd"&gt;
    
    <span class="code-tag">&lt;camel:camelContext id=<span class="code-quote">"camelContext"</span>&gt;</span>
        <span class="code-tag">&lt;camel:jmxAgent id=<span class="code-quote">"agent"</span>
disabled=<span class="code-quote">"true"</span> /&gt;</span>
        <span class="code-tag">&lt;camel:routeBuilder ref=<span class="code-quote">"myRouteBuilder"</span>/&gt;</span>
    <span class="code-tag">&lt;/camel:camelContext&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><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>

<h3><a name="GAE-Security"></a>Security</h3>

<ul>
	<li>For instructions how to protect Camel applications on GAE refer to <a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=gsec&amp;linkCreation=true&amp;fromPageId=5965065"
class="createlink">Security for Camel GAE Applications</a> page.</li>
	<li>The gauth component provides access to the Google authentication services and can
also be used outside Google App Engine.</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/GAE">View Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=5965065&revisedVersion=5&originalVersion=4">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