@Override public void run() { try { int correlationId = clientMessage.getCorrelationId(); final EventHandler eventHandler = eventHandlerMap.get(correlationId); if (eventHandler == null) { logger.warning( "No eventHandler for callId: " + correlationId + ", event: " + clientMessage); return; } eventHandler.handle(clientMessage); } finally { connection.decrementPendingPacketCount(); } }
private void invoke(ClientRegistrationKey registrationKey, Address address) throws Exception { ListenerMessageCodec codec = registrationKey.getCodec(); ClientMessage request = codec.encodeAddRequest(true); EventHandler handler = registrationKey.getHandler(); handler.beforeListenerRegister(); ClientInvocation invocation = new ClientInvocation(client, request, address); invocation.setEventHandler(handler); String serverRegistrationId = codec.decodeAddResponse(invocation.invoke().get()); handler.onListenerRegister(); int correlationId = request.getCorrelationId(); ClientEventRegistration registration = new ClientEventRegistration(serverRegistrationId, correlationId, address, codec); Map<Address, ClientEventRegistration> registrationMap = registrations.get(registrationKey); registrationMap.put(address, registration); }
private boolean handleRetry() { if (isBindToSingleConnection()) { return false; } if (handler == null && reSendCount.incrementAndGet() > retryCountLimit) { return false; } if (handler != null) { handler.beforeListenerRegister(); } try { sleep(); executionService.execute(this); } catch (RejectedExecutionException e) { if (LOGGER.isFinestEnabled()) { LOGGER.finest("Retry could not be scheduled ", e); } clientInvocationFuture.setResponse(e); } return true; }