[ https://issues.apache.org/jira/browse/ARTEMIS-4044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17616630#comment-17616630 ]
Justin Bertram commented on ARTEMIS-4044: ----------------------------------------- bq. ...it is periodically failing to obtain a connection AFTER the server has finished starting. Based on [^failure.log] this is not quite accurate. The problem is actually that Spring's {{JmsTemplate}} is unable to create a JMS session on a connection that has already been closed. It's not actually trying to obtain a connection per se. This is a subtle but important difference because it indicates a different failure mode than the one seen in either [^success.log] or [^success_2_19_1.log]. In [^success.log] there's no failure at all, and in [^success_2_19_1.log] the failure happens when Spring's {{JmsTransactionManager}} attempts to create a connection. However, in [^failure.log] we see that the failure happens when {{JmsTemplate}} tries to invoke {{javax.jms.Session.createQueue()}}. It may be that you'd see the same inability to create a session once the broker was restarted even in previous versions if you saw this same failure mode. > AMQ219010: Connection is destroyed with embedded artemis in tests > ----------------------------------------------------------------- > > Key: ARTEMIS-4044 > URL: https://issues.apache.org/jira/browse/ARTEMIS-4044 > Project: ActiveMQ Artemis > Issue Type: Bug > Environment: MacOS 12.6 > Corretto JDK 11 > Spring Boot 2.7.4 > artemis.version set to 2.26.0 > Reporter: Stephen Baker > Priority: Minor > Attachments: failure.log, success.log, success_2_19_1.log > > > I have a unit test for verifying a listener routine I wrote in the event of > an Artemis failure. > With artemis-server 2.25.0 and 2.26.0 it is periodically failing to obtain a > connection AFTER the server has finished starting. > {code:java} > @Test > void receiveBatchesTest_resilientToJmsFailure() throws Exception { > var receiveCount = new AtomicInteger(0); > BatchingJmsListenerDefinition<String> listener = > BatchingJmsListenerDefinition.builder(String.class) > .concurrency(1) > .maxBatchSize(10) > .destination("TestQueue") > .jmsTemplate(jmsTemplate) > .target(s -> receiveCount.addAndGet(s.size())) > .receiveTimeout(Duration.ofSeconds(1)) > .errorPauseTime(Duration.ofMillis(1)) > .build(); > embeddedActiveMQ.stop(); > registry.registerListener(listener, true); > await().atLeast(Duration.ofMillis(1000)); > embeddedActiveMQ.start(); > jmsTemplate.convertAndSend("TestQueue", "message1"); > jmsTemplate.convertAndSend("TestQueue", "message2"); > await().atMost(5, TimeUnit.SECONDS).until(() -> receiveCount.get() == 2); > }{code} > * [^failure.log] > * [^success.log] > * [^success_2_19_1.log] > When {{registerListener}} is called we expect a connection failure and on > 2.19.1 we get one there "AMQ219007: Cannot connect to server(s). Tried with > all available servers." but it should catch and try again until the server > comes up, and then when we write to the queue after the server is up we > definitely expect the connection to work, but as can be seen in the > [^failure.log] we are getting: > {noformat} > ActiveMQNotConnectedException[errorType=NOT_CONNECTED message=AMQ219010: > Connection is destroyed{noformat} > Line 117 is the first {{jmsTemplate.convertAndSend}}. -- This message was sent by Atlassian Jira (v8.20.10#820010)