You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by rodih <ro...@gmail.com> on 2008/07/28 08:17:25 UTC
Closing Producers
Hi,
If I define a new producer or consumer as a local variable will it be closed
(Closed + Garbage collected at some point) once the method returns?
Thanks.
--
View this message in context: http://www.nabble.com/Closing-Producers-tp18684689p18684689.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Closing Producers
Posted by Hans Bausewein <ha...@comerwell.xs4all.nl>.
rodih wrote:
>
> Thanks for the quick response. I will take your advice and will close
> resources explicitly.
>
That's generally recommended. You should not rely on the implementation of a
specific JMS provider, anyway. And it's usually not difficult to do.
Follow the J2EE spec. The comments are clear, I think.
http://java.sun.com/j2ee/1.4/docs/api/
If you close the Session, you may assume that the producers are closed by
the JMS provider (ActiveMQ in this case).
(But ActiveMQ 5.1.0 does not in all cases.)
Hans
--
View this message in context: http://www.nabble.com/Closing-Producers-tp18684689p18698801.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Closing Producers
Posted by James Strachan <ja...@gmail.com>.
BTW to avoid having to write all the code to explicitly close things
down you can use the JmsTemplate or MessageListenerContainer helper
classes in the spring framework.
2008/7/28 rodih <ro...@gmail.com>:
>
> Thanks for the quick response. I will take your advice and will close
> resources explicitly.
> BTW, Are connections and session behave the same (are closing resources the
> same as consumers/producers when finalized).
>
> Thanks again.
>
>
> rajdavies wrote:
>>
>>
>> On 28 Jul 2008, at 07:17, rodih wrote:
>>
>>>
>>> Hi,
>>> If I define a new producer or consumer as a local variable will it
>>> be closed
>>> (Closed + Garbage collected at some point) once the method returns?
>>>
>>> Thanks.
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Closing-Producers-tp18684689p18684689.html
>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>>
>>
>> Yes they should be if you use ActiveMQ - however I wouldn't
>> recommend it - as its specific to ActiveMQ (not every JMS client will
>> do the same) - and gc is not very deterministic anyway.
>> It would be better to close them explicitly
>>
>>
>>
>>
>> cheers,
>>
>> Rob
>>
>> http://open.iona.com/products/enterprise-activemq
>> http://rajdavies.blogspot.com/
>>
>>
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Closing-Producers-tp18684689p18688165.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com
Re: Closing Producers
Posted by Rob Davies <ra...@gmail.com>.
Yep - all JMS managed resources (Connection,session,consumer,producer)
behave the same way.
On 28 Jul 2008, at 12:09, rodih wrote:
>
> Thanks for the quick response. I will take your advice and will close
> resources explicitly.
> BTW, Are connections and session behave the same (are closing
> resources the
> same as consumers/producers when finalized).
>
> Thanks again.
>
>
> rajdavies wrote:
>>
>>
>> On 28 Jul 2008, at 07:17, rodih wrote:
>>
>>>
>>> Hi,
>>> If I define a new producer or consumer as a local variable will it
>>> be closed
>>> (Closed + Garbage collected at some point) once the method returns?
>>>
>>> Thanks.
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Closing-Producers-tp18684689p18684689.html
>>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>>
>>
>> Yes they should be if you use ActiveMQ - however I wouldn't
>> recommend it - as its specific to ActiveMQ (not every JMS client
>> will
>> do the same) - and gc is not very deterministic anyway.
>> It would be better to close them explicitly
>>
>>
>>
>>
>> cheers,
>>
>> Rob
>>
>> http://open.iona.com/products/enterprise-activemq
>> http://rajdavies.blogspot.com/
>>
>>
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Closing-Producers-tp18684689p18688165.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Re: Closing Producers
Posted by rodih <ro...@gmail.com>.
Thanks for the quick response. I will take your advice and will close
resources explicitly.
BTW, Are connections and session behave the same (are closing resources the
same as consumers/producers when finalized).
Thanks again.
rajdavies wrote:
>
>
> On 28 Jul 2008, at 07:17, rodih wrote:
>
>>
>> Hi,
>> If I define a new producer or consumer as a local variable will it
>> be closed
>> (Closed + Garbage collected at some point) once the method returns?
>>
>> Thanks.
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Closing-Producers-tp18684689p18684689.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>>
>
> Yes they should be if you use ActiveMQ - however I wouldn't
> recommend it - as its specific to ActiveMQ (not every JMS client will
> do the same) - and gc is not very deterministic anyway.
> It would be better to close them explicitly
>
>
>
>
> cheers,
>
> Rob
>
> http://open.iona.com/products/enterprise-activemq
> http://rajdavies.blogspot.com/
>
>
>
>
>
>
--
View this message in context: http://www.nabble.com/Closing-Producers-tp18684689p18688165.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.
Re: Closing Producers
Posted by Rob Davies <ra...@gmail.com>.
On 28 Jul 2008, at 07:17, rodih wrote:
>
> Hi,
> If I define a new producer or consumer as a local variable will it
> be closed
> (Closed + Garbage collected at some point) once the method returns?
>
> Thanks.
>
> --
> View this message in context: http://www.nabble.com/Closing-Producers-tp18684689p18684689.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Yes they should be if you use ActiveMQ - however I wouldn't
recommend it - as its specific to ActiveMQ (not every JMS client will
do the same) - and gc is not very deterministic anyway.
It would be better to close them explicitly
cheers,
Rob
http://open.iona.com/products/enterprise-activemq
http://rajdavies.blogspot.com/