How do I issue the close() method within an onMessage() method call and what are the semantics of the close() method?

Submitted by: Administrator
If you wish to issue the close() method within an onMessage() method call, the system administrator must select the Allow Close In OnMessage check box when configuring the connection factory. For more information, see JMS Connection Factories in the Administration Console Online Help. If this check box is not selected and you issue the close() method within an onMessage() method call, the call will hang.

The close() method performs the following steps to execute an orderly shutdown:

* Terminates the receipt of all pending messages. Applications may return a message or null if a message was not available at the time of the close.

* Waits until all message listeners that are currently processing messages have completed (except for the message listener from which the close() method is being called).

* Rolls back in-process transactions on its transacted sessions (unless such transactions are part of an external JTA user transaction).

* Does not force an acknowledge of client-acknowledged sessions. By not forcing an acknowledge, no messages are lost for queues and durable subscriptions that require reliable processing.

When you close a connection, all associated objects are also closed. You can continue to use the message objects created or received via the connection, except the received message's acknowledge() method. Closing a closed connection has no effect.
Note: Attempting to acknowledge a received message from a closed connection's session throws an IllegalStateException.
When you close a session, all associated producers and consumers are also closed.
For more information about the impact of the close() method for each object, see the appropriate javax.jms javadoc.
Submitted by: Administrator

Read Online BEA Weblogic Job Interview Questions And Answers