Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Examples/JPA/CacheCoordination"

(Running the example)
(Running the example)
Line 32: Line 32:
 
==Running the example==
 
==Running the example==
 
# Install Oracle WebLogic (or your desired JEE application server, or use existing application server)
 
# Install Oracle WebLogic (or your desired JEE application server, or use existing application server)
 +
# Configure paths to server in the <example>/build.xml (JEE_HOME, JEE_SERVER, JEE_HOST, JEE_USER, JEE_PASSWORD)
 
# Upgrade the eclipselink.jar in your application server to be the latest release (not required)
 
# Upgrade the eclipselink.jar in your application server to be the latest release (not required)
 
## In WebLogic the eclipselink.jar is in <weblogic-home>/modules/ directory named org.eclipse.persistence_1.0.0.0_x-x.jar, where x depends on the version of WebLogic.
 
## In WebLogic the eclipselink.jar is in <weblogic-home>/modules/ directory named org.eclipse.persistence_1.0.0.0_x-x.jar, where x depends on the version of WebLogic.
 
## If using another application server you may need to add the eclipselink.jar to your application server's library path.
 
## If using another application server you may need to add the eclipselink.jar to your application server's library path.
 
## You must also update the path in the <example>/build.xml to point to EclipseLink, JPA and EJB (JPA_LIB, EJB_LIB, ECLIPSELINK_LIB)
 
## You must also update the path in the <example>/build.xml to point to EclipseLink, JPA and EJB (JPA_LIB, EJB_LIB, ECLIPSELINK_LIB)
# Configure paths to server in the <example>/build.xml (JEE_HOME, JEE_SERVER, JEE_HOST, JEE_USER, JEE_PASSWORD)
 
 
# Install Oracle database (or use existing database, ensure the database is not an embedded database)
 
# Install Oracle database (or use existing database, ensure the database is not an embedded database)
 
# Configure database in <example>/build.xml (DB_DRIVER, DB_URL, DB_USER, DB_PASSWORD)
 
# Configure database in <example>/build.xml (DB_DRIVER, DB_URL, DB_USER, DB_PASSWORD)
 
## or, you could create your own DataSource in your application server using your application server's tools or config,
 
## or, you could create your own DataSource in your application server using your application server's tools or config,
 
## this example uses ant to automatically create a DataSource in the server.
 
## this example uses ant to automatically create a DataSource in the server.
 +
# Install ant (or uses existing ant install)
 +
# Create the WebLogic domain and cluster
 +
## Run "ant create-cluster",
 +
## this will create a new WebLogic domain, a cluster and three servers on the same machine but with different ports.
 +
## Ensure the prompt environment variables have been set to use the JVM provided in the WebLogic install (JRockit was used for this example)
 +
## An existing domain/cluster could also be used, or separate machines for each server in the cluster.
 +
## If using an existing domain/cluster, you will need to manually configure and start each server.
 +
# Start the cluster
 +
## Run "ant start-cluster",
 +
## this will start 4 weblogic servers, an admin server, and 3 servers in a cluster.
 +
# Configure the cluster
 +
## Run "ant setup-cluster"
 +
## this will create a DataSource, ConnectionPool, JMSServer and deploy then to the cluster.
 +
# Build the application
 +
## Run "ant"
 +
## this will compile the example code and build the employee.ear
 +
# Deploy the application
  
 
==Links==
 
==Links==

Revision as of 15:37, 20 September 2010

Overview

EclipseLink supports a shared (L2) object cache that avoids database access for objects and their relationships. This cache is enabled by default which is normally not a problem, unless the database is modified directly by other applications, or by the same application on other servers in a clustered environment.

There are many solutions to caching in a clustered environment, including:

  • disable the shared cache
  • only cache read-only objects
  • set a cache invalidation timeout
  • use refreshing on objects/queries when fresh data is required
  • use optimistic locking (writes on stale data will fail, and will automatically invalidate the cache)
  • using a distributed cache (such as Oracle TopLink Grid with Oracle Coherence)
  • using cache coordination (synchronizing the caches, as discussed in this example)

This example gives an overview of the cache coordination option.

EclipseLink provides a cache coordination feature that enables a set of EclipseLink sessions to synchronize their changes in a distributed network such as an application server cluster. Cache coordination works by each EclipseLink session (ServerSession/persistence unit) on each server in the cluster being able to broadcast notification of transactional object changes to the other EclipseLink sessions in the cluster. EclipseLink supports cache coordination over RMI and JMS. The cache coordination framework is also extensible so other options could be developed.

This example demonstrates enabling cache coordination using JMS or RMI for a JEE EJB 3.0 SessionBean application using JPA deployed to an Oracle Weblogic cluster. The example could be ported to other JEE application servers or environments. EclipseLink supports cache coordination in any Java environment, including Java SE, or Tomcat.

If you encounter any issues in running this example, or are running in another app server or version please discuss, here

Prerequisites

The following software is required to run this example:

  • Oracle Weblogic Server (10.3.3 was used, but any WLS version supporting EJB 3 should work, or any JEE application server with some work) - download link
  • ant (1.7 was used, but other versions should also work) - download link
  • Oracle database (or any other client/server database (embedded database will not work as cannot be accessed from all machines)) - download link
  • EclipseLink (WLS 10.3.4 includes EclipseLink 2.1, a 2.2 build or any >= 1.2 version could be used) - download link
  • Cache coordination example - download link

Running the example

  1. Install Oracle WebLogic (or your desired JEE application server, or use existing application server)
  2. Configure paths to server in the <example>/build.xml (JEE_HOME, JEE_SERVER, JEE_HOST, JEE_USER, JEE_PASSWORD)
  3. Upgrade the eclipselink.jar in your application server to be the latest release (not required)
    1. In WebLogic the eclipselink.jar is in <weblogic-home>/modules/ directory named org.eclipse.persistence_1.0.0.0_x-x.jar, where x depends on the version of WebLogic.
    2. If using another application server you may need to add the eclipselink.jar to your application server's library path.
    3. You must also update the path in the <example>/build.xml to point to EclipseLink, JPA and EJB (JPA_LIB, EJB_LIB, ECLIPSELINK_LIB)
  4. Install Oracle database (or use existing database, ensure the database is not an embedded database)
  5. Configure database in <example>/build.xml (DB_DRIVER, DB_URL, DB_USER, DB_PASSWORD)
    1. or, you could create your own DataSource in your application server using your application server's tools or config,
    2. this example uses ant to automatically create a DataSource in the server.
  6. Install ant (or uses existing ant install)
  7. Create the WebLogic domain and cluster
    1. Run "ant create-cluster",
    2. this will create a new WebLogic domain, a cluster and three servers on the same machine but with different ports.
    3. Ensure the prompt environment variables have been set to use the JVM provided in the WebLogic install (JRockit was used for this example)
    4. An existing domain/cluster could also be used, or separate machines for each server in the cluster.
    5. If using an existing domain/cluster, you will need to manually configure and start each server.
  8. Start the cluster
    1. Run "ant start-cluster",
    2. this will start 4 weblogic servers, an admin server, and 3 servers in a cluster.
  9. Configure the cluster
    1. Run "ant setup-cluster"
    2. this will create a DataSource, ConnectionPool, JMSServer and deploy then to the cluster.
  10. Build the application
    1. Run "ant"
    2. this will compile the example code and build the employee.ear
  11. Deploy the application

Links

Back to the top