Reputation: 291
I am trying to introduce a timeout on my producer when sending messages to ActiveMQ Artemis broker 2.17.0. I use the following code for this purpose
@Bean
public ConnectionFactory jmsConnectionFactoryOnline() {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerUrl,username,password);
connectionFactory.setCallTimeout(5000);
return connectionFactory;
}
@Bean
public JmsPoolConnectionFactory pooledConnectionFactory() {
JmsPoolConnectionFactory poolingFactory = new JmsPoolConnectionFactory();
poolingFactory.setConnectionFactory(jmsConnectionFactoryOnline());
poolingFactory.setMaxConnections(MAX_CONNECTIONS);
poolingFactory.setMaxSessionsPerConnection(MAX_SESSIONS_PER_CONNECTION);
poolingFactory.setConnectionIdleTimeout(0);
return poolingFactory;
}
When I simulate losing network on the ActiveMQ Artemis node using iptables -A INPUT -s ip_producer -j DROP
I can see on producer side that current connections honor the timeout of 5sec initially set.
Unfortunately following requests (new connections) seem to ignore it since I can observe producer waiting for the next calls up to Connection timeout interval (60sec) before declaring the request broken.
Can you guide me how to resolve this, or point to me what am I doing wrong and I cannot set a timeout on my producer?
Upvotes: 1
Views: 1550
Reputation: 2309
The ConnectionTTL
attribute of ActiveMQConnectionFactory
determines how long a connection will be keep alive in the absence of any data arriving and its default value is 60 seconds.
Seting the ConnectionTTL
attribute with a value lower than 60000 will reduce the connection timeout.
Upvotes: 0