Skip to content

added option to set the ReceiveMode of a service bus subscription#37

Merged
niemyjski merged 1 commit intoFoundatioFx:masterfrom
global-roam:master
Jun 17, 2021
Merged

added option to set the ReceiveMode of a service bus subscription#37
niemyjski merged 1 commit intoFoundatioFx:masterfrom
global-roam:master

Conversation

@jcono
Copy link
Copy Markdown
Contributor

@jcono jcono commented Jun 17, 2021

I have the need to ensure delivery of messages on the service bus and being able to configure the client to use ReceiveMode.PeekLock to guarantee delivery.

I think this change is all that is required. I'll admit that I haven't gone through thoroughly to see if there's any reason not to lock into using ReceiveMode.ReceiveAndDelete but as far as I can tell it should be fine.

Also I included usage of the cancellation token into creating the subscription which seemed to make sense as well.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jun 17, 2021

CLA assistant check
All committers have signed the CLA.

@niemyjski
Copy link
Copy Markdown
Member

LGTM, thanks for the pr! I'll merge this in but please leave a note how it works out for you. I'm wondering what will happen to the queue entries now that we don't delete them when we receive them (with your flag on).

@niemyjski niemyjski merged commit fba5fd9 into FoundatioFx:master Jun 17, 2021
@jcono
Copy link
Copy Markdown
Contributor Author

jcono commented Jun 17, 2021

I will let you know once I have tested but it's my understanding that the combination of ReceiveMode.PeekLock and MessageHandlerOptions.AutoComplete used when registering the message handler will result in SubscriptionClient.CompleteAsync being called once the handler successfully completes.

The source code for the message pump used by the subscription client would suggest this is the case too.

So as far as I can tell the message would be deleted from the queue so long as the registered handler doesn't throw an exception. At least that's how the comments in the code read (the Microsoft documentation is a little light on detail).

What I don't know yet is what happens in the event of an exception in the handler (meaning the message remains on the queue) and whether that message then gets delivered again (to the same receiver) once the peek lock is abandoned. For our usage I'm hoping it does.

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