[event-hubs] fixes issue where processEvents ignores maxWaitTime after retryable disconnect event#12280
Conversation
|
/azp run js - eventhubs-client - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run js - eventhubs-client - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run js - eventhubs-client - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| 0, | ||
| "Expected to receive 0 events in second processEvents invocation." | ||
| ); | ||
| // The elapsed time since the last processEvents invocation should be >= maxWaitTimeInSeconds |
There was a problem hiding this comment.
Why? Shouldn't the subscribe end with the maxWaitTime?
There was a problem hiding this comment.
The maxWaitTimeInSeconds is the maximum time you should wait between processEvents invocations. The subscription runs forever unless explicitly closed.
There was a problem hiding this comment.
Yeah, I think you need to take it within the context of a subscribe call.
azure-sdk-for-js/sdk/eventhub/event-hubs/src/eventHubConsumerClient.ts
Lines 405 to 433 in 2425a88
If you understand that subscribe() receives events until it is closed, then 'passing the data to user code for processing' is a little less cryptic (though it could be even more clear if we called out processEvents explicitly here)
There was a problem hiding this comment.
I think I understand now.
The elapsed time since the last processEvents invocation should be >= maxWaitTimeInSeconds since there are no events to receive.
Previously, with the bug, the same test would go back to the start and would have received events.
There was a problem hiding this comment.
Actually, previously with the bug it was worse in that both maxWaitTimeInSeconds would be ignored, and no events would be received (so it just invoked processEvents repeatedly as fast as it could).
richardpark-msft
left a comment
There was a problem hiding this comment.
Some nits. I agree with @HarshaNalluru's comment and I think the test is a bit unclear.
The actual code change is pretty great though.
|
/azp run js - eventhubs-client - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Hello @chradek! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|

Fixes #12278
Description
This PR adds a check within the
PartitionPump's receive events loop to determine whether the receiver has been closed. If the receiver has been closed, it will create a new receiver using an event start position that matches the last event seen by the pump.The receiver is explicitly closed when a disconnected event is received on the underlying AMQP connection, which causes calls to
receiveBatchto immediately return any events it had collected up to this point. Note that once the receiver is closed, the receiver's onAmqpMessage handler is removed so it won't receive any additional events.Updates to testing
I manually tested the changes in this PR against the sample code in the linked issue.
I also updated the existing
disconnecttest to confirm thatmaxWaitTimeInSecondsis honoured after a disconnected event is encountered.processEventsinvocations.