コード例 #1
0
  private void createKafkaAdaptorListener(
      InputEventAdapterListener inputEventAdapterListener,
      InputEventAdapterConfiguration inputEventAdapterConfiguration) {

    Map<String, String> brokerProperties = new HashMap<String, String>();
    brokerProperties.putAll(inputEventAdapterConfiguration.getProperties());
    String zkConnect =
        brokerProperties.get(KafkaEventAdapterConstants.ADAPTOR_SUSCRIBER_ZOOKEEPER_CONNECT);
    String groupID = brokerProperties.get(KafkaEventAdapterConstants.ADAPTOR_SUSCRIBER_GROUP_ID);
    String threadsStr = brokerProperties.get(KafkaEventAdapterConstants.ADAPTOR_SUSCRIBER_THREADS);
    String optionalConfiguration =
        brokerProperties.get(KafkaEventAdapterConstants.ADAPTOR_OPTIONAL_CONFIGURATION_PROPERTIES);
    int threads = Integer.parseInt(threadsStr);

    String topic =
        inputEventAdapterConfiguration
            .getProperties()
            .get(KafkaEventAdapterConstants.ADAPTOR_SUSCRIBER_TOPIC);

    consumerKafkaAdaptor =
        new ConsumerKafkaAdaptor(
            topic,
            tenantId,
            KafkaEventAdapter.createConsumerConfig(zkConnect, groupID, optionalConfiguration));
    consumerKafkaAdaptor.run(threads, inputEventAdapterListener);
  }
コード例 #2
0
 @Override
 public void disconnect() {
   if (consumerKafkaAdaptor != null) {
     consumerKafkaAdaptor.shutdown();
     String topic =
         eventAdapterConfiguration
             .getProperties()
             .get(KafkaEventAdapterConstants.ADAPTER_MESSAGE_TOPIC);
     log.debug("Adapter " + eventAdapterConfiguration.getName() + " disconnected " + topic);
   }
 }