Over a million developers have joined DZone.

HotRod client in OSGi

· Integration Zone

Build APIs from SQL and NoSQL or Salesforce data sources in seconds. Read the Creating REST APIs white paper, brought to you in partnership with CA Technologies.

Infinispan 7.0.0.Alpha1 makes it possible to easily run the HotRod client in an OSGi based container such as Karaf. Until this point there was no easy way to find out which libraries were required for the HotRod client to run in OSGi. These libraries then had to be installed manually and dynamic imports enabled for all the libraries. Last but not least, it was not possible to use the latest HotRod feature - remote queries.

The 7.0.0.Alpha1 introduces a "features" file which not only lists all dependencies required for correct functionality of the HotRod client in OSGi, but also makes it very easy to install the whole feature into Karaf (version 2.3.3 or 3.0) in just a few steps.

HotRod client feature file for OSGi

The feature file has been deployed into JBoss Nexus repository so it's publicly available. It looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<features>
   <feature name="hotrod-client" version="7.0.0.Alpha1">
      <bundle>mvn:org.jboss.logging/jboss-logging/3.1.2.GA</bundle>
      <bundle>mvn:org.infinispan/infinispan-commons/7.0.0.Alpha1</bundle>
      <bundle>mvn:commons-pool/commons-pool/1.6</bundle>
      <bundle>mvn:org.jboss.marshalling/jboss-marshalling-osgi/1.4.2.Final</bundle>
      <bundle>mvn:org.infinispan/infinispan-client-hotrod/7.0.0.Alpha1</bundle>
   </feature>
   <feature name="hotrod-client-with-query" version="7.0.0.Alpha1">
      <feature version="7.0.0.Alpha1">hotrod-client</feature>
      <bundle>mvn:org.infinispan/infinispan-query-dsl/7.0.0.Alpha1</bundle>
      <bundle>mvn:com.google.protobuf/protobuf-java/2.5.0</bundle>
      <bundle>mvn:org.infinispan/infinispan-remote-query-client/7.0.0.Alpha1</bundle>
      <bundle>mvn:org.infinispan.protostream/protostream/1.0.0.Final</bundle>
   </feature>
</features>

Installing the HotRod client feature in Karaf

The HotRod feature (either a simple HotRod client or HotRod client with remote query capabilities) can be installed in Karaf in the following steps:
karaf@root> features:addUrl mvn:org.infinispan/infinispan-client-hotrod/7.0.0.Alpha1/xml/features
karaf@root> features:install hotrod-client
karaf@root> list
START LEVEL 100 , List Threshold: 50
   ID   State         Blueprint      Level  Name
[ 316] [Active     ] [            ] [   80] JBoss Logging 3 (3.1.2.GA)
[ 317] [Active     ] [            ] [   80] Infinispan Commons (7.0.0.Alpha1)
[ 318] [Active     ] [            ] [   80] Commons Pool (1.6.0)
[ 319] [Active     ] [            ] [   80] JBoss Marshalling OSGi Bundle (1.4.2.Final)
[ 320] [Active     ] [            ] [   80] Infinispan Hot Rod Client (7.0.0.Alpha1)
karaf@root> features:install hotrod-client-with-query
Refreshing bundles org.infinispan.client-hotrod (320)
karaf@root> list
START LEVEL 100 , List Threshold: 50
   ID   State         Blueprint      Level  Name
[ 316] [Active     ] [            ] [   80] JBoss Logging 3 (3.1.2.GA)
[ 317] [Active     ] [            ] [   80] Infinispan Commons (7.0.0.Alpha1)
[ 318] [Active     ] [            ] [   80] Commons Pool (1.6.0)
[ 319] [Active     ] [            ] [   80] JBoss Marshalling OSGi Bundle (1.4.2.Final)
[ 320] [Active     ] [            ] [   80] Infinispan Hot Rod Client (7.0.0.Alpha1)
[ 321] [Active     ] [            ] [   80] Infinispan Query DSL API (7.0.0.Alpha1)
[ 322] [Active     ] [            ] [   80] Protocol Buffer Java API (2.5.0)
[ 323] [Active     ] [            ] [   80] Infinispan Remote Query Client (7.0.0.Alpha1)
[ 324] [Active     ] [            ] [   80] ProtoStream - core (1.0.0.Final)
There's still one limitation with respect to remote querying, though. The remote query feauture requires a JMX-based connection to Infinispan server in order to be able to register a .protobin file, which holds the description of data types being transferred between the client and server. Since a remoting-jmx protocol is required and the existing remoting-jmx client does not work correctly in OSGi (see https://issues.jboss.org/browse/ISPN-4011), it is required to register the .protobin file in another way - not from inside the OSGi container. This will be fixed in one of the next releases.

Stay connected for news about running the whole Infinispan datagrid in OSGi, not only the HotRod client. This is work in progress.

The Integration Zone is brought to you in partnership with CA Technologies.  Use CA Live API Creator to quickly create complete application backends, with secure APIs and robust application logic, in an easy to use interface.

Topics:

Published at DZone with permission of Manik Surtani, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}