Hi,
I've been desperately looking for a proper solution for weeks now, but haven't been able to find anything proper.
Our use case is the following: in our existing system, a handful of components communicate over ActiveMQ, using Camel and JMS. In the planned next version, the company-wise used stack contains RabbitMQ as the message broker, so our current task is to migrate existing applications to this new environment.
During prototyping, it occurred to us that the performance of one of our tests that puts a heavy load on the broker runs significantly slower, which obviously led us to the topic of connection factories and caching connections, sessions and producers. Measurements showed that with no caching at all and caching of connections, sessions and producers there is considerable time difference (with everything cached, the total time for the test is six times less then without caching).
Our Camel routes use implicitly the Spring JmsTemplate, which would definitely need a caching ConnectionFactory. However, there seems to be no solution out of the box. I have tried:
- integrating org.messaginghub's PooledJMS library(
https://mvnrepository.com/artifact/org.messaginghub/pooled-jms
). It caches the connection, but leaks channels because of RMQSession.setMessageListener throwing an UnsupportedOperationException runtime exception which is then not properly handled by the code
if (!(dest instanceof TemporaryQueue || dest instanceof TemporaryTopic)) {
return getCachedProducer(dest);
}
and RMQDestination implementing everything:
public class RMQDestination implements Queue, Topic, Destination, Referenceable, Serializable, TemporaryQueue, TemporaryTopic
- in the suggestion above, the destination was manually created in beans.xml
<bean id="jmsDestination" class="com.rabbitmq.jms.admin.RMQDestination" >
<constructor-arg value="spring-integration" />
<constructor-arg value="false" />
<constructor-arg value="false" />
</bean>
which is an option, but it needs refactoring (not to mention how we would go about a possible connection failover), I would like to have something more transparent.
And I'm puzzled. I thought that it is a completely relevant use-case, and still, there seem to be no proper solution in sight, or at least I haven't been able to find it. I'm assuming that yes, one way would be to migrate to pure AMQP/RabbitMQ, but, nevertheless, I don't want to believe that there are no established best practices already for this use case.
Have I missed something obvious?
(In case it is of interest, I used Camel version 3.18 and the RabbitMQ JMS Client is version 2.8.0)
Thanks,
Matyas