if (!isRemote())
{
fail("This test should be run in a remote configuration!");
}
Client client = null;
ObjectName subsystemService = null;
CallbackServerTimeoutTest.SimpleCallbackHandler callbackHandler = null;
try
{
subsystemService = RemotingTestSubsystemService.deployService();
client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL);
callbackHandler = new SimpleCallbackHandler();
client.connect();
JMSRemotingConnection.
addInvokerCallbackHandler("test", client, null, serverLocator, callbackHandler);
client.invoke(new OnewayCallbackTrigger("blip"));
// make sure we get the callback
Callback c = callbackHandler.getNextCallback(3000);
assertNotNull(c);
assertEquals("blip", c.getParameter());
// sleep for twice the timeout, to be sure
long sleepTime = ServerInvoker.DEFAULT_TIMEOUT_PERIOD + 60000;
log.info("sleeping for " + (sleepTime / 60000) + " minutes ...");
Thread.sleep(sleepTime);
log.debug("woke up");
client.invoke(new OnewayCallbackTrigger("blop"));
// make sure we get the callback
c = callbackHandler.getNextCallback(3000);
assertNotNull(c);
assertEquals("blop", c.getParameter());
}
finally
{
if (client != null)
{
// Note. Calling Client.disconnect() does remove the InvokerCallbackHandler registered
// above. For the http transport, the CallbackPoller will continue running, which will
// generate a lot of ERROR log messages after the server has shut down.
client.removeListener(callbackHandler);
client.disconnect();
}
RemotingTestSubsystemService.undeployService(subsystemService);
}
}