The MDB lifecycle is similar to the stateless session bean lifecycle. The following state diagram shows the MDB's lifecycle:
There are just two MDB lifecycle states: does-not-exist and method-ready pool. The initial state of an MDB is the does-not-exist state. This would be the case before a container starts up. The next state is the method-ready pool. When the container starts up it typically creates a number of MDB instances in the method-ready pool. However, the container can decide at any time to create such instances. In creating an instance in the method-ready pool, the container performs the following steps:
1. The MDB is instantiated.
2. The container injects the bean's
MessageDrivenContext
, if applicable.3. The container performs any other dependency injection that is specified in the bean's metadata.
4. The container invokes a
PostConstruct
callback method if one is present in the bean. ThePostConstruct
method would be used for initializing any resources used by the...