Reputation: 2847
I have a stateless EJB with method that process data. Usually method works 5..20 seconds
I need to have about 10 threads, that executes that method concurrently. So I made annotation for that method @Schedule(second = "*", minute = "*", hour = "*")
But container (Glassfish 4) launches only one thread for my method.
I tried to use annotation @Asynchronous
, but it make no effect
What should I do?
Upvotes: 0
Views: 150
Reputation: 18143
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.
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.
}
}
Upvotes: 2