Quartz 调度器实现的设计决策

发布于 2024-12-23 05:42:41 字数 807 浏览 2 评论 0原文

目前,我正在为我们的一个项目探索 Quartz 调度程序。虽然我仍在探索它,但我有一些疑问。

早些时候,我曾与一个基于 Java 的电子商务平台合作,他们以非常好的方式实现了 Quartz 调度程序。定义新任务需要执行以下步骤。

  1. 登录到 GUI。
  2. 单击新建按钮,它将打开一个页面。
  3. 输入唯一的Job名称和我们要调用的方法名称。
  4. 我们想要传递的任何参数;如果方法需要它们,则只允许使用原语。
  5. 提供触发详细信息(时间、日期、月份任何可能的组合)。
  6. 点击保存按钮,我们就可以开始了。

现在这引发了一些问题,因为在 Quartz 中我们必须创建一个作业类,该类应该实现 Job 接口并实现其execute(JobExecutionContext context) 方法,该方法将执行工作。我想知道平台上的 API 是如何完成这一切的,因为我从未创建过必须实现 Job 接口的类。

例如,如果我想创建一个 OrderExport 函数,我所做的就是创建一个名为 OrderExport 的类,其方法为 export。然后在调度程序的 UI 中,我只需在文本框中填写作业名称(任何唯一名称)、类名称(例如 OrderExport)、方法名称(例如 export() >) 和触发细节。

任何人都可以建议/指导我他们是如何实现这一目标的吗?

Currently I am exploring Quartz scheduler for one of our projects. While I am still in process of exploring it, I have a few doubts.

Earlier I was working with one of Java-based e-commerce platforms where they have implemented Quartz scheduler in a very good way. Defining a new task requires the following steps.

  1. Log in to the GUI.
  2. Click on new button, and it will open a page.
  3. Enter the unique Job name and the method name that we want to call.
  4. Any parameters which we want to pass; if methods need them, only primitives are allowed.
  5. Provide trigger details (Time, Day, Month any possible combinations).
  6. Hit the save button and we are ready to go.

Now this prompted a few question, since in Quartz we have to create a job class that should implement Job interface and should implement its execute(JobExecutionContext context) method, which will perform the work. I am wondering how that API on the platform was doing all this, as I have never created a class which has to implement the Job interface.

For example, if i want to create a OrderExport function, all I did is created a class namely OrderExport with a method say export. Then in the UI for scheduler, I just filled the text-boxes with job name (any unique name), class name (e.g. OrderExport), method name (e.g. export()) and triggering details.

Can any one suggest/guide me how they have achieved this?

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

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

发布评论

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

评论(1

拥抱我好吗 2024-12-30 05:42:41

电子商务平台更有可能使用通用作业,该作业可以获取对组件的引用(也许它是基于工厂的,它有方法访问您的 OrderExport 类?该方法是否需要静态?这是哪个电子商务平台?)并通过反射执行请求的方法。

More likely than not, the ecommerce platform was using a generic job, that could get reference to the component (maybe it was factory based, it had ways to get access to your OrderExport class? was the method required to be static by any chance? Which ecommerce platform was this?) and execute the method requested via reflection.

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