This content has been marked as final. Show 5 replies
1002099 wrote:You should close a connection when you have no further use for it as this will release resources.
+"When an application completes, you need to close any connections that you have created. Failure to close a connection can cause resources not to be released by the JMS provider. Closing a connection also closes its sessions and their message producers and message consumers.+
+Before your application can consume messages, you must call the connection's start method; for details, see Section 3.5, "Message Consumers." If you want to stop message delivery temporarily without closing the connection, you call the stop method."+
Should I close the connection as the last paragraph say?. If so, I don't know how to do it without lose the service, because if I call "close" method on the connection and immediatelyi start it, i will lose all my consumers and producers for a little time.
You must start a connection if you want to receive messages from it.
Most applications don't use stop(). However if your application needs to temporarily pause delivery of messages (to the application) for some reason, call stop(). When your application wants delivery of messages (to the application) to restart, call start() again.
Thanks for your reply Nigel,
Now I understand the use of stop and start methods. However, I'm still confused with close method. In my application, i'm using one connection for create different sessions, consumers and producers. All of them, are working constantly, because we can't stop the service (and the message activity it's generous). I suppose that my memory leaks comes from the detail that you say about the resources and their releases. Now my question is: How can I close my connection (using "close" method, or similar that release resources), without stopping my activity, for release all the resources that makes me leak memory?.
Thanks a lot
I don't think that closing the connection is really the answer since you obviously are not done with it until you shut down your entire service.
The real question is: why are those resources you found through profiling sticking around in memory? That probably cannot be answered in the general sense - JMS is only an API, you are using a particular implementation of that API and the problem may reside within that implementation. You mentioned that you found the memory usage in specific classes - which ones exactly?
Absolutely agree with you. My suspicions are more oriented to the implementation I'm using (ActiveMQ - classes that I'm detected has activemq signature), and of course, from bad use that I'm taking in my SW.
I'm coming to this forum, searching recommendations (and experiences) of best practices for 24x7 applications that use JMS as communication method, and trying to find the answer to my problem.
After I noticed the API fragment, that I pasted before in relation with the "close" method on the connection specification, I would like to know, if these acumulated resources (that i'm detecting profiling my application with an specific implementation), will be release, if I'm close the connection at any moment.
I would still direct your questions to an ActiveMQ forum or mailing list if I were you. At least in such a place you reach a large pool of people who actually use the technology. The website lists plenty of resources where you can ask for help, such as: