question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE REQ] Introduce abstraction similar to IMessageReceiver implemented by ServiceBusMessageActions

See original GitHub issue

Library name

Azure.Messaging.ServiceBus Microsoft.Azure.WebJobs.Extensions.ServiceBus

Please describe the feature.

Microsoft.Azure.ServiceBus had an IMessageReceiver interface that allows abandoning, completing, etc but has no equivalent in the Azure.Messaging.ServiceBus.

ServiceBusMessageActions (and one could argue other classes such as ServiceBusReceiver, ProcessMessageEventArgs, ProcessSessionMessageEventArgs) should implement an interface to allow abstraction.

Task AbandonMessageAsync(ServiceBusReceivedMessage message, IDictionary<string, object> propertiesToModify = null, CancellationToken cancellationToken = default);
Task CompleteMessageAsync(ServiceBusReceivedMessage message, CancellationToken cancellationToken = default) { throw null; }
Task DeadLetterMessageAsync(ServiceBusReceivedMessage message, IDictionary<string, object> propertiesToModify = null, CancellationToken cancellationToken = default);
Task DeadLetterMessageAsync(ServiceBusReceivedMessage message, string deadLetterReason, string deadLetterErrorDescription = null, CancellationToken cancellationToken = default);
Task DeferMessageAsync(ServiceBusReceivedMessage message, IDictionary<string, object> propertiesToModify = null, CancellationToken cancellationToken = default);
Task RenewMessageLockAsync(ServiceBusReceivedMessage message, CancellationToken cancellationToken = default);

This would essentially allow us to replace references to IMessageReceiver in Microsoft.Azure.ServiceBus with something new without having to introduce dependencies (and coupling) to Microsoft.Azure.Webjobs.Extensions.ServiceBus .

This might also help in addressing the testing concerns raised in #25375

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
4nandPcommented, May 4, 2022

How would you suggest writing a piece of functionality that will call for example Abandon that can be consumed by Microsoft.Azure.Webjobs.Extensions.ServiceBus but also be consumable by something using Azure.Messaging.ServiceBus directly (i.e. something agnostic of the hosting mechanism)? I fear the initial response is too focused on an aside about testing and mocking rather than the fact that I would have to otherwise introduce coupling with the webjobs packages.

This just pushes the concern to the consumer because we’d have to define the interface in our library that originally used IMessageReceiver and then implement it as a decorator around either ServiceBusReceiver or ServiceBusMessageActions as appropriate. That seems over the top vs implementing an interface within the framework for something that doesn’t seem to have changed much over the years. I’m trying to avoid coupling with the hosting layer so that the same library can be used by code running in a function app, console, docker etc, i.e. host agnostic.

/unresolve

0reactions
msftbot[bot]commented, May 6, 2022

Hi @4nandP. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Im not able to mock ServiceBusReceivedMessage and ...
With that fix, a parameterless constructor is available to ensure that ServiceBusMessageActions is usable with a mocking framework such as Moq ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found