-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Event Hubs] Improve the current implementation of Sender #3375
Comments
This can be done using the new awaitable sender introduced in amqp/rhea-promise#44 right? |
Yes, it should be possible to do that. Notable differences in Catching Errors and retrying the sendThe current In actionAfterTimeout, in SB and EH we throw Handling
|
Based on the discussion here so far here's my summary: OverviewWe should switch to using the Current StateLink recreation
We don't attempt to recreate a link on session or sender errors. Retry logicWe currently rely on the Sender detailsWe use an event-based sender and attach the following event handlers each time we call send:
None of these check if the error is retryable directly, instead leaving that to the Proposed ChangesSender to AwaitableSender
Send implementationUpdate to wrap the awaitable send method in a new Promise. We need to keep 3 features in mind:
To support these 3 features, we'll need to create a new Promise that wraps the awaitable send call as we do today. CancellationThe awaitable send method doesn't accept an abort signal. We can either update Retryable errorsWe can continue to rely on the TimeoutWe can handle timeouts the same as we do currently. QuestionsDid |
As we discussed offline while working on amqp/rhea-promise#42, we arrived at the conclusion that
A sender_error event is always followed by a sender_close event |
Following are some notes on the implementation at - #4446
Also, discussed offline with @ramya-rao-a about having a sample/repro to verify the original problem being solved, and so below is the sample being used to test. Based on the value supplied for With changes in linked PR, this test failed previously and now succeeds, validating our approach! const senderCount = 1200;
try {
const producer = client.createProducer();
const promises = [];
for (let i = 0; i < senderCount; i++) {
debug(">>>>> Sending a message to the hub when i == %d", i);
promises.push(producer.send([{ body: `Hello World ${i}` }]));
}
await Promise.all(promises);
} catch (err) {
debug("An error occurred while running the test: ", err);
throw err;
} |
@chradek @ramya-rao-a let me know if there are any other comments on this. Looks like amqp/rhea-promise#48 is related and takes care of the updates to |
Good point on timeout being configured at sender creation time. Logged amqp/rhea-promise#49 For now, lets use the approach as described in #4446 (comment) |
#4446 is now merged. @ramya0820 You have a test case mentioned in the comment above. Can you please send a PR that adds that test to our code before closing this issue? |
Sent #4637 In sender tests, 2 of them are failing - to do with message size checks, currently skipped these in this PR. cc: @ShivangiReja Receiving a |
@ramya0820 We can get the original error from the innerError field. So the change in
to |
The current sender has a promise wrapper around the rhea sender which is based on event emitter pattern. Every time a message is sent, event handlers are added and removed and the promise is resolved or rejected based on the type of event received. This design works well as long as the customer is awaiting on the previous send (i.e an eventhub client is sending one message at a time).
If too many messages are sent, then this causes the node.js error
too many listeners attached, by default only 11 (max) are allowed
.A better appraoch would be add all the event handlers at the time of creating the sender link and then maintaining an internal map of the messages being sent. The promises would be resolved or rejected based on the type of event received.
Things that make this approach a little complex are:
The text was updated successfully, but these errors were encountered: