adspace
How do I issue the close() method within an onmessage() method call and what are the semantics of the close() method? : BEA Weblogic
Answer Posted / Jaideep Shrivastava
To issue the close() method within an onmessage() method call in a Message Driven Bean (MDB) in WebLogic, you can use a finally block to ensure that the connection is closed even if an exception occurs. Here's a simplified example:n```javanpublic void onMessage(Message message) {n try ({n Connection connection = message.getJMSConnection();n Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);n // Process the message heren }n finally {n if (connection != null) {n try {
connection.close();
} catch (JMSException e) {
// handle exception
}n }n })n```nThe close() method in JMS is used to release the resources associated with a Connection or Session object, including the physical connection to the JMS provider. This can help to reduce resource consumption and prevent leaks.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
No New Questions to Answer in this Category !! You can
Post New Questions
Answer Questions in Different Category