如何将 Quartz 与 EJB3 一起使用?

发布于 2024-08-13 06:17:52 字数 584 浏览 6 评论 0 原文

我希望能够:

  • 定义不同的作业和触发器。
  • 按需修改到期日期和间隔
  • 暂停或取消执行(触发)

作业将是 ejbs 或调用 ejbs,我想从网站管理所有内容(用户必须定义​​执行)

所以我查看了计时器服务、计时器对象、计时器和计时器句柄。但我认为它不能满足我所有的需求

,另一方面,Quartz 允许我做我想做的每件事,但我对如何将其集成到我的 jboss 中一无所知。 我读到石英使用它自己的线程池,我不知道如何处理这一切。

我在我的项目中使用Jboss Seam,但是seam/quartz集成非常有限(或者文档是)并且不是100%安全(在他们的论坛上看到:‘永远运行’任务仅几周后就结束

如果有人设法将一个好的调度程序集成到他的应用程序服务器中(jboss 是一个优点)并且可以给我指导、建议,甚至代码片段,我都会很兴奋。

提前致谢。

I want to be able to :

  • define different jobs and triggers.
  • modify the expirations dates and intervals on demand
  • pause or cancel an execution (trigger)

the jobs would be ejbs or call ejbs and i would want to manage everything from the website (the user will have to define the executions)

So i looked at the timerservice, timerobjects, timer and timerhandle. But i think it can't answer to all my needs

Quartz, on the other hand, allows me to do every thing that i want, but i haven't the slightest clue on how to integrate this into my jboss.
I read that quartz uses its own threadpool, and i don't know how to handle all this.

I use Jboss Seam in my project, but the seam/quartz integration is very limited (or the documentation is) and not 100% safe (seen on their forum : 'run forever' tasks end after only a few weeks)

If someone managed to integrate a good scheduler into his application server (jboss is a plus) and could give me directions, advices, or even code snippets, i would be thrilled.

Thanks in advance.

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

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

发布评论

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

评论(4

羞稚 2024-08-20 06:17:52

我有一些将 Quartz 集成到 Weblogic(抱歉,没有 jboss 经验)应用程序服务器的经验。 Quartz 有一个内置的监听器 class ,它将在服务器启动时调用(根据 J2EE 规范)自动配置 Quartz 调度程序。然后,在另一个启动类中,您可以检索该调度程序、添加作业并开始为这些作业提供服务。

你通常不需要担心线程池,如果你也需要的话,Quartz 可以自己处理所有这些。它在启动时从属性文件中获取信息,您可以定义该信息或使用quartz 附带的默认属性文件。我一直使用默认值,因为它适合我的目的。

至于定义作业,您可以创建作业类并从那里调用您的 ejb。这是非常简单的。

为了您的阅读乐趣:

所有 Quartz 文档

Quartz JavaDoc

包含大量代码片段的食谱

希望这足以让您入门!

I have some experience integrating Quartz into a Weblogic (no jboss experience, sorry) application server. Quartz has a built in listener class that will be called upon server startup (per J2EE specs) that automatically configure the Quartz scheduler. Then in another startup class you can retrieve that scheduler, add jobs and begin serving those jobs.

You generally don't need to worry about the threadpool, Quartz can handle all this itself if you want it too. It gets its information from a properties files on startup that you can define or use the default one that comes with quartz. I have been using the default because it works for my purposes.

As far as defining jobs, you create your job classes and call your ejbs from there. It is rather very simple.

For your reading pleasure:

All Quartz documentation

Quartz JavaDoc

Cookbook containing lots of code snippets

Hope that's enough to get you started!

仙气飘飘 2024-08-20 06:17:52

好消息! JBoss 已经有一个内置的调度程序。

由于 EJB 2.0 规范包括按计划的时间间隔运行无状态会话 Bean 和 MDB,因此所有应用程序服务器都包含此功能已有一段时间了。

以下是配置 JBoss 使用其内置调度程序运行类的示例:

http:// www.jboss.org/community/wiki/Scheduler

JBoss 实现的最佳部分是它基于 MBean 规范,这意味着您可以在运行时创建/更新/删除计划任务。

Great news! JBoss has a built-in scheduler already.

Since the EJB 2.0 specification included running stateless session beans and MDBs at scheduled intervals, all application servers have included this capability for some time now.

Here is an example of configuring JBoss to run a class using its built-in scheduler:

http://www.jboss.org/community/wiki/Scheduler

The best part about JBoss' implementation is that it is based on the MBean specification, which means that you can create/update/delete scheduled tasks at runtime.

慕烟庭风 2024-08-20 06:17:52

好吧,很抱歉,我在 Jboss Seam 的源代码中找到了我所需要的:
QuartzDispatcher 到创建 QuartzTriggerHandle它在指定的时间和日期触发接缝事件,并且可以手动暂停、恢复和停止。我在我想要执行的方法上使用@observer。

这很简单,而且到目前为止还有效。

Ok, i am sorry, i found in the sources of Jboss Seam just what i needed :
QuartzDispatcher to create QuartzTriggerHandle wich fires seam event at specified time and date and is manually pausable, resumable and stoppable. I use an @observer on the method i wanted to execute.

It's simple, and it works so far.

时光倒影 2024-08-20 06:17:52

正如 Poindexter 所指出的,Quartz 文档 有很好的起点:使用 Quartz 进行开发的教程使用示例Cook Book(以代码示例形式提供的快速操作指南) 等。

什么是 Quartz 文章也非常好(即使现在有点旧)。

要与 JBoss 集成,也许可以查看 如何在 JBoss 上配置 Quartz 服务维基百科。

As pointed out by Poindexter, the Quartz documentation has nice starting points: Tutorial for Developing with Quartz, Examples of Usage, Cook Book (Quick How-Tos in the form of code examples), etc.

The What Is Quartz article is really good too (even if a bit old now).

For integration with JBoss, maybe have a look at How to configure a Quartz service on JBoss Wiki.

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