users@jms-spec.java.net

[jms-spec users] [jsr343-experts] Re: Re: Make TemporaryQueue/Topic AutoCloseable?

From: Nigel Deakin <nigel.deakin_at_oracle.com>
Date: Fri, 04 Jan 2013 10:35:46 +0000

On 03/01/2013 22:21, Philippe Marschall wrote:
>
>
> On 03.01.2013 17:58, Nigel Deakin wrote:
>> Philippe,
>>
>> On 02/01/2013 16:29, Philippe Marschall wrote:
>>> I wanted to ask whether it would make sense to make TemporaryQueue and
>>> TemporaryTopic implement AutoCloseable so that they can be used in a
>>> try-with-resources block?
>>
>> Thanks for your comment.
>>
>> TemporaryQueue and TemporaryTopic don't have a close method. A temporary
>> queue or topic will be automatically deleted when the Connection (or
>> JMSContext) used to create it is closed.
>>
>> Are you proposing that we add a close method to TemporaryQueue and
>> TemporaryTopic which causes the temporary queue or topic to be deleted?
>
> Yes, more or less. That would allow a TemporaryQueue/TemporaryTopic to
> be used in a create/use/delete pattern with language support. Thinking
> about it I'm not so sure anymore. Maybe I just want to use
> try-with-resources wherever I can.

OK. So you're asking for new methods TemporaryQueue.close() and
TemporaryTopic.close(), where "close" actually means "delete".

Can you say more about the use case where this might be useful? I don't
want to guess, but it sounds like you want to create large numbers of
temporary destinations using the same connection.

(It will always be more efficient to reuse the same temporary
destination for multiple consecutive multiple request/reply operations.
If you create a new temporary destination every time you will incur the
overhead of creating the temporary destination and creating a consumer
on it multiple times)

Thanks,

Nigel