Alex
Alex

Reputation: 1535

Infinispan Concurrency DefaultCacheManager

I m using infinispan and initializing the DefaultCacheManager by this code lines:

                GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();
                gcb.globalJmxStatistics().enabled(false).allowDuplicateDomains(true);
                gcb.transport().defaultTransport().addProperty(JGroupsTransport.CONFIGURATION_STRING,
                        configurator.getProtocolStackString());

                ConfigurationBuilder builder = new ConfigurationBuilder();
                builder.clustering().cacheMode(CacheMode.DIST_SYNC).expiration().lifespan(24l, TimeUnit.HOURS);

                builder.clustering().stateTransfer().awaitInitialTransfer(false);
                builder.clustering().hash().numOwners(2);

                cacheManager = new DefaultCacheManager(gcb.build(), builder.build());

The above snippet code is present in N war deployed inside the same application server.

So it happens that when i deploy all the war simultaneosly i get a concurrency exception executing the new DefaultManager() instruction

org.infinispan.jmx.JmxDomainConflictException: ISPN000034: There's already a JMX MBean instance type=CacheManager,name="DefaultCacheManager" already registered under 'org.infinispan' JMX domain. 

this happens even if i ve specified the configuration property:

allowDuplicateDomains(true);

How can i handle correctly this behaviour?

Upvotes: 0

Views: 232

Answers (1)

Sebastian Łaskawiec
Sebastian Łaskawiec

Reputation: 2737

I created a reproducer for this issue and as far as I can tell it looks OK.

Just a couple of gotchas and hints:

  • Please make sure you're using the latest stable version (in this case 8.2.4.Final).
  • I suggest using CDI extension rather than implementing your own bootstrap and cleanup.
  • If you for some reason need to create CacheManager yourself - remember to stop it when destroying beans.
  • If you're using Wildfly - remember that your CacheManager is not the only one in the container (WF uses Infinispan for internal things like session replication).

Upvotes: 1

Related Questions