使用 spring 3 创建一个始终在后台运行的 pojo/ejb

发布于 2024-10-15 12:57:13 字数 218 浏览 4 评论 0原文

我过去创建过一些应用程序,这些应用程序的网页会调用持久层来获取一些查询结果或针对数据库插入、删除等。然而,除了持久层之外,没有任何东西在后台运行。现在我需要开发一个应用程序,该应用程序有一个始终在后台运行的进程,该进程正在等待通过 Zeromq 消息系统发送的消息(此时无法更改)。我对如何设置对象以使其始终运行但我可以控制或查询对象的结果有点迷失。

是否有涵盖此配置的教程/示例?

谢谢,

I have created apps in the past that would have web pages that would call the persistence layer to get some query results or to insert, delete, etc against a db. However, nothing was left running in the background except for the persistence layer. Now I need to develop an app that has an process that is always running in the background, which is waiting for messages to come thru a zeromq messaging system (cannot change this at this point). I am a little lost as to how to setup the object so that it can always be running and yet I can control or query the results from the object.

Is there any tutorial/examples that covers this configuration?

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红尘作伴 2024-10-22 12:57:13

您可以使用某种计时器,每秒启动一个方法来查看特定资源并处理从中获取的输入。
如果你使用Spring,你可以看看 @Scheduled< /a> 注释。

如果您的输入是某种 java 方法调用,那么请查看 java.util.concurrent 包以及并发编程。 -- 但请注意这样一个事实,即在 EJB 环境中创建自己的线程存在一些限制。

You could use some kind of timer, to start a method every second to look at a specific ressource and process the input taken from that.
If you use Spring than you could have a look at the @Scheduled annotation.

If your input is some kind of java method invokation, than have a look at the java.util.concurrent Package, and concurrent programming at all. -- But be aware of the fact, that there are some restictions one creating own Threads in an EJB environment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文