Skip to content
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

[service-bus] Track 2 - port sender.open() #8636

Conversation

richardpark-msft
Copy link
Member

Port the important bits from #8329, which added an .open() method to the Sender for track 1.

The main difference here is that ServiceBusClient calls open() on the sender internally, which means we don't need to expose it on the Sender interface.

@richardpark-msft
Copy link
Member Author

/azp run js - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -242,15 +242,17 @@ export class ServiceBusClient {
* Creates a Sender which can be used to send messages, schedule messages to be sent at a later time
* and cancel such scheduled messages.
*/
createSender(queueOrTopicName: string): Sender {
async createSender(queueOrTopicName: string): Promise<Sender> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the docs be updated to mention that the sender will be automatically opened when created? This does mean they'd need to explicitly close the sender (or client) if they didn't want it to keep the process open anymore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting. I mean, technically there was no reason for them not to call close() before but, as you're pointing out, they didn't have to.

I can update the doc comment (not sure what I'll write there yet?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's not super important if we treat this as a new API and that's the behavior (we can mention it in a migration guide for existing users). But it might be worth saying something about the fact that a connection with the service is established if the motivation for this change is that customers want to know if the connection is open or not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, adding it to the migration guide is a good idea.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migration guide updated and, thanks to you, I remembered to update the samples as well!

validateEntityNamesMatch(this._connectionContext.config.entityPath, queueOrTopicName, "sender");

const clientEntityContext = ClientEntityContext.create(
queueOrTopicName,
this._connectionContext,
`${queueOrTopicName}/${generate_uuid()}`
);
return new SenderImpl(clientEntityContext, this._clientOptions.retryOptions);
const sender = new SenderImpl(clientEntityContext, this._clientOptions.retryOptions);
await sender.open();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So with this change, if the sender can't be opened, then the user doesn't get a sender at all and instead get an error right? Is that intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original motivation for this was to front-load the work but we had another issue where people wanted a deterministic way to make sure that the connection was actually loaded up and running.

So yes, intentional and you're right, they won't be able to get a sender.

Copy link
Contributor

@chradek chradek Apr 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

people wanted a deterministic way to make sure that the connection was actually loaded up and running

Is this meant only for when the sender is 1st created? I ask since it's possible for the connection to be lost at any point after the sender is created.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only meant for when the sender is first created.

However, you brought up a good point that lazy connect would often use retries. So that has now been added :)

@richardpark-msft
Copy link
Member Author

/azp run js - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

validateEntityNamesMatch(this._connectionContext.config.entityPath, queueOrTopicName, "sender");

const clientEntityContext = ClientEntityContext.create(
queueOrTopicName,
this._connectionContext,
`${queueOrTopicName}/${generate_uuid()}`
);
return new SenderImpl(clientEntityContext, this._clientOptions.retryOptions);
const sender = new SenderImpl(clientEntityContext, this._clientOptions.retryOptions);
await sender.open();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This open() should respect the retry options passed to the client

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

@richardpark-msft
Copy link
Member Author

/azp run js - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@richardpark-msft
Copy link
Member Author

/azp run js - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@richardpark-msft
Copy link
Member Author

/azp run js - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@ramya-rao-a ramya-rao-a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Havent looked at the test files, but rest of the changes look good.
Please wait for a review from @HarshaNalluru and @chradek before merging

…ore we've had a chance to mock anything.

Changing to simulate the connection being closed so open() will get called (and fail properly in our mock)
@richardpark-msft
Copy link
Member Author

/azp run js - servicebus - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@chradek chradek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Tests look valid as well 😄

/**
* The signal which can be used to abort requests.
*/
abortSignal?: AbortSignalLike;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question that doesn't need to be resolved now, but are we planning to have retry options here as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be discussed with the broader team.

@richardpark-msft richardpark-msft merged commit d0ad83c into Azure:master May 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants