Search code examples
javaejbwildflywildfly-10infinispan

WildFly Infinispan put get not working propertly


WildFly 10.0.0-final

Infinispan 8.1.0-Final

Im working with 2 nodes same config standalone-full-ha

/subsystem=infinispan/cache-container=infinispan_cache:add( aliases=["infinispan_cache-alias"], default-cache=default_cache, start=LAZY)
/subsystem=infinispan/cache-container=infinispan_cache/transport=TRANSPORT/:add(lock-timeout=60000, stack=tcp)
/subsystem=infinispan/cache-container=infinispan_cache/replicated-cache=default_cache:add(mode=ASYNC)

I get the cache in this way

@Resource(lookup = "java:jboss/infinispan/cache/infinispan_cache/default_cache")
private org.infinispan.Cache<String, Object> cache;

I'm using putForExternalRead then the other node knows the value using get, the other side, everything go well, but when I use get from the node witch put the value, returns null.

cache.putForExternalRead("hola","Hola prueba");
Object o = cache.get("hola");//This o is null

Solution

  • The solution was to configure properly Jgroups with TCP stack and my own Cache under batch SYNC transaction

    <subsystem xmlns="urn:jboss:domain:infinispan:4.0">
            ...
            <cache-container name="my_infinispan_cache" aliases="my_infinispan_cache-alias" default-cache="default_cache">
                <transport lock-timeout="60000"/>
                <replicated-cache name="default_cache" mode="SYNC">
                    <locking isolation="READ_COMMITTED"/>
                    <transaction locking="OPTIMISTIC" mode="BATCH"/>
                    <eviction strategy="NONE" max-entries="-1"/>
                    <expiration lifespan="-1" max-idle="-1"/>
                </replicated-cache>
            </cache-container>
        </subsystem>
        ...
        <subsystem xmlns="urn:jboss:domain:jgroups:4.0">
            <channels default="ee">
                <channel name="ee" stack="tcp"/>
            </channels>
            <stacks>           
                <stack name="udp">
                    ...
                </stack>
                <stack name="tcp">
                    <transport type="TCP" socket-binding="jgroups-tcp"/>
                    <protocol type="MPING" socket-binding="jgroups-mping"/>
                    <protocol type="MERGE3"/>
                    <protocol type="FD_SOCK" socket-binding="jgroups-tcp-fd"/>
                    <protocol type="FD"/>
                    <protocol type="VERIFY_SUSPECT"/>
                    <protocol type="pbcast.NAKACK2"/>
                    <protocol type="UNICAST3"/>
                    <protocol type="pbcast.STABLE"/>
                    <protocol type="pbcast.GMS"/>
                    <protocol type="MFC"/>
                    <protocol type="FRAG2"/>
                </stack>
            </stacks>
        </subsystem>