Java Reference
In-Depth Information
Figure 4.8. The MDB lifecycle has three states: doesn't exist, idle, and busy. There are only two lifecycle callbacks
corresponding to bean creation and destruction; you can use
PostConstruct
and
PreDestroy
to receive these
callbacks.
• Creates MDB instances.
• Injects resources, including the message-driven context (discussed in
chapter 5
in
detail).
• Places instances in a managed pool (if the container supports pooling; if pooling
isn't supported, new instances are created when needed).
• Pulls an idle bean out of the pool when a message arrives (the container may have
to increase the pool size at this point).
• Executes the message listener method—for example, the
onMessage
method.