Active PooledConnectionFactory pooling Connections vs Sessions

一曲冷凌霜 提交于 2019-12-08 01:26:48

问题


I'm looking at using PooledConnectionFactory in a Tomcat application, where in a Tomcat POST handler I want to drop a message into a queue to be picked up by a single remote consumer. AMQ pools both Connection and Session objects, and I'm trying to understand when I should use one over the other.

The approach I'm considering is to have a single Connection and set MaximumActiveSessionPerConnection to match my Tomcat threads, and the POST handler would borrow and return Sessions from the connection. Does this sound reasonable, or are there are advantages to pooling Connections instead?

If it matters, I'm not using Spring or other web app frameworks, just Tomcat. I'm persisting messages to disk in AMQ.


回答1:


Both approaches should be functionally equivalent, and the difference in the code to do one vs. the other should be relatively small.

In terms of performance I don't think it will really matter as your bottleneck will be on the consuming side not on the producing side since you have a single consumer and potentially many concurrent producers.

Personally, I would prefer letting the pool do all the work and just writing the application as if it is creating a connection and session every time it sends a message (which would obviously be a huge anti-pattern without a pool).



来源:https://stackoverflow.com/questions/52262882/active-pooledconnectionfactory-pooling-connections-vs-sessions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!