This docs is for v0.2+
- Start from v0.2, it is not longer a mandatory to provide a JMS ConnectionFactory. For a single JVM simple usage, you may use the default in-memory, non-persistent ActiveMQ connection factory, or you could configure your JMSProvider in several ways.
- Execution Context
- GroovyJMS mainly provide an execution context that you can use enhanced JMS API and convenient methods, and access to implicit variables
- GroovyJMS is based on JMS and preserve any JMS concepts and keywords. You could mix the usage of GroovyJMS API and JMS API.
- At the highest level, there are JMS ConnectionFactory, Connection and Session. You could create any of them outside the execution context and pass to the constructor of GroovyJMS, or you could use the implicitly created instances.
- Refer to the next section about JMS ConnectionFactory
- Inside the execution context, you could get a copy of the thread-scope connection and session instance. But you cannot set a new connection or session.
JMS Connection Factory
To use GroovyJMS, you need to decide which JMS implementation you'll use. There are several options:
- use the default in-memory, not-persistent ActiveMQ broker and connection factory, this is created by the ActiveMQJMSProvider class. Notice that the ActiveMQJMSProvider will start a ActiveMQ broker if it is not existed already, and will add a "vm://localhost" transport connector URL if not existed. In this case, the syntax is as simple as:
- Provide a JMSProvider by
- specific a "groovy.jms.provider" system property that point to a class that implements groovy.jms.provider.JMSProvider
- set a JMSProvider to the JMS.provider static variable, e.g.
- Provide Connection Factory or Connection in runtime. it is the most recommended approach. You may utilize your JEE container or dependency injection framework to inject the required JMS resources to your class, and support the connection or factory to GroovyJMS.
Unsupported Features or Limitation
- nested usage is not supported yet. you may still use the lib in nested manner but you have manage the Connection and Session carefully.
- For example:
- you are recommended to avoid nestled usage. If you use it, try to use a multiple connection.