Should I use just one Session in my application based on HornetQ?

♀尐吖头ヾ 提交于 2019-12-01 09:31:52

The best rule of thumb for minimum resource usage is to use the fewest constructs as possible while remaining thread safe. Accordingly:

  1. Connection Factories are thread safe: One per JMS server (or one per JMS server per destination type for topics and queues)
  2. Connections are thread safe: Depending on the application architecture, you may be able to use one connection, but I would not bend over backwards to do this.
  3. Sessions and all constructs below the session are NOT thread safe: You will need one session per concurrent thread (or per transaction if you think about it that way).

Based on that, hopefully you can strike a balance between an elegant architecture and low resource utilization.

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