I am new to implementation and understanding of Event hub. I followed the instructions from microsoft document enter link description here
However when I run my receiver code , I am facing the following error.
Caused by: com.azure.core.amqp.exception.AmqpException: Receiver 'nil' with a higher epoch '4' already exists. Receiver 'nil' with epoch 0 cannot be created. Make sure you are creating receiver with increasing epoch value to ensure connectivity, or ensure all old epoch receivers are closed or disconnected.
Could anyone suggest the cause and how I could resolve this error?
Thank you
This exception indicates that there is already another consumer in your configured consumer group that is asserting exclusive ownership over the partition that you are attempting to read. Most often, these are Event Processor types as they use the Owner Level (epoch in the error message) mechanism to help control load balancing.
In your case, seeing that there's a consumer with an owner level of 4 running and the new instance is using an owner level of 0, my best guess is that you've got an EventProcessorHost
from the legacy Microsoft.Azure.EventHubs
SDK running against that Event Hub and Consumer Group pairing, and that you're attempting to use a processor from the Azure.Messaging.EventHubs
SDK with the same configuration. If that is the case, it's important to know that processors from the two different SDK generations are not compatible and won't collaborate together in a single processor cluster; instead, they'll compete for ownership.
Mitigation will be to either stop the other consumer(s) or to run your new consumer in a different consumer group.