EJB state replication

This article describes what EJB state replication is and how to set it up

1 Introduction

2 EJB-cluster enable a Entity bean

    In order for a Entity bean to be replicated within a cluster the deployment information for the Entity bean needs to be modified.

    Go through the following steps to EJB-cluster enable a Entity bean:

    2.1 Step 1: RMI-cluster enable the Server

      As the EJB-cluster service uses a underlying RMI-cluster service, the first step is to RMI-cluster enable the Server as described in this guide.

      If the Server is already RMI-cluster enabled, continue with the next step.

    2.2 Step 2: Locate the orion-ejb-jar.xml file

      Locate the orion-ejb-jar.xml file of the EJB-module that the Entity bean belongs to. This file is normaly located in the deployment directory of the Application that the EJB-module belongs to.

      In a default installation, the orion-ejb-jar.xml file is located at "orion/application-deployment/[Application]/[EJB-module]/orion-ejb-jar.xml". Substitute [EJB-module] with the EJB-module the Entity is part of and the [Application] with the Application the EJB-module is part of.

    2.3 Step 3: Cluster enable the Entity

      In the orion-ejb-jar.xml file located in the previous step, locate the deployment tag for the Entity. It should look something like in listing 1 below:


      <orion-ejb-jar ... >
      <enterprise-beans>
      <entity-deployment
      name="name"
      table="table"
      data-source="datasource"
      ... >
      ...
      </entity-deployment>
      ...
      </enterprise-beans>
      ...
      </orion-ejb-jar>
      Listing 1: The deployment tag of an Entity with the implicit clustering-schema attribute (normally not displayed).

      Where name is the name of the Entity bean.

      Make sure that the data-source and table is the same DataSource and table name for all nodes in the cluster.

      Add the attribute clustering-schema with a value of "asynchronous-cache" to cluster-enable the Entity bean (the default value is "default" which means that the Entity is not clustered). By now the deployment tag for the Entity should look similar to the example shown in listing 2 below.


      <orion-ejb-jar ... >
      <enterprise-beans>
      <entity-deployment
      name="name"
      table="table"
      data-source="datasource"
      clustering-schema="asynchronous-cache"
      ... >
      ...
      </entity-deployment>
      ...
      </enterprise-beans>
      ...
      </orion-ejb-jar>
      Listing 2: Cluster enabling a Entity bean by setting the clustering-schema attribute.

    2.4 Step 4: Enable transactional writes (Optional)

      If the entity is written to often consider adding the attribute exclusive-write-access with a value of "false" to the Entity's deployment tag. This will slow down the performance but making sure that all writes are transactional (the default value is "true" which is best suited for Entities that are mostly read.


      <orion-ejb-jar ... >
      <enterprise-beans>
      <entity-deployment
      name="name"
      table="table"
      data-source="datasource"
      clustering-schema="asynchronous-cache"
      exclusive-write-access="false"
      ... >
      ...
      </entity-deployment>
      ...
      </enterprise-beans>
      ...
      </orion-ejb-jar>
      Listing 3: Enabling transactional writes for a clustered Entity

3 EJB-cluster enable a Session bean

    In order for a Session bean to be distributed within a cluster the deployment information for the Session bean needs to be modified.

    Go through the following steps to EJB-cluster enable a Entity bean:

    3.1 Step 1: RMI-cluster enable the Server

      As the EJB-cluster service uses a underlying RMI-cluster service, the first step is to RMI-cluster enable the Server as described in this guide.

      If the Server is already RMI-cluster enabled, continue with the next step.

    3.2 Step 2: Locate the orion-ejb-jar.xml file

      Locate the orion-ejb-jar.xml file of the EJB-module that the Session bean belongs to. This file is normaly located in the deployment directory of the Application that the EJB-module belongs to.

      In a default installation, the orion-ejb-jar.xml file is located at "orion/application-deployment/[Application]/[EJB-module]/orion-ejb-jar.xml". Substitute [EJB-module] with the EJB-module the Session is part of and the [Application] with the Application the EJB-module is part of.

    3.3 Step 3: Cluster enable the Session

      In the orion-ejb-jar.xml file located in the previous step, locate the deployment tag for the Session. It should look something like in listing 3 below:


      <orion-ejb-jar ...>
      <enterprise-beans>
      <session-deployment
      name="name"
      location="location"
      ... >
      </session-deployment>
      </orion-ejb-jar>
      Listing 3: The deployment tag of the Session bean.

      Where name is the name of the Session bean.

      Add the attribute replication with a value of "cluster" to cluster-enable the Session bean (the default value is "none" which means that the Session is not clustered). By now the deployment tag for the Session should look similar to the example shown in listing 4 below.


      <orion-ejb-jar ...>
      <enterprise-beans>
      <session-deployment
      name="name"
      location="location"
      ...
      replication="cluster"
      ... >
      </session-deployment>
      </orion-ejb-jar>
      Listing 4: The deployment tag of the cluster enabled Session bean.

4 Debugging

    This section describes common techniques that can be used to debug RMI-clustering.

    4.1 Tracing

      In order to get trace information from the cluster services, start the Orion Server with the cluster.debug and ejb.cluster.debug system properties set to true, as exemplified in listing 5 below.


      java -Dejb.cluster.debug=true -Dcluster.debug=true -jar orion.jar -console
      Listing 5: Starting a Orion server with cluster.debug system properties turned on

      The cluster.debug property will list common cluster debug information to the cosole.

      The ejb.cluster.debug property will list EJB cluster debug information to the console.

    4.2 Application logs

      Issues the EJB-clustering service has with either sending or receiving state can be found in the Applications application.log file per default.

5 Troubleshooting

    This section describes common problems and possible solutions.

    5.1 Firewall issues

      Make sure that any firewalls allows for the Servers to communicate on the configured multicast address in both directions, both sending and receiving information.

      Using a simple multicast sender/receiver test application allows for testing the configured multicast address and make sure that packets can be both sent and received.

    5.2 Proxies/Gateways issues

      As multicast packets are known to hog down networks if allowed to roam free, most proxies and gateways won't let multicast packets pass. Make sure that the multicast packets can reach all nodes in the cluster and configure any proxies/gateways accordingly.

Copyright © 2005 IronFlare AB