I am using a JBoss EAP 6.3 application server in conjunction with a JDG 6.3.1 (with Infinispan 6.1.2), both instances run on the same virtual machine and the connection protocol is Hot Rod.
If for whatever reason the JDG is not reachable I want the Hot Rod Client used in an EJB application on the EAP to catch the HotRodClientException
and continue directly with a database call.
This works fine but the retry count in the RemoteCacheManager is set to 10 so that it takes a lot of time until I can continue after the connection finally failed after 10 retries.
Looking at the classes involved I was not able to find a way to configure the max retry count for a Hot Rod connection. The only thing I found is using ConfigurationBuilder.withProperties(Properties)
, but it is mentioned that this is for migrating from an old version of Inifinispan where properties objects where used for configuration.
I tried the following code but it also fails in setting the rety count to 1:
Properties jdgProperties = new Properties();
jdgProperties.put("infinispan.client.hotrod.server_list", host + ":" + hotrodPort);
jdgProperties.put("infinispan.client.hotrod.max_retries", "1");
Configuration jdgConfWithProperties = builder.withProperties(jdgProperties).build();
How can I configure the retry count to anything but the default value of 10?
This should work:
Configuration configuration = new ConfigurationBuilder().maxRetries(2).build();
RemoteCacheManager remoteCacheManager = new RemoteCacheManager(configuration);