Why JMSProducer interface does not extend java.lang.Autocloseable?

1.3k Views Asked by At

As per the JMS specs for classic APIs

The Connection, Session, MessageProducer, MessageConsumer and
QueueBrowser interfaces have been modified to extend the
java.lang.Autocloseable interface. This means that applications can
create these objects using a Java SE 7 try-with-resources statement which
removes the need for applications to explicitly call close() when these
objects are no longer required.

And after JMS2 for classic APIs

The new JMSContext and JMSConsumer interfaces also extend the
java.lang.Autocloseable interface.

Question is why JMSProducer not extend AutoCloseable?

1

There are 1 best solutions below

0
On BEST ANSWER

last paragraph from javadoc of JMSProducer

Instances of JMSProducer are intended to be lightweight objects which can be created freely and which do not consume significant resources. This interface therefore does not provide a close method.

yes it is confusing, but note that MessageProducer does implement Autocloseable, but JMSProducer does not.