0

I have two applications using same database entities. Both applications are deployed on jboss eap 6.2 separate clusters. DB tables are updated only from one application but are read from both applications. Both applications are using native hibernate APIs to read/write data from database.

After enabling infinispan as 2LC in embedded mode, how do I ensure that cache entities updated in one application are invalidated from 2nd application cache? Any JMX/JMS interface to signal cache invalidation?

If I go for remote cache mode and start infinispan as hot rod server, then cache server can be shared with both application. But then do i need to update code to query entities from cache using hot rod client API's? Also will it update/invalidate the cache automatically if entity is updated from application.

priyam
  • 74
  • 7

1 Answers1

1

This is not supported. There's no remote second level cache Infinispan implementation for Hibernate. The embedded implementation uses deep integrations with embedded-only features and hence it's not interchangeable.

If using embedded, each application gets their own caches and these cannot be shared because each application is a separate classloader. So, entity A from classloader X cannot be read with entity A from classloader Y.

If you really want a shared cache, nothing stops you from doing it yourself, by adding data to a remote Infinispan Server.

Galder Zamarreño
  • 5,027
  • 2
  • 26
  • 34
  • if I go for remote infinispan server, will cache be invalidated automatically when entity is updated? And when the entity is read again, cache will be populated from database automatically similar to embedded mode? – priyam Aug 09 '18 at 11:37
  • If you go for remote infinispan server, you handle your own cache since there's no hibernate cache provider for Infinispan remote. The cache can be configured with invalidation mode which works like that: when an entity is updated, it's invalidated from other nodes. When you read the entity, it'd up to your code that calls the Infinispan server to cache things. – Galder Zamarreño Aug 10 '18 at 11:00