It is easy to set up Infinispan and run it as a cluster composed from JBoss AS nodes only or standalone nodes in JavaSE environment. One have to prepare a single configuration file and that's it. But what can we do if there is a need that a cluster should be formed by couple of nodes started under JBoss and some count of nodes running as JavaSE application? The answer is quite easy - we need (as usually) a common configuration for both types of nodes, i.e. configuration provided as separate XML file and as a part of JBoss server profile. The challange here is to provide the same key elements of configuration using different XML schemas. Since both XSDs are well documented there's a hope we can do it!
A small clarification here - since I tested this for UDP protocol following description will concern usage of this protocol. I didn't tested TCP scenario but if someone of you has faced it - your tips, comments and experience is more than welcome on this forum. Moreover I used JBoss 7.1.1 with Infinispan 5.1.2 and JGroups 3.0.6 for enterprise part and Infinispan 5.1.5 with JGroups 3.0.10 for standalone part of a cluster.
First of all we have to start with JGroups configuration since this is a key factor for a transport layer. Both configurations don't have to be necessarily exactly the same - in scenario I built such cluster a default configurations of JGroups for JBoss server and Infinispan Quickstart projects was taken.
Obvious and standard points here are multicast's address and port. Both must be the same for both types of nodes. Those are fundamentals we can further build on. Next thing to set up is the same failure detection protocol - I used FD protocol in my situation however the scenario works also for FD_ALL protocol. What is important here standalone and enterprise sides must use the same protocol at the same time. If not the cluster view will be created but it won't be stable and data between nodes will not flow.
Infinispan configuration on the other hand has to provide the same names of cluster and cache. We want to create a cluster of nodes so name of it have to be the same on all of nodes if data packets should not be discarded. The same applies to the cache name - if in the target node that is a part of existing Infinispan cluster there is no cache with specific name the data will be abonded and both cache instances remain transparent for each other.
Two tips at the end:
- In case if you are not using different versions of JGroups in JBoss and JavaSE you can hit the problem of incompatibility between them. You can try to tackle this case with special flag in JGroups configuration, i.e. 'discard_incompatible_packets'. However I didn't have to use it so it's hard to say whether having such situation using the flag will help. If you had try this, your comments will be definitely valueable for others!
- What I spotted as well is usage of different IP stacks by JBoss and JavaSE virtual machines. Both evironments must use the same stack to communicate with each other. This can be solved by '-Djava.net.preferIPv4Stack' and '-Djava.net.preferIPv6Stack' JVM flags and setting proper true/false values for them.