Grails ActiveMQ Plugin

  • Tags : messaging, jms, activemq
  • Latest : 0.4.1
  • Last Updated: 19 June 2012
  • Grails version : 1.2 > *
3 votes
Dependency :
compile ":activemq:0.4.1"
Custom repositories :
mavenRepo "http://download.java.net/maven/2/"
mavenRepo "http://repository.jboss.org/nexus/content/groups/public-jboss/"

Documentation Source Issues

Summary

Plugin to integrate ActiveMQ in a Grails application.

Description

ActiveMQ Plugin

grails-activemq is a plugin to embedded in a Grails application ActiveMQ for messaging. This release is very simple, in futures releases we provide mayor support for ActiveMQ advanced configuration.

This plugin can be used in conjuntion with jms plugin to develop MDP (Message Driven Pogos).

This plugin at the moment is not production ready. Use at your risk for rapid prototyping with JMS without installing anymore.

Code

Plugin code is located at GitHub: http://github.com/domix/grails-activemq If you wish to contribute, feel free to get a GitHub Account, fork the code, do your hacks and pull request.

Authors

  • Domingo Suarez Torres

Installation

grails install-plugin activemq

Recomended aditional configuration:

grails install-plugin jms

Configuration

Out of the box the plugin is fully configured to run in the local Grails application VM at port 61616, but you can configure the port in your Config.groovy like this:

grails.plugins.activemq.port=7892

The JMX monitoring is disabled by default, but you can enable JMX monitoring with this config

grails.plugins.activemq.useJmx=true/false

And you can configure the messaging persistence, the persistence is disabled by default.

grails.plugins.activemq.persistent=true/false

Out of the box Spring Beans

  • jmsBroker: ActiveMQ itself
  • connectionFactory: a Connection Factory to JMS Broker
  • defaultJmsTemplate: the Spring Template to send and receive messages

Mini Tutorial

Follow this simple steps:

  • grails create-app demoActiveMQ
  • cd demoActiveMQ
  • grails install-plugin activemq
  • grails install-plugin jms
  • grails create-controller notification
  • Edit NotificationController to this:
class NotificationController {
	def index = {
		def message = "Hi, this is a Hello World with JMS & ActiveMQ, " + new Date()
		sendJMSMessage("queue.notification", message)
		render message
	}
}
  • grails create-service onNotification
  • Edit OnNotificationService to this:
class OnNotificationService {
	boolean transactional = false
	static exposes = ['jms']
	static destination = "queue.notification"

def onMessage(it){ println "GOT MESSAGE: $it" } }

  • grails run-app
  • Browse to: http://localhost:8080/demoActiveMQ/notification
  • See result on console.