Lifecycle of MQ Connection in JSF - Connection Closed

不问归期 提交于 2019-12-11 06:00:40

问题


I use JSF 2 an WebSphere MQ for Messaging (JMS).

I want to know what's the best practice to open / close the QueueConnection? Should I use for each client session one connection and open it on (post-)construction and close it on (pre-) destruction like here?

Or are there better ways to handle the connection? E.g. "Open EntityManager in View" Pattern for JDBC/JPA?


回答1:


Avoid creating a new connection for each getMessage() invocation. Create one connection at construct time, save it as an instance variable.

For each getMessage() call, create a new session, get the message, then close the session.

When you're done, close the connection at destruction time.



来源:https://stackoverflow.com/questions/19442196/lifecycle-of-mq-connection-in-jsf-connection-closed

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