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?
Timed out after waiting 5,000 ms for response when sending packet 45 [code=CONNECTION_TIMEDOUT]and then I suppose it has no longer a connection with the broker (or the broker closes it). Then the second time it is called as I can now understand it tries to acquire a new one and it fails after it expires the connection timeout set and not immediately after 5sec as I had set on ConnectionFactory callTimeout (still no network available). Is that a correct assumption? - ypanag