在石英作业中使用CDI [英] Using CDI in Quartz Jobs

查看:166
本文介绍了在石英作业中使用CDI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以以便携式方式在Quartz工作中使用CDI bean?



我已经尝试编写自己的JobFactory等但是问题是,BeanManager不能通过JNDI使用,因为作业运行在非托管线程中。我的应用程序服务器是Websphere 8.0.0.1,我已经看到它是针对EE6规范,使名称java:可用于非管理线程。



有现在我想到两个解决方案:


  1. 让Websphere创建工作线程(不知道该怎么做,任何帮助都会很好)

  2. 实现EJB并通过EJBJobInvoker调用该方法

我知道,当我使用CDI解决方案,那么我不能让工作线程运行在不同的JVM中,如果我错了就纠正我的错误。为了保持可扩展性,我应该为此实现一个EJB?你怎么看,你有没有遇到过这个问题?我也会喜欢不同的解决方案,甚至不同的调度程序库的建议!

解决方案

查看 DeltaSpike调度程序模块



您可以在 Maven Central Repository


I would like to know if it is possible to use CDI beans in Quartz jobs in a portable way?

I have already tried to write my own JobFactory and so on, but the problem is, that the BeanManager is not available through JNDI, because the job runs in a non managed thread. My application server is Websphere 8.0.0.1 and I already read that it is against the EE6 spec to make the name "java:" available to non managed threads.

There are two solutions now I think:

  1. Let Websphere create the worker threads(Don't know how to do that, any help would be nice)
  2. Implement an EJB and call the method through the EJBJobInvoker

I know that, when I use the CDI solution, then I am not able to let the worker threads run in a different JVM, correct me if I am wrong. To stay scaleable I should implement an EJB for that? What do you think, have you ever had that problem? I would also appreciate different solutions or even suggestions on different scheduler libraries!

解决方案

Look at DeltaSpike scheduler module.

You can find last version on Maven Central Repository.

这篇关于在石英作业中使用CDI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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