简体   繁体   中英

Does ActiveMQManagedConnection (EAP/AMQ) support Autoclosable?

I am using:

  • openshift
    • AMQ (seems to be a forked activemq-5.11.0.redhat...... version)
  • EAP 7.2.3
  • While local debugging I get as Connection some ~ConnectionProxy with a physical ActiveMQManagedConnection

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

https://github.com/apache/activemq/blob/activemq-5.11.0/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQManagedConnection.java#L53

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM