Grails后台进程 [英] Grails background process

查看:87
本文介绍了Grails后台进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Grails相当陌生,而且我有一个要求,我不知道如何实现。
我需要创建一个流程,它将与Grails应用程序一起运行并进行远程调用,处理接收到的数据并将其写入数据库,以便Grails应用程序可以使用它。

I am fairly new to Grails and I have a requirement that I don't know how to implement. I need to make a process that will be running along the side with Grails application and making remote calls, process received data and writing it to DB so that Grails application can make use of it.

到目前为止,我认为我需要利用域控制器,但我不确定如何创建一个独立的进程,并在后台不断运行并更新数据库。

So far I figured that I need to leverage domain controllers, but I am not sure how to make a separate process that is constantly running in the background and updating DB.

可能吗?我可以获得参考或代码示例。
谢谢。

Is it possible? Can I get references or code examples. Thank you.

推荐答案

你最好的选择是通过 http://grails.org/plugin/quartz http://grails.org/plugin / quartz2 插件。我使用了quartz插件,并且您创建的Job类是工件(如控制器,服务等),因此它们支持依赖注入。服务是进行事务性数据库工作的最佳场所,因此将一个或多个服务注入Job类以处理数据库工作。

Your best bet is Quartz via the http://grails.org/plugin/quartz or http://grails.org/plugin/quartz2 plugins. I've used the quartz plugin and the Job classes you create are artifacts (like controllers, services, etc.) so they support dependency injection. Services are the best place to do transactional database work, so inject one or more services into your Job classes to handle database work.

quartz2插件更新,因此您可能拥有在当前版本的Grails中使用它更多的运气,但它可能不具备旧版插件的所有功能。

The quartz2 plugin is newer so you may have more luck using it in current versions of Grails, but it might not have all of the features of the older plugin.

这篇关于Grails后台进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆