使用 spring 3 创建一个始终在后台运行的 pojo/ejb
我过去创建过一些应用程序,这些应用程序的网页会调用持久层来获取一些查询结果或针对数据库插入、删除等。然而,除了持久层之外,没有任何东西在后台运行。现在我需要开发一个应用程序,该应用程序有一个始终在后台运行的进程,该进程正在等待通过 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用某种计时器,每秒启动一个方法来查看特定资源并处理从中获取的输入。
如果你使用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.