用spring进行多线程Context初始化?
我有一个带有 spring 的传统三层应用程序。我的存储库之一需要 >初始化需要 3 分钟,所以我考虑了一些多线程方法来加速整个过程 - 我认为依赖树中的大多数服务和控制器已经可以启动,因此只有少数必须等待最后一个存储库出现。
有没有最佳实践方法?
I have a traditional 3-tier application with spring. One of my repositories needs > 3 minutes for initialization so I thought about some multi-threaded approach in order to speed up the whole process - I think most service and controllers in my dependency tree can already be started so only a few must wait for the last repository to come up.
Is there any best practice approach?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Spring 的 Executor 抽象。如果您在应用程序服务器中,那么我建议您使用应用程序服务器的工作管理器(spring 支持它)。例如,WebSphere 应用程序服务器和 Weblogic 都支持在 JNDI 中注册工作管理器。然后您可以将 jndi 名称传递给 spring。 任务执行器
Use Spring's Executor abstraction. And if you are within a app server then I suggest you use application server's work-manager (spring supports it). For e.g. WebSphere app server and Weblogic both support registering the workmanagers in JNDI. You can then pass the jndi name to spring. Task Executors