0

I have inherited an Azure Event Hub as a ressource for management and usage. Unfortunately there is no documentation. I can only see a Event Hub Namespace Ressource and there is one Event Hub Entity, which is active. If I click on it, there is only a $Default consumer group and I can't figure out what the Event Hub does. Is it possible to see what the Event hub does and how can I retrieve information through the Event Hub?

Thanks!

Edit: This is the current code I'm using. I can authenticate but I don't receive any messages or I can't retrieve what Event Hub is providing. How can I receive the data?

from confluent_kafka import Consumer, KafkaException, KafkaError

bootstrap_servers = SERVER
topic = TEST_HUB
group_id = ID

# Kafka Config

consumer_config = {
    'bootstrap.servers': bootstrap_servers,
    'group.id': group_id,
    'auto.offset.reset': 'earliest',
    'enable.auto.commit': False,
    'security.protocol': 'SASL_SSL',
    'sasl.mechanism': 'PLAIN',
    'sasl.username': '$ConnectionString',
    'sasl.password': MY_EVENT_HUB_ENDPOINT
}

# Consumer
consumer = Consumer(consumer_config)


# Subscribe to the azure event hub
consumer.subscribe([topic])

# Consume messages from Kafka 
try:
    while True:
        message = consumer.poll(5.0)

        if message is None:
            continue

        if message.error():
            if message.error().code() == KafkaError._PARTITION_EOF:
                # End of partition event
                continue
            else:
                # Handle error
                print(f"Error: {message.error().str()}")
                break

        # Process the Kafka message
        key = message.key()
        value = message.value()
        print(value)

        # Commit the message offset
        consumer.commit(message)

except KeyboardInterrupt:
    pass

finally:
    # Close
    consumer.close()
AzUser1
  • 183
  • 1
  • 14

1 Answers1

0

Event Hubs exposes the events for any consumer wishing to read them. for more details refer : Azure Event Hub And refer1 , refer2

Hope it helps.

Neha Tawar
  • 687
  • 7
  • 23
  • I followed the guide and used Python instead of Java to connect to the Event Hub using Kafka. It works to the extend that I can successfully authenticate to event hub but I dont see how I can retrieve the information. Could you elaborate on how to get the information? – AzUser1 Jun 27 '23 at 11:22
  • This answer consists of mainly links, the answer would be greatly improved when it provides an actual overview of what event hub does. Like now it is better suited as a comment. – Peter Bons Jun 27 '23 at 12:45