[英]Executing external services using EJB Timer Service
I have a scenario to ask regarding utilizing the EJB Timer Service. 我有一个关于利用EJB计时器服务的场景。
Use case as follows: The system should be able to schedule a task that will poll/ask our subversion repository for files changes using some particular timestamp. 用例如下:系统应该能够安排一个任务,该任务将使用某些特定的时间戳来轮询/询问我们的Subversion存储库中的文件更改。
The idea is that whenever the scheduled task is about to run, it will execute command against a particular svn repository. 这个想法是,每当计划任务要运行时,它将针对特定的svn存储库执行命令。 For this particular purpose, I will not call any external process but will use the 'pure' java way of using the SVNKit java library http://svnkit.com/ 为此,我不会调用任何外部进程,而是使用“纯” java方式来使用SVNKit Java库http://svnkit.com/
My only concern is this: Is it a good idea to use the EJB Timer Service to execute task that will call external processes? 我唯一关心的是:使用EJB计时器服务执行将调用外部进程的任务是一个好主意吗? My way will use a 'pure' java way but in other scenario such as calling a batch file/command line/external executable directly into the timer service logic. 我的方式将使用“纯” java方式,但在其他情况下,例如将批处理文件/命令行/外部可执行文件直接调用到计时器服务逻辑中。
I worry about the effects of server memory use/performance etc. 我担心服务器内存使用/性能等的影响。
Is this a good idea? 这是一个好主意吗?
The other thought that I am thinking is to just create a 'desktop' application in the server using client based technology such as SWT/Swing that will do the polling and then code the logic there but this will mean that I need to manage two applications. 我在想的另一个想法是,使用基于客户端的技术(例如SWT / Swing)在服务器中创建一个“桌面”应用程序,该应用程序将执行轮询,然后在那里进行逻辑编码,但这意味着我需要管理两个应用程序。 The 'desktop' app that will poll and the 'web' user interface that I will create in Glassfish. 将会轮询的“桌面”应用程序以及我将在Glassfish中创建的“网络”用户界面。
I am leaning towards doing everything in the App server of my choice which is glassfish. 我倾向于在我选择的应用服务器(glassfish)中执行所有操作。
I have used EJB Timer before but it only calls against the database without calling any extenral service and it's just that this scenario came up so I raised a question here to gather more thoughts from those who have experienced doing this. 我以前使用过EJB Timer,但是它只调用数据库而没有调用任何扩展服务,只是这种情况出现了,所以我在这里提出了一个问题,以收集有经验的人的更多想法。
Any thoughts? 有什么想法吗?
In theory, EJBs aren't supposed to depend on external I/O since it interferes with the container/server's management of bean instances, threads, etc. 从理论上讲,EJB不应该依赖于外部I / O,因为它会干扰容器/服务器对Bean实例,线程等的管理。
In practice, this should work if you take precautions. 在实践中,如果采取预防措施,这应该会起作用。 For example: 例如:
Keep in mind that EJB 3.0 timers are persistent (vs EJB 3.1 timers, which have the option of being non-persistent), which means: 请记住,EJB 3.0计时器是持久性的(与EJB 3.1计时器相比,它可以是非持久性的),这意味着:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.