You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem description
For certain use cases, I would like to use the embedded Infinispan instance in Keycloak to add own caches used by a external provider, particularly when running Keycloak in cluster mode.
Keycloak already exposes the InfinispanConnectionProvider SPI, which provides access to the Infinispan CacheManager. With the introduction of the new Infinispan configuration SPI (see #37912), it is now possible to contribute cache configurations via the CacheEmbeddedConfigProvider. However, there is no example or test case provided to demonstrate how to use the new SPI.
From what I understand, the intended approach for adding custom caches is to provide cache configurations through an external cache configuration file. However, for some scenarios this is not ideal.
Possible approaches that come to mind are:
Bundling cache configuration files inside the provider JAR and loading them automatically, or
Programmatically defining default cache configurations from the provider itself
Current analysis
I experimented with defining a cache configuration programmatically via the CacheEmbeddedConfigProvider:
However, when I try to add new cache configurations from a custom provider during the postInit process at the provider factory, it doesn't work as expected.
At that point in the lifecycle:
The ConfigurationBuilderHolder has already been initialised into the DefaultCacheManager during the migration process at startup.
Newly added cache configurations from CacheEmbeddedConfigProvider are no longer picked up.
What is the intended and supported way for a custom provider to define new Infinispan caches:
before the DefaultCacheManager is created,
without extending or overriding CacheEmbeddedConfigProvider,
and how can this be done without causing conflicts when multiple providers want to register their own caches?
Call stack from the initialization of the DefaultCacheManager:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem description
For certain use cases, I would like to use the embedded Infinispan instance in Keycloak to add own caches used by a external provider, particularly when running Keycloak in cluster mode.
Keycloak already exposes the
InfinispanConnectionProviderSPI, which provides access to the InfinispanCacheManager. With the introduction of the new Infinispan configuration SPI (see #37912), it is now possible to contribute cache configurations via theCacheEmbeddedConfigProvider. However, there is no example or test case provided to demonstrate how to use the new SPI.From what I understand, the intended approach for adding custom caches is to provide cache configurations through an external cache configuration file. However, for some scenarios this is not ideal.
Possible approaches that come to mind are:
Current analysis
I experimented with defining a cache configuration programmatically via the
CacheEmbeddedConfigProvider:However, when I try to add new cache configurations from a custom provider during the
postInitprocess at the provider factory, it doesn't work as expected.At that point in the lifecycle:
ConfigurationBuilderHolderhas already been initialised into theDefaultCacheManagerduring the migration process at startup.CacheEmbeddedConfigProviderare no longer picked up.What is the intended and supported way for a custom provider to define new Infinispan caches:
DefaultCacheManageris created,CacheEmbeddedConfigProvider,Call stack from the initialization of the

DefaultCacheManager:Beta Was this translation helpful? Give feedback.
All reactions