Could I know what will be the available option for us to ensure that no two md bean instance reside in different cluster node accessing the same shared resources?
The current approach i have identified is using the Hibernate LockMode.UPGRADE_NOWAIT. Whenever the md bean access the shared resource, it will acquire the lock via LockMode.UPGRADE_NOWAIT.
Thus whenever the following error happened , it signal that other md bean instance in different cluster node is accessing. org.hibernate.exception.LockAcquisitionException: could not execute query at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:87) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.doList(Loader.java:2147)
That sounds like a reasonable approach. Generally if you want to control access to something and that something provides it's own locking mechanisms, it's wise to use them. That's what you're doing here.