To deploy and run a Message-Driven Bean, perform the following steps:
Verify that a registry is running.
Start the Message-Oriented Middleware (the JMS provider implementation). See Section 9.4.1 Launching the Message-Oriented Middleware or Section 26.5.1 Accessing the Message-Oriented Middleware as a Service.
Create and register in JNDI the JMS destination object that will be used by the MDB.
This can be done automatically by the JMS service or explicitly by the proprietary administration facilities of the JMS provider (Section 26.4 JMS Administration). The JMS service creates the destination object if this destination is declared in the jonas.properties file (as specified in the previous section).
Deploy the MDB component in JOnAS.
Note that, if the destination object is not already created when deploying an MDB, the container asks the JMS service to create it based on the deployment descriptor content.
Run the EJB client application.
Stop the application.
When using JMS, it is very important to stop JOnAS using the jonas stop command; it should not be stopped directly by killing it.
If the configuration property jonas.services contains the jms service, then the JOnAS JMS service will be launched and may try to launch a JMS implementation (a MOM).
For launching the MOM, three possibilities can be considered:
Launching the MOM in the same JVM as JOnAS
This is the default situation obtained by assigning the true value to the configuration property jonas.service.jms.collocated in the jonas.properties file.
jonas.services security,jtm,dbm,jms,ejb // The jms service must be in the list jonas.service.jms.collocated true |
In this case, the MOM is automatically launched by the JOnAS JMS service at the JOnAS launching time (command jonas start).
Launching the MOM in a separate JVM
The JORAM MOM can be launched using the command:
JmsServer |
For other MOMs, the proprietary command should be used.
The configuration property jonas.service.jms.collocated must be set to false in the jonas.properties file. Setting this property is sufficient if the JORAM's JVM runs on the same host as JONAS, and if the MOM is launched with its default options (unchanged a3servers.xml configuration file under JONAS_BASE/conf or JONAS_ROOT/conf if JONAS_BASE is not defined).
jonas.services security,jtm,dbm,jms,ejb // The jms service must be in the list jonas.service.jms.collocated false |
To use a specific configuration for the MOM, such as changing the default host (which is localhost) or the default connection port number (which is 16010), requires defining the additional jonas.service.jms.url configuration property as presented in the following case.
Launching the MOM on another host
This requires defining the jonas.service.jms.url configuration property. When using JORAM, its value should be the JORAM URL joram://host:port where host is the host name, and port is the connection port (by default, 16010). For SwiftMQ, the value of the URL is similar to the following: smqp://host:4001/timeout=10000.
jonas.services security,jtm,dbm,jms,ejb // The jms service must be in the list jonas.service.jms.collocated false jonas.service.jms.url joram://host2:16010 |
As mentioned previously, the default host or default connection port number may need to be changed. This requires modifying the a3servers.xml configuration file provided by the JOnAS delivery in JONAS_ROOT/conf directory. For this, JOnAS must be configured with the property jonas.service.jms.collocated set to false, and the property jonas.service.jms.url set to joram://host:port. Additionally, the MOM must have been previously launched with the JmsServer command. This command defines a Transaction property set to fr.dyade.aaa.util.NullTransaction. If the messages need to be persistent, replace the -DTransaction=fr.dyade.aaa.util.NullTransaction option with the -DTransaction=fr.dyade.aaa.util.ATransaction option. Refer to the JORAM documentation for more details about this command. To define a more complex configuration (for example, distribution, multi-servers), refer to the JORAM documentation on http://joram.objectweb.org.