InvokerLocator serverLocator = new InvokerLocator(locatorURI);
log.info("Connecting to: " + serverLocator);
HashMap config = new HashMap();
config.put(InvokerLocator.FORCE_REMOTE, "true");
addExtraClientConfig(config);
Client client = new Client(serverLocator, config);
client.connect();
assertTrue(client.getInvoker() instanceof BisocketClientInvoker);
log.info("client is connected");
String callbackLocatorURI1 = getTransport() + "://" + host + ":1";
config.put(Bisocket.IS_CALLBACK_SERVER, "true");
Connector callbackConnector1 = new Connector(callbackLocatorURI1, config);
callbackConnector1.start();
String callbackLocatorURI2 = getTransport() + "://" + host + ":2";
Connector callbackConnector2 = new Connector(callbackLocatorURI2, config);
callbackConnector2.start();
DelayedCallbackHandler callbackHandler = new DelayedCallbackHandler();
client.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI1));
client.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI2));
assertEquals(2, invocationHandler.callbackHandlers.size());
log.info("client added callback handlers");
client.invokeOneway(CALLBACK_TEST);
client.invokeOneway(CALLBACK_TEST);
Thread.sleep(500);
assertEquals(2, callbackHandler.callbackCounter);
Iterator it = invocationHandler.callbackHandlers.iterator();
ServerInvokerCallbackHandler serverInvokerCallbackHandler1 = (ServerInvokerCallbackHandler) it.next();
ServerInvokerCallbackHandler serverInvokerCallbackHandler2 = (ServerInvokerCallbackHandler) it.next();
Client callbackClient1 = serverInvokerCallbackHandler1.getCallbackClient();
Client callbackClient2 = serverInvokerCallbackHandler2.getCallbackClient();
assertNotSame(callbackClient1, callbackClient2);
assertTrue(callbackClient1.getInvoker() instanceof BisocketClientInvoker);
MicroSocketClientInvoker clientInvoker1 = (MicroSocketClientInvoker) callbackClient1.getInvoker();
assertTrue(callbackClient2.getInvoker() instanceof BisocketClientInvoker);
MicroSocketClientInvoker clientInvoker2 = (MicroSocketClientInvoker) callbackClient2.getInvoker();
Field field = MicroSocketClientInvoker.class.getDeclaredField("pool");
field.setAccessible(true);
List pool1 = (List) field.get(clientInvoker1);
List pool2 = (List) field.get(clientInvoker2);