コード例 #1
0
    @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();
      }
    }
コード例 #2
0
  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);
  }
コード例 #3
0
  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;
  }