Hi All,
I've been encountering socket leaks in JBoss 2.4.6 when running code similar
to the following to send JMS messages to topics on which Message Driven Beans
are listening.
public static void sendLogItem(int type, String message) {
TopicPublisher publisher = null;
TopicConnection connection = null;
TopicSession session = null;
try {
InitialContext jndiContext = new InitialContext();
Topic topic = (Topic)jndiContext.lookup("topic/logEventTopic");
TopicConnectionFactory factory =
(TopicConnectionFactory)jndiContext.lookup("TopicConnectionFactory");
connection = factory.createTopicConnection();
session = connection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
publisher = session.createPublisher(topic);
LogData evt = new LogData();
evt.setMessage(message);
evt.setType(type);
ObjectMessage msg = session.createObjectMessage(evt);
publisher.publish(msg);
} catch (Throwable ex) {
} finally {
if (publisher != null) {
try {
publisher.close();
} catch (Throwable discard) {}
}
if (session != null) {
try {
session.close();
} catch (Throwable discard) {}
}
if (connection != null) {
try {
connection.close();
} catch (Throwable discard) {}
}
}
}
As shown, I've tried to be careful to close anything that might need closing,
but I'm probably missing something here, since after numerous calls to this
method, a number of unclosed sockets will accumulate until no more sockets
can be allocated by my program. What am I doing wrong here?
Thanks in advance.
-Neal
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user