Azure Event Hubs supports three protocols for consumers and producers: AMQP, Kafka, and HTTPS : Azure Event Hubs - Exchange events using different protocols - Azure Event Hubs | Microsoft Docs
Kafka byte[] producer
Code Block | ||
---|---|---|
| ||
final Properties properties = new Properties();
// add other properties
properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
ByteArraySerializer.class.getName());
final KafkaProducer<Long, byte[]> producer = new KafkaProducer<Long, byte[]>(properties);
final byte[] eventBody = new byte[] { 0x01, 0x02, 0x03, 0x04 };
ProducerRecord<Long, byte[]> pr =
new ProducerRecord<Long, byte[]>(myTopic, myPartitionId, myTimeStamp, eventBody); |
Kafka byte[] consumer
Code Block | ||
---|---|---|
| ||
final Properties properties = new Properties();
// add other properties
properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,
ByteArrayDeserializer.class.getName());
final KafkaConsumer<Long, byte[]> consumer = new KafkaConsumer<Long, byte[]>(properties);
ConsumerRecord<Long, byte[]> cr = /* receive event */
// cr.value() is a byte[] with values { 0x01, 0x02, 0x03, 0x04 } |