(设计思路)唤醒多进程做工作流的最佳实践
我正在设计多流程工作流引擎。我在 Websphere 上部署了 4 个服务,并找到了如何唤醒它们的方法。目前的解决方案是
Quartz每分钟唤醒1个进程,如果最后一个进程已经在运行,则该进程不会重复运行(使用java的静态变量来控制)。
2 处理查询最大至200条记录。
2 进程将创建最多 50 个并发线程来处理作业。
3 处理 sleep 5 秒并检查是否有空闲座位来处理更多。
4 如果没有记录要处理,进程将获取下200条记录的数据
5 如果没有数据,进程将结束,等待quartz稍后唤醒
你觉得怎么样?你还有其他想法吗?
I 'm designing multiple process workflow engine. I deploy 4 services on Websphere and finding idea how to wake up them. Current solution is
1 Quartz will wake up process every minute , if last process already running, this process will not run duplicate ( use java's static variable to control) .
2 Process query maximum to 200 record.
2 Process will create concurrence thread maximum to 50 to process job.
3 Process sleep 5 second and check if there are free seat to process more.
4 If there are no record to process, process will fetch data next 200 record
5 if there are no data , process will end , wait quartz to wake up later
What you think about it ? Do you have other idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定您的系统与工作流程有何关系。术语“工作流”通常表示系统正在管理需要人工输入的任务。您正在描述一个简单的处理引擎,它从数据库表中获取工作。对于此类工作,它可能会正常工作,但并不是真正的“最佳实践”。
我建议进行两项更改。
您的应用程序应该有一个内部线程池来处理作业。没有必要创建一个新线程来处理每个作业。使线程池可配置,以便您可以快速轻松地增加或减少其大小。
您的应用程序应该有一个队列接口(例如JMS)来接收作业而不是重复读取数据库表。
I'm not sure how your system relates to workflow. The term 'Workflow' generally indicates that a system is managing tasks that require human input. You are describing a simple processing engine that takes its work from a database table. For that kind of work it will probably work OK, but isn't really 'best practice'.
I would suggest two changes.
Your application should have an internal thread pool to process jobs. Creating a new thread to process each job isn't necessary. Make the thread pool configurable so you can increase or decrease its size quickly and easily.
Your application should have a queue interface (eg JMS) to receive jobs rather than repeatedly reading a database table.
“最佳实践”一词经常被用作不思考事情的借口。
但我想说,任何涉及睡眠几秒钟的解决方案都不是最佳实践。
The phrase "best practice" is often used as an excuse for not thinking about things.
But I'd say that any solution involving sleeping for a number of seconds is not best practice.