In my Spring boot app, we have configured @EnableCaching
with HazelcastCacheManager
and it working without problem.
But, it is required to access Hazelcast
instance to use it's other features (distributed locks, distributed computing).
How can I achieve this using the same instance of Hazelcast
used in HazelcastCacheManager
(instead of creating new one)?
p.s. First thing came to my mind is registering Hazelcast
wrapper class as @Component
, and Auto wiring it to @Configuration
annotated class using constructor. But I am not sure how things will turn out.
How about this, HazelcastCacheManager.getHazelcastInstance()
.
Perhaps also then expose the retrieved HazelcastInstance
as a @Bean
, then you can inject into the rest of your application and that code need have no awareness of @EnabledCaching
being present or absent.