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

EclipseLink/Examples/JPA/CacheCoordination

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:

  • disabling the shared cache
  • only caching read-only objects
  • set a cache invalidation timeout
  • refreshing
  • using a distributed cache
  • using cache coordination (synchronizing the caching)

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.

Prerequisites

The following software is required to run this example:

  • Oracle Weblogic Server (10.3.4 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))
  • EclipseLink (WLS 10.3.4 includes EclipseLink 2.1, a 2.2 build or any >= 1.2 version could be used) - download link
  • Example - download link

Links

Back to the top