Plugins You can find out about all the publicly available Grails plugins.

Apache Camel Plugin

  • Authors: Chris Navta
5 votes
compile "org.grails.plugins:camel:0.2"




grails install-plugin camel


This plugin has been superseded by the Grails Routing Plugin


The Apache Camel Grails plug-in allows you to send and route messages to a wide variety of destination endpoints directly from your Controllers and Services. It also provides a new Grails artifact, Routes, to configure your routes using know Enterprise Integration Patterns via the Apache Camel Java DSL.

Creating Routes

To create a new route, use the ‘grails create-route’ command:

grails create-route MyMessage

This will create a route in your ‘grails-app/routes’ directory:

class MyMessageRoute {
	def configure = {

In the configure closure you have full access to the Camel Java DSL to configure your message routes.

Route Configuration

Simple Example

To create a route from an in-memory queue called “my.queue” to stdout, use:


This would print out any Object sent to “seda:my.queue” to the console.

Slightly More Complex Example

Suppose you wanted to send messages asynchronously to the following Grails Service:

class MyService {
	def myMethod(fooBarText) { “Got text: ${ fooBarText }”

Using Camel’s bean integration, we can deliver messages directly to any Grails Service:

from(“seda:my.queue”).filter {“FooBar”)

This would deliver any message with the text “FooBar” in the body to the myMethod method of the myService service.

This example also illustrates one of the routing enhancements the plug-in offers. You can pass a Closure to the “filter”, “when” and “process” DSL methods.

Sending Messages

The plug-in provides a new method, ‘sendMessage’, to all Controllers and Services for sending messages to endpoints. It accepts a String endpoint and an Object message:

def myMessage = [name:”foo”,data:”bar”]

This would send the Map “myMessage” to an in-memory queue called “my.queue”.

Using Camel and ActiveMQ for JMS Messaging

Camel is a very easy way to integrate JMS messaging into your application. Just set up the ActiveMQ Component in your grails-app/conf/spring/resources.groovy:

beans = {
	activemq(org.apache.activemq.camel.component.ActiveMQComponent) {
		brokerURL = 'vm://MyBroker'

Had to download: activemq-all-5.2.0.jar activemq-pool-5.2.0.jar

This will create an in-vm broker and configure the "activemq" uri:


By default the component will create Queues from the uri. To create a Topic, add 'topic' to the URI:


Camel has rich support for JMS and ActiveMQ. To learn more about what options are available, check out the Camel documentation on the ActiveMQ and JMS Components.

Camel Components

Apache Camel has a wide variety of built-in Components for message delivery, such as JMS, SMTP, Web Services and Jabber. Take a look at the Apache Camel documentation for a comprehensive list.