I have a J2EE application which has a EJB module and a web module. For this application, I have some initialization code which should be done at the application startup. I implemented the application Initializer as a web context listener. That is the application is initialized when Jboss initialize the web context. Then the EJB is fine to process request.
However I found out that the EJB module initialization and web module initialization were two parallel processes. The EJB can process client-request before the web context is completed initialized. More specifically, I have a MDB which subscribes a topic durablely. The MDB will use some stuff initialized by web context lsitener. However the message arrives on MDB before the application is initialized.
Is there application-wide initialization mechanism that holds off all client request until the application initialization is finished?
There are a number of ways to do this, but none are portable.
e.g. MBean dependencies.
or Use an MBean to initialise the app
or deploy your MDB with delivery not active and start delivery in your listener
using a JMX invocation on the MDB's invoker