static Consumer<byte[], byte[]> newConsumer(
String brokerList, @Nullable String groupId, @Nullable Settings config) {
Properties ps = toProperties(config);
ps.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList);
ps.setProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
ps.setProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class.getName());
if (groupId != null) {
ps.setProperty(ConsumerConfig.GROUP_ID_CONFIG, groupId);
}
if (ps.getProperty(ConsumerConfig.CLIENT_ID_CONFIG) == null) {
final String name = "euphoria.client-id-" + UUID.randomUUID().toString();
LOG.warn("Autogenerating name of consumer's {} to {}",
ConsumerConfig.CLIENT_ID_CONFIG, name);
ps.setProperty(ConsumerConfig.CLIENT_ID_CONFIG, name);
}
return new KafkaConsumer<>(ps);
}