@Override
  public void transport(String message) {

    String currentMessage = "";
    try {

      if (!(message.startsWith("{") && message.endsWith("}"))
          && !(message.startsWith("\"") && message.endsWith("\"")))
        message = wrapMessageInQuotes(message);

      // could use a JSON Object , but the JSON is so trivial , just
      // building it with a StringBuffer
      StringBuffer json = new StringBuffer();
      json.append("{\"").append("event\":").append(message).append(",\"");

      if (!config.getIndex().equalsIgnoreCase("default"))
        json.append("index\":\"").append(config.getIndex()).append("\",\"");

      json.append("source\":\"")
          .append(config.getSource())
          .append("\",\"")
          .append("sourcetype\":\"")
          .append(config.getSourcetype())
          .append("\"")
          .append("}");

      currentMessage = json.toString();

      if (config.isBatchMode()) {
        lastEventReceivedTime = System.currentTimeMillis();
        currentBatchSizeBytes += currentMessage.length();
        batchBuffer.add(currentMessage);
        if (flushBuffer()) {
          currentMessage = rollOutBatchBuffer();
          batchBuffer.clear();
          currentBatchSizeBytes = 0;
          hecPost(currentMessage);
        }
      } else {
        hecPost(currentMessage);
      }

    } catch (Exception e) {
      logger.error("Error writing received data via HEC: " + ModularInput.getStackTrace(e));
    }
  }
  @Override
  public void init(Object obj) {
    config = (HECTransportConfig) obj;

    this.batchBuffer = Collections.synchronizedList(new LinkedList<String>());
    this.lastEventReceivedTime = System.currentTimeMillis();

    try {

      Registry<SchemeIOSessionStrategy> sslSessionStrategy =
          RegistryBuilder.<SchemeIOSessionStrategy>create()
              .register("http", NoopIOSessionStrategy.INSTANCE)
              .register("https", new SSLIOSessionStrategy(getSSLContext(), HOSTNAME_VERIFIER))
              .build();

      ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor();
      PoolingNHttpClientConnectionManager cm =
          new PoolingNHttpClientConnectionManager(ioReactor, sslSessionStrategy);
      cm.setMaxTotal(config.getPoolsize());

      HttpHost splunk = new HttpHost(config.getHost(), config.getPort());
      cm.setMaxPerRoute(new HttpRoute(splunk), config.getPoolsize());

      httpClient = HttpAsyncClients.custom().setConnectionManager(cm).build();

      uri =
          new URIBuilder()
              .setScheme(config.isHttps() ? "https" : "http")
              .setHost(config.getHost())
              .setPort(config.getPort())
              .setPath("/services/collector")
              .build();

      httpClient.start();

      if (config.isBatchMode()) {
        new BatchBufferActivityCheckerThread().start();
      }

    } catch (Exception e) {
      logger.error("Error initialising HEC Transport: " + ModularInput.getStackTrace(e));
    }
  }