Red Hat Application Server: JOnAS User Guide | ||
---|---|---|
Prev | Chapter 11. Transactional Behavior of EJB Applications | Next |
As explained in the previous section, the transactional behavior of an application can be defined in a declarative way or coded in the bean and/or the client itself (transaction boundaries demarcation). In any case, the distribution aspects of the transactions are completely transparent to the bean provider and to the application assembler. This means that a transaction may involve beans located on several JOnAS servers and that the platform itself will handle management of the global transaction. It will perform the two-phase commit protocol between the different servers, and the bean programmer need do nothing.
Once the beans have been developed and the application has been assembled, it is possible for the deployer and for the administrator to configure the distribution of the different beans on one or several machines, and within one or several JOnAS servers. This can be done without impacting either the beans' code or their deployment descriptors. The distributed configuration is specified at launch time. In the environment properties of an EJB server, the following can be specified:
Which Enterprise Beans the JOnAS server will handle
If a Java Transaction Monitor will be located in the same Java Virtual Machine (JVM) or not.
To achieve this goal, two properties must be set in the jonas.properties file, jonas.service.ejb.descriptors and jonas.service.jtm.remote. The first one lists the beans that will be handled on this server (by specifying the name of their EJB-JAR files), and the second one sets the Java Transaction Monitor (JTM) launching mode:
If set to true, the JTM is remote, that is, the JTM must be launched previously in another JVM
If set to false, the JTM is local, that is, it will run in the same JVM as the EJB Server.
Example:
jonas.service.ejb.descriptors Bean1.jar, Bean2.jar jonas.service.jtm.remote false |
The Java Transaction Monitor can run outside any EJB server, in which case it can be launched in a stand-alone mode using the following command:
TMServer |
Using these configuration facilities, it is possible to adapt the beans' distribution to the resources (CPU and data) location, for optimizing performance.
The following figure illustrates four cases of distribution configuration for three beans.
Case 1: The three beans B1, B2, and B3 are located on the same JOnAS server, which embeds a Java Transaction Monitor.
Case 2: The three beans are located on different JOnAS servers, one of them running the Java Transaction Monitor, which manages the global transaction.
Case 3: The three beans are located on different JOnAS servers, the Java Transaction Monitor is running outside of any JOnAS server.
Case 4: The three beans are located on different JOnAS servers. Each EJB server is running a Java Transaction Monitor. One of the JTM acts as the master monitor, while the two others are slaves.
These different configuration cases may be obtained by launching the JOnAS servers and eventually the JTM (case 3) with the adequate properties. The rational when choosing one of these configurations is resources location and load balancing. However, consider the following points:
If the beans should run on the same machine, with the same server configuration, case 1 is the more appropriate.
If the beans should run on different machines, case 4 is the more appropriate, since it favors local transaction management.
If the beans should run on the same machine, but require different server configurations, case 2 is a good approach.