9.4. Running a Message-Driven Bean

To deploy and run a Message-Driven Bean, perform the following steps:

9.4.1. Launching the Message-Oriented Middleware

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:

  1. 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).

  2. 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.

  3. 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

9.4.1.1. Change the JORAM default configuration

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.