Merge pull request #222 from spelluru/patch-2

first param should be byte[] - as per Eric Lam
This commit is contained in:
Eric Lam (MSFT) 2022-11-28 11:20:56 -08:00 коммит произвёл GitHub
Родитель 436fdb4fac 4c34382009
Коммит c7c395d420
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -38,11 +38,11 @@ and ByteArrayDeserializer:
// add other properties
properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, ByteArraySerializer.class.getName());
final KafkaProducer<Long, byte[]> producer = new KafkaProducer<Long, byte[]>(properties);
final KafkaProducer<byte[], byte[]> producer = new KafkaProducer<byte[], byte[]>(properties);
final byte[] eventBody = new byte[] { 0x01, 0x02, 0x03, 0x04 };
ProducerRecord<Long, byte[]> pr =
new ProducerRecord<Long, byte[]>(myTopic, myPartitionId, myTimeStamp, eventBody);
ProducerRecord<byte[], byte[]> pr =
new ProducerRecord<byte[], byte[]>(myTopic, myPartitionId, myTimeStamp, eventBody);
/* send pr */
```
@ -53,9 +53,9 @@ and ByteArrayDeserializer:
// add other properties
properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class.getName());
final KafkaConsumer<Long, byte[]> consumer = new KafkaConsumer<Long, byte[]>(properties);
final KafkaConsumer<byte[], byte[]> consumer = new KafkaConsumer<byte[], byte[]>(properties);
ConsumerRecord<Long, byte[]> cr = /* receive event */
ConsumerRecord<byte[], byte[]> cr = /* receive event */
// cr.value() is a byte[] with values { 0x01, 0x02, 0x03, 0x04 }
```