MessageListenerThread extends Thread { String key(ConsumerRecord<byte[], byte[]> record) { byte[] key = record.key(); return key == null ? null : new String(key, UTF_8); } MessageListenerThread(String name, MessageListener listener); @Override void run();  }
@Test void key() { assertThat(thread.key(new ConsumerRecord<>("topic", 0, 0, null, null))) .isNull(); assertThat(thread.key(new ConsumerRecord<>("topic", 0, 0, Strings.bytes("key"), null))) .isEqualTo("key"); }