I have the below infinispan config:
<?xml version="1.0" encoding="UTF-8"?>
<infinispan xmlns="urn:infinispan:config:15.2">
<jgroups>
<stack name="test-cluster" extends="tcp">
<TCPPING initial_hosts="node1.domain.com[7800],node2.domain.com[7800]"/>
</stck>
</jgroups>
<cache-container name="foobar">
<transport stack="test-cluster" cluster="test-cluster"/>
<replicated-cache name="foobar-cache">
<expiration lifespan=1"15m"/>
<memory max-count="200" when-full="REMOVE"/>
</replicated-cache>
</cache-container>
</infinispan>
I have @EnableCaching on my main class right next to the @SpringBootApplication and I'm using @Cacheable on one of the methods inside an @Service class. The cache is working perfectly fine until I send requests to the same node.
The nodes are forming their very own clusters for some reason and even after reading the documentation and obliterating my infinispan.xml config to the bare minimum I could think of I absolutely don't understand what's going on.
I enabled TRACE logs for both org.infinispan and org.jgroups, and seemingly it doesn't even try to contact the other node only localhost. There is no firewall, in both cases the IPs logged by jgroups are the actual IPs of localhost which is great.
I verified the connectivity from either of the hosts using:
nc -zv <other-hostname> 7800
Ncat: Version 7.92 ( https://nmap.org/ncat )
Ncat: Connected to <other-host-ip>:7800.
Ncat: 0 bytes sent, 0 bytes receoved in 0.01 seconds.
I'm stuck like rebar in concrete. What on earth am I missing? Why aren't my individual nodes connecting to one another? I'm using the very same infinispan.xml config bundled in the jar itself (src/main/resources/infinispan.xml) and using the below config for loading it from
application.yml:
infinispan:
embedded:
configXml: "caching/infinispan.xml"
Based on infinispan-spring-boot3-starter docs it should just magically work, well seemingly it does but only for localhost so I'm sure I'm missing something but I have no idea where and what.
You're missing the stack.combine and stack.position attributes, as said in our docs: https://infinispan.org/docs/stable/titles/embedding/embedding.html#customizing-jgroups-stacks_cluster-transport
It should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<infinispan xmlns="urn:infinispan:config:15.2">
<jgroups>
<stack name="test-cluster" extends="tcp">
<TCPPING initial_hosts="node1.domain.com[7800],node2.domain.com[7800]"
stack.combine="REPLACE"
stack.position="MPING" />
</stck>
</jgroups>
<cache-container name="foobar">
<transport stack="test-cluster" cluster="test-cluster" />
<replicated-cache name="foobar-cache">
<expiration lifespan= 1"15m" />
<memory max-count="200" when-full="REMOVE" />
</replicated-cache>
</cache-container>
</infinispan>