Active PooledConnectionFactory池连接与会话 [英] Active PooledConnectionFactory pooling Connections vs Sessions

查看:177
本文介绍了Active PooledConnectionFactory池连接与会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑在Tomcat应用程序中使用PooledConnectionFactory,在Tomcat POST处理程序中,我想将消息放入队列中以供单个远程消费者选择。 AMQ汇集了Connection和Session对象,我试图了解何时应该使用其中一个。

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.

我正在考虑的方法是使用一个连接并设置MaximumActiveSessionPerConnection以匹配我的Tomcat线程,POST处理程序将从连接借用并返回Sessions。这听起来是否合理,或者汇集连接是否有优势?

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?

如果重要,我不会使用Spring或其他Web应用程序框架,只使用Tomcat。我在AMQ中将消息保存到磁盘。

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

推荐答案

两种方法都应该在功能上等同,并且代码的区别在于一个与另一个应该相对较小。

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).

这篇关于Active PooledConnectionFactory池连接与会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆