use of org.apache.kafka.common.serialization.ByteBufferDeserializer in project presto by prestodb.
the class KafkaConsumerManager method createConsumer.
KafkaConsumer<ByteBuffer, ByteBuffer> createConsumer(String threadName, HostAddress hostAddress) {
final Properties properties = new Properties();
properties.put(BOOTSTRAP_SERVERS_CONFIG, hostAddress.toString());
properties.put(GROUP_ID_CONFIG, threadName);
properties.put(MAX_POLL_RECORDS_CONFIG, Integer.toString(maxPollRecords));
properties.put(MAX_PARTITION_FETCH_BYTES_CONFIG, maxPartitionFetchBytes);
properties.put(CLIENT_ID_CONFIG, String.format("%s-%s", threadName, hostAddress.toString()));
properties.put(ENABLE_AUTO_COMMIT_CONFIG, false);
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(KafkaPlugin.class.getClassLoader())) {
log.debug("Creating KafkaConsumer for thread %s broker %s", threadName, hostAddress.toString());
return new KafkaConsumer<>(properties, new ByteBufferDeserializer(), new ByteBufferDeserializer());
}
}
Aggregations