Hi,
this is what I want to do:
I have en EJB that has an asynchronous method, and a remote client that calls
this method.
Is it possible for the client to call the asynch method then continue
processing? (fire and forget).
Then how would the ejb send the response to the client?
What I have done is, let the client implement an interface to act as a
Callback handler and pass to the async method a reference to the client.
When the ejb is done with the job it should call the method in the client.
Here is a very simplified example:
//ICallback defines only public void addResult(Integer result);
public class CalculationClient implements ICallback
{
public void addResult(Integer result)
{
System.out.println(result);
}
public void doLengthyCalculation()
{
Context initalContext = new InitialContext();
CalculatorRemote remoteEjb =
initalContext.lookup("java:global/CalculationServer/Calculator!my.package.CalculatorRemote");
remoteEjb.calculate(this);
}
}
//CalculatorRemote is annotated with @Remote
public class Calculator implements CalculatorRemote
{
@Override
@Asynchronous
public Future<Integer> calculate(ICallback callBack)
{
// Do calculation...
callBack.addResult(newResult);
Future<Integer> futureResult = new
AsyncResult<Integer>(newResult);
return futureResult;
}
}
The lookup is working normally and I can see in the server log that the
calculation is performed and finished, but the addResult method in the client
is not called...
How should such a constellation be handled?
Thanks in advance.
Regards
--
[Message sent by forum member 'MohamzJava']
View Post: http://forums.java.net/node/826162