[
https://issues.apache.org/jira/browse/ARTEMIS-5169?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
mcwolf resolved ARTEMIS-5169.
-----------------------------
Resolution: Fixed
Setting *callTimeout* and *callFailoverTimeout* solves the problem
{code:java}
connectionFactory.ConnectionFactory=tcp://192.168.0.1:1883?retryInterval=200&reconnectAttempts=-1&callTimeout=5000&callFailoverTimeout=5000
{code}
> Closing JMSContext on failed connection with reconnectAttempts = -1
> -------------------------------------------------------------------
>
> Key: ARTEMIS-5169
> URL: https://issues.apache.org/jira/browse/ARTEMIS-5169
> Project: ActiveMQ Artemis
> Issue Type: Bug
> Affects Versions: 2.31.0, 2.38.0
> Environment:
> java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
> connectionFactory.ConnectionFactory=tcp://192.168.0.1:1883?retryInterval=200&reconnectAttempts=-1
> Reporter: mcwolf
> Priority: Major
>
> I have a Java SE application (jms client) that works with Artemis ActiveMQ.
> In the {{ActiveMQInitialContextFactory}} configuration, I have set
> {{reconnectAttempts}} = {{-1}} so that, when the connection to the server is
> dropped, the connection is automatically reestablished.
> Everything works fine and the connection is restored as expected. However, I
> noticed that when I try to call {{JMSContext::stop()}} /
> {{JMSContext::close()}} while the connection is broken (i.e., the client is
> in reconnect mode), the call blocks until the client manages to connect.
> If I stop the application without calling {{JMSContext::stop()}} /
> {{JMSContext::close()}} when the connection is broken, it stops cleanly
> (apparently the implementation uses daemon threads) but this approach does
> not work for me, the service is used in a dialog and I want to release the
> occupied resources when it is closed.
> {code:java}
> ConnectionFactory cf = (ConnectionFactory)
> initialContext.lookup("ConnectionFactory");
> JMSContext jmsContext = cf.createContext();
> jmsContext.setExceptionListener(this::handleJMSException);
> Topic topic = jmsContext.createTopic("topicName");
> jmsContext.createConsumer(topic).setMessageListener(this::onMessage);
> ...
> setOnCloseRequest(dialogEvent -> {
> if(jmsContext != null) {
> jmsContext.close();
> }
> });
> {code}
> artemis-jms-client: 2.31.0 and 2.38.0
> OS: Ubuntu 24.04.1 LTS
> Java: OpenJDK 64-Bit Server VM (build 20.0.1+9-29, mixed mode, sharing)
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact