[ 
https://issues.apache.org/jira/browse/ARTEMIS-4044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17616633#comment-17616633
 ] 

Justin Bertram edited comment on ARTEMIS-4044 at 10/12/22 6:28 PM:
-------------------------------------------------------------------

Yeah, I'm fighting spring boot a little at the moment to get a raw connection 
so I can create exactly the same scenario. My test in my last comment wasn't 
great either, because that's a proxied SingleConnectionFactory connection, with 
sometimes detects the close and creates a new connection even in that little 
test, before we try to create the session.
{noformat}
javax.jms.JMSException: ActiveMQDisconnectedException[errorType=DISCONNECTED 
message=AMQ219015: The connection was disconnected because of server shutdown]
    at 
org.apache.activemq.artemis.jms.client.ActiveMQConnection$JMSFailureListener.connectionFailed(ActiveMQConnection.java:714)
 ~[artemis-jms-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.jms.client.ActiveMQConnection$JMSFailureListener.connectionFailed(ActiveMQConnection.java:735)
 ~[artemis-jms-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl.callSessionFailureListeners(ClientSessionFactoryImpl.java:767)
 ~[artemis-core-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl.failoverOrReconnect(ClientSessionFactoryImpl.java:702)
 ~[artemis-core-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl.handleConnectionFailure(ClientSessionFactoryImpl.java:537)
 ~[artemis-core-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl$DelegatingFailureListener.connectionFailed(ClientSessionFactoryImpl.java:1299)
 ~[artemis-core-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.spi.core.protocol.AbstractRemotingConnection.callFailureListeners(AbstractRemotingConnection.java:78)
 ~[artemis-core-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.core.protocol.core.impl.RemotingConnectionImpl.fail(RemotingConnectionImpl.java:222)
 ~[artemis-core-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl$CloseRunnable.run(ClientSessionFactoryImpl.java:1073)
 ~[artemis-core-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.utils.actors.OrderedExecutor.doTask(OrderedExecutor.java:42)
 ~[artemis-commons-2.21.0.jar:na]
    at 
org.apache.activemq.artemis.utils.actors.OrderedExecutor.doTask(OrderedExecutor.java:31)
 ~[artemis-commons-2.21.0.jar:na]
    at 
org.apache.activemq.artemis.utils.actors.ProcessorBase.executePendingTasks(ProcessorBase.java:65)
 ~[artemis-commons-2.21.0.jar:na]
    at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
 ~[na:na]
    at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
 ~[na:na]
    at 
org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118)
 ~[artemis-commons-2.21.0.jar:na]
Caused by: org.apache.activemq.artemis.api.core.ActiveMQDisconnectedException: 
AMQ219015: The connection was disconnected because of server shutdown
    ... 7 common frames omitted{noformat}


was (Author: sebaker):
Yeah, I'm fighting spring boot a little at the moment to get a raw connection 
so I can create exactly the same scenario. My test in my last comment wasn't 
great either, because that's a proxied SingleConnectionFactory connection, with 
sometimes detects the close and creates a new connection even in that little 
test, before we try to create the session.

 
{code:java}
javax.jms.JMSException: ActiveMQDisconnectedException[errorType=DISCONNECTED 
message=AMQ219015: The connection was disconnected because of server shutdown]
    at 
org.apache.activemq.artemis.jms.client.ActiveMQConnection$JMSFailureListener.connectionFailed(ActiveMQConnection.java:714)
 ~[artemis-jms-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.jms.client.ActiveMQConnection$JMSFailureListener.connectionFailed(ActiveMQConnection.java:735)
 ~[artemis-jms-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl.callSessionFailureListeners(ClientSessionFactoryImpl.java:767)
 ~[artemis-core-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl.failoverOrReconnect(ClientSessionFactoryImpl.java:702)
 ~[artemis-core-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl.handleConnectionFailure(ClientSessionFactoryImpl.java:537)
 ~[artemis-core-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl$DelegatingFailureListener.connectionFailed(ClientSessionFactoryImpl.java:1299)
 ~[artemis-core-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.spi.core.protocol.AbstractRemotingConnection.callFailureListeners(AbstractRemotingConnection.java:78)
 ~[artemis-core-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.core.protocol.core.impl.RemotingConnectionImpl.fail(RemotingConnectionImpl.java:222)
 ~[artemis-core-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl$CloseRunnable.run(ClientSessionFactoryImpl.java:1073)
 ~[artemis-core-client-2.21.0.jar:2.21.0]
    at 
org.apache.activemq.artemis.utils.actors.OrderedExecutor.doTask(OrderedExecutor.java:42)
 ~[artemis-commons-2.21.0.jar:na]
    at 
org.apache.activemq.artemis.utils.actors.OrderedExecutor.doTask(OrderedExecutor.java:31)
 ~[artemis-commons-2.21.0.jar:na]
    at 
org.apache.activemq.artemis.utils.actors.ProcessorBase.executePendingTasks(ProcessorBase.java:65)
 ~[artemis-commons-2.21.0.jar:na]
    at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
 ~[na:na]
    at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
 ~[na:na]
    at 
org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118)
 ~[artemis-commons-2.21.0.jar:na]
Caused by: org.apache.activemq.artemis.api.core.ActiveMQDisconnectedException: 
AMQ219015: The connection was disconnected because of server shutdown
    ... 7 common frames omitted
 
{code}

> 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)

Reply via email to