I have created a simple Kotlin app: fun main() { val artemisData = Paths.get("target/artemis").also { Files.createDirectories(it) }
val config = ConfigurationImpl().apply { isPersistenceEnabled = true journalDirectory = artemisData.resolve("journal").toString() bindingsDirectory = artemisData.resolve("bindings").toString() largeMessagesDirectory = artemisData.resolve("large-messages").toString() pagingDirectory = artemisData.resolve("paging").toString() addQueueConfiguration( CoreQueueConfiguration() .setName("taskProcess") .setAddress("taskProcess") .setRoutingType(RoutingType.ANYCAST) ) addAddressesSetting("#", AddressSettings().apply { isAutoCreateAddresses = true isAutoCreateQueues = true defaultAddressRoutingType = RoutingType.ANYCAST deadLetterAddress = "DLQ".simple() }) isSecurityEnabled = false isGracefulShutdownEnabled = false addAcceptorConfiguration("invm", "vm://0") } val server = ActiveMQServers.newActiveMQServer(config) try { server.start() ActiveMQClient.createServerLocator(false, TransportConfiguration(InVMConnectorFactory::class.java.name)).use { locator -> val sf = locator.createSessionFactory() sf.use { factory -> /* factory.createSession().use { session -> session.createConsumer("taskProcess").use { consumer -> while (true) { val msgReceived = consumer.receive(1000L) ?: break println("message = " + msgReceived.bodyBuffer.readString()) } } } */ } println("sesion factory closed") } } finally { server.stop() println("server stopped") } } server stopped Mar 09, 2020 9:41:27 AM org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl stop INFO: AMQ221002: Apache ActiveMQ Artemis Message Broker version 2.11.0 [c391f658-61e1-11ea-9910-34e6d7649e27] stopped, uptime 2.331 seconds The app runs, and terminates properly but ... you have to wait additional 1 min 5s for the java process to terminate. It hangs on java.lang.ref.Reference#waitForReferencePendingList If you do not create the session factory - the termination is immediate. What am I doing wrong? As you see all resources use try-with-resources and are properly closed. -- Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html