After verifying with internal sources here is some additional info:
- Azure SDK team released a new version (v5.2.1) of the event-hubs package this week that has some improvements around recovering from connection issues that the customers/users should consider upgrading to.
• Changelog: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/eventhub/event-hubs/CHANGELOG.md#521-2020-06-08 - When receiving events, the user doesn't need to retry in the event an error occurs, the
EventHubConsumerClient
will automatically retry.
• This works in two different ways depending on if the error that's shown inprocessError
has itsretryable
field set totrue
or not.
• Iferror.retryable
isundefined
orfalse
, then the client will next callprocessClose
if the user has provided it.
• If the user is using a checkpointstore (e.g. eventhubs-checkpointstore-blob) to store event checkpoints, then after ~10 seconds, the client will check if any other clients have started reading from the partition that received an error, and if not, attempt to read again. If the user is not using a checkpointstore, then after ~10 seconds the client will attempt to read again regardless.
• At this point, the user'sprocessInitialize
will be called, and then the user should start seeing events as they become available.
• One thing to note though is that in this process, the client will resume reading events from the last known checkpoint for the partition. If the user isn't callingcontext.updateCheckpoint(event)
in their code, then this resume from thestartPosition
, which is defaulted tolatest
.
• Iferror.retryable
istrue
, then the process is simpler. The client won't callprocessClose
, and instead continue attempting to read events from where it left off.
• The user may pass in retryOptions to theEventHubConsumerClient
constructor if they want to tweak the defaults, but the client will always attempt to retry as described above until the user callssubscription.close()
.
• EventHubConsumerClient options: https://video2.skills-academy.com/en-us/javascript/api/@azure/event-hubs/eventhubconsumerclient?view=azure-node-latest#eventhubconsumerclient-string--string--checkpointstore--eventhubclientoptions- - The timeout isn't currently configurable, but is set to 60 seconds.
- The EventHubConsumerClient will not close automatically when there is no data available. The user will actually see
processEvents
called periodically (60 seconds by default) with an empty array if no events are available.
Hope this info helps.
Thank you
Please do consider to click on "Accept Answer" and "Up-vote" on the post that helps you, as it can be beneficial to other community members.