step by step Sample JMS in Spring Framework [closed]

自闭症网瘾萝莉.ら 提交于 2020-01-01 03:04:06

问题


JMS using in spring, how to config and what type of dependency to use


回答1:


There are some caveats with Spring JMS.

  1. You absolutely must not use Spring JMS directly on a JMS connection factory. This is because Spring - particularly JmsTemplate - opens a connection, uses it for one message, then closes it. This is the correct pattern to use when the connection factory is, in fact, a connection pool. But if it is really just a connection factory, you're going to slaughter the server under load. This is normally only an issue when you're running a standalone application rather than inside of a J2EE container, which typically has resource adapters or other things that do pooling for you. Spring does supply a SingleConnectionFactory bean that will reuse a connection, but this is not the best solution when you're using a clustered server and want to load balance your connections and work.
  2. The Spring APIs are all designed around processing single messages at a time. In some cases, where you may be able to deal with a batch of messages, it may be preferable to use Spring to provide you with the connection factories and such, but roll your own code to actually do the message I/O. That way, you can, for example, set up a transacted session, process 100 messages, then commit the acknowledgment as a batch. That should reduce the workload on the server, assuming you can do so safely.



回答2:


You could check out Spring in Action. It has a chapter about messaging using JMS from Spring which I found helpful.



来源:https://stackoverflow.com/questions/793042/step-by-step-sample-jms-in-spring-framework

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