[英]How manage heavy task under Java/Spring?
I have a dashboard where users can do modification to their customers datas. 我有一个仪表板,用户可以在其中修改客户数据。 Some modifications needs heavy processing on all those customers.
一些修改需要对所有这些客户进行大量处理。 I don't want to block my user waiting that the task finished so how can I manage this in background?
我不想阻止我的用户等待任务完成,所以如何在后台管理?
I saw Spring Batch but I'm not sure it's the good answer. 我看到了Spring Batch,但我不确定这是不是很好的答案。 Is there anything else?
还有别的事吗?
Thanks in advance for your help. 在此先感谢您的帮助。
请参阅(google) @Async和/或Spring AMQP / JMS
It is not a Spring specific feature, but if you work under a commercial java application server (say websphere, weblogic), you will have some implementation of workmanagers. 它不是Spring特有的功能,但如果您在商业Java应用程序服务器(例如websphere,weblogic)下工作,您将拥有一些工作管理器的实现。
http://docs.oracle.com/javaee/1.4/api/javax/resource/spi/work/WorkManager.html http://docs.oracle.com/javaee/1.4/api/javax/resource/spi/work/WorkManager.html
These are container-managed threadpools used to send work into the background. 这些是容器管理的线程池,用于将工作发送到后台。 You will find tools in your admin console to configure and fine tune them.
您可以在管理控制台中找到用于配置和微调它们的工具。
You should have a separte process or application to process this kind of heavy task. 您应该有一个separte进程或应用程序来处理这种繁重的任务。 Your main application have to communicate with this heavy-task-processor via any method like JMS, JGroups, ConcurrentLinkedQueue, or whatever you want.
您的主应用程序必须通过任何方法(如JMS,JGroups,ConcurrentLinkedQueue或任何您想要的方法)与此重任务处理器进行通信。 You can process (deque) each task one at time or using a thread pool.
您可以一次处理(解除)每个任务或使用线程池。 When the task is finish you have to implement a way to inform the main application the task has finished (JMS, subscription, etc..)
任务完成后,您必须实现一种方法来通知主应用程序任务已完成(JMS,订阅等)。
You already have an accepted answer, but I wanted to throw in another option FYI. 你已经有了一个接受的答案,但是我还想投入另一个选项FYI。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.