A container is loosely referred to an application server in this article. The functions performed by a container mentioned below includes those done by a resource adapter and messaging provider.
When a MDB is deployed in a container, the container located two JMS resources that each MDB must be associated with.
- The ConnectionFactory that the container uses to create a connection to the messaging server.
- The Destination that the MDB is interested in receiving messages from the messaging server.
The container constructs a MDB instance with the following sequence.
- Invokes the MDB class'es newInstance() method to obtain a new instance.
- Injects resources to the instance,if any. For example, injects MessageDrivenContext if declared.
- Invokes the PostConstruct method, if any.
- Get an available MDB instance (or create a new one if none is available) from the instance pool.
- Allocate a thread from the thread pool (to execute the MDB instance).
- Start the allocated thread to deliver the message with the following sequence.
- Start a new transaction if the MDB uses a container-managed transaction (default).
- Invoke the onMessage(Message m) method.
- Acknowledge/commit the transaction when onMessage() returns.
- Return the current thread and MDB instance back to their own pools.
The container calls an MDB instance's PreDestroy method, if any, before it destroys the instance.
No comments:
Post a Comment