I have created an event hub in Azure portal with 2 partitions( 0 and 1). As there is no concept of topics in event hubs like Service bus. I am trying to store different data in partition 0 and partition 1 using
ehClient = EventHubClient.createFromConnectionStringSync(eventHubConnectionString.toString());
byte[] payload = "Storing data in partion 0".getBytes("UTF-8");
/** Storing data in partion 0*/
EventData data = new EventData(payload);
ehClient .send(data, "0");
Even though I am trying to store the data in partition 0 it is by default getting stored in partition 1.
My recieiver logic is:
eventHubClient = EventHubClient.create(Constant.EVENTHUB_SASKEYNAME,
Constant.EVENTHUB_SASKEY, Constant.EVENTHUB_NAMESPACE, Constant.EVENTHUB_NAME);
EventHubConsumerGroup eventHubConsumerGroup = eventHubClient.getConsumerGroup("$Default");
eventHubReceiver = eventHubConsumerGroup.createReceiver("0", null, -1);
while (true) {
message = eventHubReceiver.receive(-1);
if (null != message)
System.out.println("The message that is delivered is : " + message.getPayload());
else
System.out.println("No message in the hub");
}
Is it the right way to store the data in partitions? Can we use partitions as equivalent to Azure Service bus topics?