[英]concurrent threads for a method of EJB
I have a stateless EJB with method that process data. 我有一个处理数据的方法的无状态EJB。 Usually method works 5..20 seconds
通常该方法有效5..20秒
I need to have about 10 threads, that executes that method concurrently. 我需要大约10个线程,这些线程可以同时执行该方法。 So I made annotation for that method
@Schedule(second = "*", minute = "*", hour = "*")
But container (Glassfish 4) launches only one thread for my method. 因此,我对该方法进行了注释
@Schedule(second = "*", minute = "*", hour = "*")
但是容器(Glassfish 4)仅为我的方法启动一个线程。
I tried to use annotation @Asynchronous
, but it make no effect 我尝试使用注释
@Asynchronous
,但没有任何效果
What should I do? 我该怎么办?
Write a second class using the @Schedule(second = "*", minute = "*", hour = "*")
to call your @Asynchronous
EJB method - then, if the duration is as you said, it should start a new thread every second. 使用
@Schedule(second = "*", minute = "*", hour = "*")
@Asynchronous
@Schedule(second = "*", minute = "*", hour = "*")
编写第二个类@Schedule(second = "*", minute = "*", hour = "*")
以调用@Asynchronous
EJB方法-然后,如果持续时间如您所说,则应重新开始每秒线程。
public class Caller {
@EJB
AsyncEJB asyncEjb;
@Schedule(second = "*", minute = "*", hour = "*")
public void call() {
this.asyncEjb.call();
}
}
@Stateless
public class AsyncEJB {
@Asynchronous
public void call() {
// Do long running stuff.
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.