I try to get an async process running. Based on this example: http://tomee.apache.org/examples-trunk/async-methods/README.html
But the method addWorkflow(Workflow
The issue is that Java can't decorate the implicit this pointer.
In other words, the @Asynchronous annotation won't be processed and you're doing an ordinary method call.
You can inject your so singleton with a reference to itself (call this e.g. "self"), then call self.addWorkflow.
You might also want to consider running your async code in a stateless bean. You are using a read lock for addWorkflow, but runWorkflow still has a write lock. I think you have a dead lock now: you're holding the lock until work is done, but no work can be done until the write lock is released.
So the normal way would be to have the @Asynchronous method in another bean from the caller method.
@Stateless
public class ComputationProcessor {
@Asynchronous
public Future<Data> performComputation {
return new AsyncResult<Data>(null);
}
}
@Stateless
public class ComputationService {
@Inject
private ComputationProcessor mProcessor;
public void ...() {
Future<Data> result = mProcessor.performComputation();
...
}
}
As you discovered, it won't work if the @Asynchronous method is in the same bean than the caller.