The @DependsOn annotation only works for other @Singleton beans. Definitely use CONTAINER concurrency. Understand that this code is just a plain jvm ReentrantReadWriteLock under the covers. It would be hard to do much better.
- http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/ReentrantReadWriteLock.html All methods annotated with an @Lock(READ) acquire a read lock. All methods annotated with @Lock(WRITE) acquire a write lock. That said, if you're already doing the configuration initialization in the @PostConstruct of the @Singleton, this issue shouldn't exist. Can you paste the stacktrace of your NPE? -- David Blevins http://twitter.com/dblevins http://www.tomitribe.com On Mar 7, 2015, at 3:51 AM, Matej <[email protected]> wrote: > Hi everybody. > > We have an annoying problem on our production system. We have an > Configuration Singleton which reads config things from DB. Then in one MDB > we inject this Singleton to control operation based on configs. Our problem > is that the system is quite heavely loadded and while the system startups > already MDB recievs onMessage events while the Singleton still initliazes. > Which produces some NPEs and system doesn't boot. > > The depneds on annotation seems not to help. We are doing BEAN conncurency > management could this be the issue? And the Singleton has an Postconstruct > annotation. > > Anyone has any pattern or tips how to handle this type of scenario. > > BR > > Matej
