This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • Tutorial for Camel on Google App Engine

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Open the camel-example-gae/src/main/webapp/WEB-INF/application-web.xml file and replace the template application name replaceme with the name of the application that you created in the previous section. Optionally, adjust the version number if needed.

Code Block
xml
xml
titleappengine-web.xmlxml
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
    <!-- 
        Set your application name and version here
     -->
    <application>replaceme</application>
    <version>1</version>
	
    <static-files>
        <exclude path="/index.html" />
    </static-files>

    <system-properties>
        <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
    </system-properties>
	
</appengine-web-app>

...

The TutorialRouteBuilder implements the message processing routes shown in the #Overview section. Input form data are received via the ghttp component. After receiving the request a RequestProcessor adds the form data and information about the current user to a ReportData POJO. The ReportData object is then serialized and queued for background processing. Queueing messages on GAE is done with the gtask component. After adding the ReportData object to the queue an HTML response is generated with the ResponseProcessor.

Code Block
java
java
titleTutorialRouteBuilder.javajava
package org.apache.camel.example.gae;

import org.w3c.dom.Document;

import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.gae.mail.GMailBinding;
import org.apache.camel.processor.aggregate.AggregationStrategy;

public class TutorialRouteBuilder extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        from("ghttp:///weather")
            .process(new RequestProcessor())
            .marshal().serialization()
            .to("gtask://default")
            .unmarshal().serialization()
            .process(new ResponseProcessor());
      
        from("gtask://default")
            .unmarshal().serialization()
            .setHeader(Exchange.HTTP_QUERY, constant("weather=").append(ReportData.city()))
            .enrich("ghttp://www.google.com/ig/api", reportDataAggregator())
            .setHeader(GMailBinding.GMAIL_SUBJECT, constant("Weather report"))
            .setHeader(GMailBinding.GMAIL_SENDER, ReportData.requestor())
            .setHeader(GMailBinding.GMAIL_TO, ReportData.recipient())
            .process(new ReportGenerator())        
            .to("gmail://default");
    }

    private static AggregationStrategy reportDataAggregator() {
        return new AggregationStrategy() {
            public Exchange aggregate(Exchange reportExchange, Exchange weatherExchange) {
                ReportData reportData = reportExchange.getIn().getBody(ReportData.class);
                reportData.setWeather(weatherExchange.getIn().getBody(Document.class));
                return reportExchange;
            }
        };
    }
    
}

...