Giter Club home page Giter Club logo

springboot-gemfire-jpa-atomikos's Introduction

springboot-gemfire-jpa-atomikos

Atomikos JTA provider as global transaction manager to coordinate GemFire/Geode cache transactions with JPA/JDBC and/or JMS resources.

Atomikos is light-weight (e.g. out-of-container), embeddable global transaction manager. Atomikos is JTA compliant and can be integrated with Gemfire/Geode to perform XA transaction across Geode, JPA/JDBC and JMS operations.

Atomikos Gemfire Integration:

  1. Add the following SpringBoot starters to your POM:
  • spring-boot-starter-data-gemfire (or spring-data-geode)
  • spring-boot-starter-data-jpa
  • spring-boot-starter-jta-atomikos
  1. Start an In-Memory JNDI provider (SimpleNamingContextBuilder) before the application context is initialized.
  2. After the Application Context initialization (e.g. in @PostConstruct) bind the Atomikos UserTransaction manager to the JNDI using name: java:comp/UserTransaction

Now you can use Spring @Transaction annotations to start global (manged by Atomikos) transactions. If Gemfire operation (like put/get) is performed within such transaction it will atomatically participate in the global transaction.

Geode/Gemfire JTA Background

Out of the box, Gemfire/Geode provides the following JTA Global Transactions integration options:

  1. Have Gemfire/Geode act as JTA transaction manager - Mind that Gemfire JTA manager is not JTA compliant and could cause synchronization and transaction coordination problems. In its current state you better not use it as JTA manager!
  2. Coordinate with an external JTA transaction manager in a container (such as WebLogic or JBoss). Also GemFire can be set as the "last resource" while using a container. - While this approach provides a reliable JTA capabilities it requires a heavey-weight JEE container.

The SpringBoot Atomikos integration extends option (2) by using Atomikos as an external JTA manager without the need of running a J2EE container.

At startup GemFire looks for a TransactionManager javax.transaction.TransactionManager that has been bound to its JNDI context. When GemFire finds such an external transaction manager, all GemFire region operations (such as get and put) will participate in global transactions hosted by this external JTA transaction manager: Coordinates with External JTA Transactions Managers

Because Gemfire/Gedoe require JNDI provider to lookup the global transactions we have build a simple (in-memory) JNDI provider: io.pivotal.poc.gemfire.gtx.jndi.SimpleNamingContextBuilder. Note: SimpleNamingContextBuilder re-uses the code from the spring-test project. If you know a more elgant way to create in-memory JNDI providers please let me know!

Build (default with Gemfire)

mvn clean install

Build with Apache Geode

mvn clean install -Pgeode

Run

java -Dgemfire.name=server1 
     -Dgemfire.server.port=40405 
     -Dgemfire.jmx-manager-port=1199 
     -Dgemfire.jmx-manager=true 
     -Dgemfire.jmx-manager-start=true 
     -jar ./target/gemfire-jpa-atomikos2-0.0.1-SNAPSHOT.jar

springboot-gemfire-jpa-atomikos's People

Contributors

tzolov avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.