What the hump is Apache Camel?
Camel is a Spring-based Integration Framework that implements routing and mediation rules using a Java-based Domain Specific Language (DSL or Fluent API), via a Spring-based XML configuration files or via Scala DSL.
The upcoming version 1.5 release includes a tutorial using Axis 1.4 with Camel. I used this example as a springboard to craft a document publisher to KnowledgeTree document management system via it's Axis-based web services.
The basic document publisher picks up an XML file, uploads it to KnowledgeTree using Apache HttpClient, and invokes KnowledgeTree's add_document webservice to include the file into the document repository. Here is the associated routing rule:
from("file:src/data?delete=true").process(ktDocUploader).to("file://target/test?noop=true");
Once the document-uploader function is implemented, the power and versatility of Camel as a routing and mediation framework comes into play. Camel supports a wide array of components allowing for more points of integration. In the above example, the File endpoint can easily be changed to FTP, SMTP, or JMS messaging without affecting the Processor code.
Route interceptors can be used to insert simple tasks like logging or complex ones like payload inspection for conditional application of logic.
intercept(xpath("/person[@user='rexjun']")).to("log:VIP").proceed();
A delivery failure is handled automatically by the Dead Letter Channel processor. I wanted failed deliveries to be deposited to another folder and this rule was implemented by a single line of code:
errorHandler(deadLetterChannel("file://target/errors"));
Aside from the Dead Letter Channel processor, Camel supports most of the Enterprise Integration Patterns and lends itself as a component of the Apache ServiceMix ESB project.