1

I needed to publish messages to 2 different partitions in azure event hub using c#. I was able achieve this by specifying 2 different partition keys. Now I need 2 different consumers to pull these messages from each partition. How can I accomplish this using a c# client? I could not find a method to consume a message using a partition key. Thanks

jtech3
  • 11
  • 1

1 Answers1

0

How about the ProcessEventsAsync method: https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.eventhubs.processor.ieventprocessor.processeventsasync?view=azure-dotnet-legacy

It expects a PartitionContext parameter whose second parameter is the partition key.

public PartitionContext (Microsoft.Azure.EventHubs.Processor.EventProcessorHost host, string partitionId, string eventHubPath, string consumerGroupName, System.Threading.CancellationToken cancellationToken);
Athanasios Kataras
  • 25,191
  • 4
  • 32
  • 61
  • Hi - Thanks for taking time to look into this. From what I tried, The 2nd parameter that you suggested is the partitionid (0,1 etc) which is different partition key value that I am setting so it didn't work for me. But I came across another link that helped.https://stackoverflow.com/questions/59014664/directing-messages-to-consumers – jtech3 Sep 14 '20 at 02:24