In our Cloud Service project, we have 2 instances for work role (deploy to Azure), the work role is consume events from the EventHub using EventProcessorHost(host name is RoleInstance name, like EventProcessorHostA and EventProcessorHostB).
For sending data, we use the same PartitionKey, so all the data will be sent toone Partition (from MSDN: Using a partition key ensures that all the events with the same key are sent to the same partition in the Event Hub):
while (true)
{
var eventData =newEventData(Encoding.UTF8.GetBytes("Message")) { PartitionKey = "TestKey" };
client.SendAsync(eventData);
Thread.Sleep(200);
}
When we deploy our project to Azure, we have twoEventProcessorHost to consume events from the EventHub (same Partition), butonly one EventProcessorHost will get the data, the other one will not get the data, is it the default behavior?
If we use different ConsumerGroup for the different EventProcessorHost, all the host will got the same data, we do not want this way.
We want to using two EventProcessorHost share one Partition, like we send message1~message 100 to the EventHub with the same partition key, all the messages will be sent to the same partition, then we consume events with two hosts, EventProcessorHostA will got 50 messages(message 1, 3, 5, 7 …), EventProcessorHostB will got 50 messages(message 2, 4, 6, 8 …), because we want to make our performance faster.
So is there any way to achieve it?
And In our demo, we found hostA start to consume (message 1, 2, 3…., hostB got no message), then we got the ReceiverDisconnectedException, then renew lease, hostA stopped, hostA will not consume again, hostB start to consume data.
We want toEventProcessorHostA will got 50 messages(message 1, 3, 5, 7 …), EventProcessorHostB will got 50 messages(message 2, 4, 6, 8 …
So how to make two host consume one partition at the same time?
Thanks so much!