I am using:
Can I use "try-with-resources"?
I am not sure and think no ... because ActiveMQManagedConnection 5.11.0 (I dont know what redhat has changed) doesnt implement Autoclosable. Neither does the implemented javax.resource.spi.ManagedConnection
I havent found the source of this EAP ConnectionProxy. Maybe it has Autoclosable.
If you're using Red Hat AMQ 6 on OpenShift (which is based on ActiveMQ 5.x) then you're stuck on JMS 1.1. The javax.jms.Connection
in JMS 1.1 doesn't extend java.lang.AutoCloseable
. Red Hat AMQ 7 (based on ActiveMQ Artemis) implements JMS 2 and the javax.jms.Connection
in JMS 2 does extend java.lang.AutoCloseable
.
Red Hat JBoss EAP 7.2.3 ships with ActiveMQ Artemis so if you're using that (along with its JCA resource adapter) then you can use try-with-resources. However, if you've configured a JCA resource adapter for integration with a broker based on ActiveMQ 5.x then you can't.