简体   繁体   English

如何将Java长时间运行的进程分发到远程服务器

[英]How to distribute Java long running process to remote servers

My php web server receive requests and needs to launch a java program that runs between 30 sec and 5 minutes or even more. 我的php web服务器接收请求并需要启动一个运行时间在30秒到5分钟甚至更长时间的java程序。 That long process needs to be distributed on the available servers in my LAN. 需要在LAN中的可用服务器上分发这个漫长的过程。

What i need: 我需要的:

  • a job queue ( that's done in a db) 一个作业队列(在db中完成)

  • A DB watch. 一个DB手表。 Get notified of new or completed job (to start another job in the queue) 获得有关新作业或已完成作业的通知(以启动队列中的其他作业)

  • Start a java process on a remote and available computer. 在远程可用计算机上启动Java进程。

It seems that it needs to be a DB watch since I need to evaluate which remote computer is available and a DB stored procedure wouldn't accomplish that easily. 它似乎需要是一个数据库监视,因为我需要评估哪个远程计算机可用,而数据库存储过程不会轻易实现。

What is the best or at least a good way to achieve this in a OS independant way using JAVA. 使用JAVA以独立于操作系统的方式实现此目的的最佳或至少是一种好方法。

I guess I could use a FileWatch and manage the queue in a folder but it seems prehistoric. 我想我可以使用FileWatch并管理文件夹中的队列,但它似乎是史前的。

Thanks 谢谢

I would use a JMS queue. 我会使用JMS队列。 You add tasks/messages to a queue and the next available process takes a task, performs it and sends back any result on another queue or topic. 您将任务/消息添加到队列,下一个可用进程接受任务,执行任务并将任何结果发送回另一个队列或主题。 This supports transparent load balancing and you can restart tasks if a process fails. 这支持透明的负载平衡,如果进程失败,您可以重新启动任务。 No polling is required. 不需要轮询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM