Hot Rod is the protocol used by "intelligent clients" of an Infinispan Server, which implies
the client is smart enough to implement a series of performance optimisation tricks; for example
it is able to connect to the most suited server in the cluster depending on the data
being requested (or written), greatly reducing the latency of operations.
While Infinispan is most known as an high-performance key/value store, when it comes to remote
clients the recommended approach is to encode your data in Google Protobuffers.
This allows for evolution of your storage schema without breaking decoding of existing
data, allows server side queries and functions to interpret the stored data, and allows
interoperability with Hot Rod clients from other programming languages.
It allows for example to read the POJOs we write using the Java client from a Python client, and
have the data converted into reasonable Python Objects.
Unfortunately dealing with an Hot Rod client can be tedious!
It’s a key-value store: manual handling of object relations is error prone
You’ll need to write and maintain a matching Protobuf Schema for all your entities
You’ll have to setup Protostream and configure it as Marshaller for the Hot Rod client
Most importantly, it requires new skills.
You’ll have to learn how a Protobuf Schema is best defined, and how to use Protostream.
Finally, you’ll have to learn the Hot Rod API and how to make the most of its
advanced flags to tune each operation, and consider carefully how you want to represent relations.
Use something familiar instead?
Hibernate OGM can automate the tedious parts, and let you focus on what matters: storing your objects.
Add this dependency:
Enable OGM’s Hot Rod super powers in your persistence.xml :
value="infinispan_remote" /> (2)
value="127.0.0.1:11222" /> (3)
||Choose Hibernate OGM as JPA Provider
infinispan_remote as datastore
||include Hot Rod configuration properties, just replacing/adding the OGM prefix.
Start Hibernate OGM!
EntityManagerFactory emf = Persistence.createEntityManagerFactory("ogm-with-hotrod");
That’s enough to create Hibernate
EntityManagers which knows how to perform CRUD of your model,
encoding and decoding your data into Hot Rod!
Start and manage the Hot Rod client, have it initialize connections to your Infinispan Server
Generate an appropriate Protobuf Schema for your model
Deploy the schema to the Infinispan Server
Initialize all the internal Protobuf encoders and decoders using Protostream
Properly implement sequences / autoincrements (a feature lacking in native Hot Rod)
There are some limitations.
The most notable one is that you will have to manually create
the Cache definitions that it will need on your Infinispan Server configuration, as
at this time this is an operation which can’t be performed over Hot Rod (but the friendly
Infinispan team is working on a solution).
Another limitation is that at this time we don’t support running JPQL queries on this backend.
You can find many more interesting details in our Infinispan integration reference guide; I’ve included a section to help you choose between Infinispan Embedded
and Infinispan Remote (over Hot Rod).
Hibernate OGM 5.0.3.Final
We also released Hibernate OGM version
5.0.3.Final, to address a single mapping issue:
many thanks to Simone Manetti for reporting OGM-1198, now resolved in this version.
If you need to upgrade from a version before 5.0, you can find help in the