Chapter 43. Configuring Compatibility Mode

Compatibility mode provides a mechanism for accessing data in the cache from multiple endpoints.

Compatibility mode configures JBoss Data Grid to use a marshaller that serializes and deserializes raw bytes into strings and primitives. For this reason, compatibility mode supports only strings and primitives and does not support objects.

Important

Compatibility mode is not an efficient method for achieving interoperability between remote endpoints. It is a legacy feature that is not recommended for new deployments.

Instead of using compatibility mode, you should configure the format in which the cache stores data by defined the media type. See Endpoint Interoperability.

43.1. 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>

43.2. Marshallers in Compatibility Mode

JBoss Data Grid does not support custom marshallers. You can use the following 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 in compatibility mode.

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.

43.3. Specifying the Marshaller

Specify marshallers with the marshaller attribute, 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>

43.3.1. Memcached Marshaller

When using memcached in compatibility mode, you must explicitly set the default marshaller, GenericJBossMarshaller, in the configuration. For example:

<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>
Important

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.