Community contributed extensions

Camel Module for Play! Framework

About this module

This module aim at integrating EIP pattern into the Play! Framework.

Components of this module

Installing module

play -> camel [version]

Getting dependencies

You need to make sure you are able to retreive all dependencies for this module, or it won’t work.

play deps --sync


Not much to configure, all required settings have defaults values.

List of properties user can override

broker.connectornone (ex.: tcp://localhost:61616)host:port that will be exposed by the ActiveMQ ConnectorOptional
broker.urlvm:localhostURL used for instanciating an embedded brokerOptional

Using @Inject

You can inject CamelContext into any class by using JSR-330:

private static CamelContext context

A good place is in a Bootstrap class, a class that extends Job and has the OnApplicationStart annotation:

public class Bootstrap extends Job {

Making your first Route

In the previous class in which you injected CamelContext, you can then use the Camel DSL which support:

RouteBuilder : Where it all begin...

I recommend you to read the architecture documentation if you need more than this basic example.

Here is a sample route you can test easily:

// Prepare the route
RouteBuilder routes = new RouteBuilder() {
	public void configure() throws Exception {
		from("file:///Users/marcus/tmp/INBOX").id("myInbox").log("Sending to JMS").to("activemq:testQueue");
		from("activemq:testQueue").id("myFakeEMail").log("Sending Email").to("log:myLogCategory?level=INFO&showBody=true");

The 1st route simply check for files in my INBOX directory, and then send the content to the testQueue JMS queue. The 2nd route listen for incoming messages, then send the content to a log category. The to part could have been a ftp, a smtp, or a bean (a processor in Camel terms...)

After the routes are created, you can then deploy them using the RouteBuilder class you created directly in CamelContext:

// Add them to camel-context


You now have a fully fonctionning EIP + an embedded JMS Broker right on your Play! application.

Have fun ;-), Marc