It's a Groovy Categories that make it very easy to use JMS in Groovy application.
- You have to provide the JMS Factory, refer to the Spring ActiveMQ setup section on this page, or check the JMS setup examples in the Grails JMS Plugin page.
Let's start with some examples first:
Setup JMS Connection Factory
For every example, it's assumed a JMS Connection Factory called "jms" is existed. For example, you could create a ActiveMQ connection factory programmatically with:
- Subscribe to a Topic message
- Send a message to a Queue or Topic
- Receive a Queue message
The receive parameter means "receives the next message that arrives within the specified timeout interval", check JMS JavaDoc for details:
- Reply to a message
By default, it reuses JMS Connection and Session. The connection and session are created when any of connect(), session(), topic() or queue() method is first called, and the connection and session are binded to a internal ThreadLocal variables until close() is called.
How it works?
- It's current hardcoded to use Log4j. It could be changed or removed on request.