Search

Chapter 38. Data Interoperability

download PDF

38.1. Protocol Interoperability

38.1.1. Protocol Interoperability

Protocol interoperability enables clients that are written in different programming languages to read and write cache entries from any Red Hat JBoss Data Grid endpoint, such as REST, Memcached, or Hot Rod.

Each endpoint stores data in a suitable format so that data transformation is not required to retrieve entries from the cache. However, when accessing data from multiple protocols, Red Hat JBoss Data Grid must convert data between the formats for each endpoint.

To access data in a cache from multiple protocols, you must enable compatibility mode on that cache.

Important

Compatibility mode supports only strings and primitives. Objects are not supported.

38.1.2. Enabling Compatibility Mode

To enable compatibility mode, add enabled=true to the compatibility element as follows:

<cache-container name="local" default-cache="default" statistics="true">
    <local-cache name="default" statistics="true">
        <compatibility enabled="true">
    </local-cache>
</cache-container>

38.1.3. Marshallers

Marshallers enable JDG to serialize and deserialize raw bytes into strings and primitives. The following table describes the marshallers that you can use with JBoss Data Grid in compatibility mode:

Table 38.1. Marshallers in Compatibility Mode
MarshallerDescription

GenericJBossMarshaller

Uses the JBoss marshaller to serialize and deserialize strings and primitives as byte arrays. This is the default marshaller for JDG.

ProtoStreamCompatibilityMarshaller

Uses the ProtoStream library to serialize and deserialize strings and primitives as byte arrays.

UTF8StringMarshaller

Serializes and deserializes strings and primitives as UTF8 byte arrays.

Note

JBoss Data Grid does not currently support custom marshallers.

38.1.4. Setting the Marshaller

By default JBoss Data Grid uses the GenericJBossMarshaller when in compatibility mode. To use a different marshaller, you must set it with the marshaller parameter as in the following example:

<cache-container name="local" default-cache="default" statistics="true">
    <local-cache name="default" statistics="true">
    	<compatibility enabled="true" marshaller="org.infinispan.commons.marshall.UTF8StringMarshaller"/>
    </local-cache>
</cache-container>

38.1.5. Protocol Interoperability Over Memcached

When using memcached in compatibility mode, you must explicitly set the default marshaller, GenericJBossMarshaller, in the configuration as follows:

Memcached Marshaller Configuration

<cache-container name="local" default-cache="default" statistics="true">
    <local-cache name="default" statistics="true">
        <compatibility enabled="true" marshaller="org.infinispan.commons.marshall.jboss.GenericJBossMarshaller"/>
    </local-cache>
</cache-container>

38.1.5.1. Transcoder for Java Clients

Java clients must use a transcoder to perform read and write operations in compatibility mode. The transcoder enables memcached clients written in Java to convert between byte arrays and strings or primitives.

38.1.6. Protocol Interoperability Over REST

When data is stored via the REST interface the values are interpreted by Hot Rod or Memcached clients as a sequence of bytes. Meaning is given to this byte-sequence using the MIME type specified via the "Content-Type" HTTP header, but the content type information is only available to REST clients. No specific interoperability configuration is required for this to occur.

When retrieving data via REST, primitive types stored are read in their primitive format. If a UTF-8 String has been stored via Hot Rod or Memcached, it will be retrieved as a String from REST. If custom objects have been serialized and stored via the remote cache, these can be retrieved as application/x-java-serialized-object, application/xml, or application/json. Any other byte arrays are treated as application/octet-stream.

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.