I am experimenting with a PooledConnectionFactory in ActiveMQ (5.12.1) - but I don't see any performance gain (even worse: using PooledConnectionFactory is slower than ActiveMQConnectionFactory).
What I do: Sending a few 100.000 messages in several threads (using CompletableFuture). One run with a ActiveMQConnectionFactory, the other with PooledConnectionFactory:
1st Run:
ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:61616");
Connection connection = cf.createConnection();
connection.start();a
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer(null);
final Topic topic = session.createTopic(topicName);
final ObjectMessage message = session.createObjectMessage(myObject);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
producer.send(topic, message);
2nd Run:
PooledConnectionFactory pcf = new PooledConnectionFactory("tcp://localhost:61616");
pcf.setMaxConnections(8);
Connection connection = pcf.createConnection();
connection.start();
...
More details:
My test application creates 250 MessageProducers, each one running in its own thread.
Connection/Session/MessageProducer are only created once - and never closed.
Messages are sent in a loop per thread, as fast as possible.
I don't see why a PooledConnectionFactory (connections > 1) does not result in an increased number of messages/second - compared to a non-PooledConnectionFactory (connections == 1).
Am I setting up the PooledConnectionFactory the wrong way? Am I missing something?