Fetching contributors…
Cannot retrieve contributors at this time
170 lines (106 sloc) 5.62 KB

Infinispan Remote-Cache Quickstart using Hot Rod client that supports Google Protocol Buffers for Serialization

Level Technologies Target Product Product Versions Source


Teiid, Infinispan, Hot Rod, Remote Query, Protobuf Annotations

Teiid 9.3+, Infinispan 9+ (JDG 7.1+)

What is it?

This quickstart demonstrates how Teiid can connect to a remote Infinispan cache and perform queries and/or update data in the cache using the Hot Rod client protocol.

System requirements

You can obtain JDG kit distributions on Red Hat’s Customer Portal at


1. JDG setup

  • Install the JDG server

  • Start JDG Server

Assumptions: - It is assumed that you will be running both servers on the same box, therefore, start the JDG server by using the port offset argument: -Djboss.socket.binding.port-offset= - That majority of usecases will be using the cache in a distributed fashion, so the clustered configuration will be used

To start the server

./ -c clustered.xml -Djboss.socket.binding.port-offset=100

For the purpose of this quick start, it assumes running both servers on the same machine and is expecting the JDG server to have its ports incremented. The port adjustment has been made in the setup.cli script to match the above offset.

  • Configure JDG Cache

Note: The clustered.xml configuration will be used, instead of the standalone.xml, because use cases will generally expect to be using a clustered environment.

You have 2 options for configuring the cache:

a) running CLI script to configure cache b) editing standalone configuration(requires restarting the infinipan server)

a) Perform the following steps to configure the cache by running the CLI script against the infinispan server

  • locate the ./src/jdg/setup-infinispan-cache.cli script in the quickstart

  • cd to the ${SERVER_HOME}/bin directory

  • execute the setup-infinispan-cache.cli script by running the following:

    ./  --file={}/setup-infinispan-cache.cli

Since the server is running with the offset, use the -c option:

./ -c --file=./setup-infinispan-cache.cli

Note the name of the cache - personCache , as it needs to match the teiid-ispn Option property in the source model of the vdb..

b) Edit the standalone.xml configuration at ${SERVER_HOME}/standalone/configuration.

Note: if the infinispan server is running, then it will need to be stopped before editing the configuration.

Copy into the "clustered" section into the configuration within the infinispan:server subsystem.

        <subsystem xmlns="urn:infinispan:server:core:8.3">
            <cache-container name="clustered" default-cache="default" statistics="true">
                <distributed-cache-configuration name="templateTeiidCache" start="EAGER"/>
                <distributed-cache name="personCache" configuration="templateTeiidCache"/>
  • start the infinispan server

2. Setup Teiid Server

  • Start the server

To start the server, open a command line and navigate to the "bin" directory under the root directory of the Teiid server and run:

./ //For Linux
standalone.bat //for Windows

If Teiid isn’t configured in the default configuration, append the following arguments to the command to specify the configuration -c {configuration.file}

./ -c standalone-teiid.xml

3. Configure JDG connection

  • Setup the JDG Cache to be accessed as a data source

The infinispan hotrod client resource adapter will be configured by executing a CLI script.

Setup JDG Data Source
cd $\{JDG_HOME}/bin
./ --file=${PATH}/teiid-quickstarts/infinispan-hotrod-as-a-datasource/src/scripts/create-infinispan-hotrod-protobuf-ds.cli

4. deploy the VDB

Deploy for reading/writing to a remote cache, copy files person-cache-vdb.xml and person-cache-vdb.xml.dodeploy to {JBOSS_HOME}/standalone/deployments

Query Demonstrations

before querying, if not already, will need to add user/pasword.
  1. Change your working directory to "${quickstart.install.dir}/simpleclient"

  2. Use the simpleclient example to run the following queries:

Example: mvn exec:java -Dvdb="PersonVDB" -Dsql="Insert into Person (id, name, salary) Values (100, 'TestPerson', 25000.00)" -Dusername="teiidUser" -Dpassword="pwd"


Use a sql tool, like SQuirreL, to connect and issue following example query:

do not do a SELECT * FROM Person, because you will get a serialization error, because the Person class is not serializable.
  1. Queries for reading/writing to a remote cache via VDB People

    • connect: jdbc:teiid:PersonVDB@mm://{host}:31000

Example Query SQL
select name, salary, id from Person
Insert into Person (id, name, salary) Values (100, 'TestPerson', 35000.00);
Insert into Person (id, name, salary) Values (200, 'TestPerson2', 44123.12);

select name, salary, id from Person where id = 100
Update Person set name='testPerson 100' where id = 100 then - select name, salary, id from Person

delete from Person where id = 100
select name, salary, id from Person