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.

[Discussion] Service Bus - Track 2 - Message Settlement Location

See original GitHub issue

The intent of this issue is to solicit feedback from the community in advance of the GA of the next major version of the Service Bus library (which will follow several Preview releases). As a reference, the .NET Azure SDK guidelines can be found here: https://azure.github.io/azure-sdk/dotnet_introduction.html Terminology: Track 0 refers to the WindowsAzure.ServiceBus library Track 1 refers to the Microsoft.Azure.ServiceBus library Track 2 refers to the new library, Azure.Messaging.ServiceBus, we are working on releasing.

Background Settlement refers to the operations that can be used to settle a message. These are Complete, Abandon, Defer, and Dead Letter. In version 4 of the Service Bus library, the settlement methods are located directly on the client types. In an earlier version of the library, the settlement methods were on the message. We would like to explore the pros and cons of placing the settlement methods in each place.

Lock token overloads We are planning to include both lock token and message overloads for settlement. The lock token overload is useful for cases where the user may not want to hold onto the entire message before settling. By putting these on the receiver, we would be able to put the overloads on the same type.

var client = new ServiceBusClient("connectionString");
ServiceBusReceiver receiver = client.GetReceiver("myQueue");
ServiceBusReceivedMessage message = await receiver.ReceiveAsync();
// message overload
await receiver.CompleteAsync(message);
// lock token overload 
await receiver.CompleteAsync(message.LockToken);

If we put the settlement methods on the message, we would need to split out the location of the lock token overload:

await message.CompleteAsync();
await receiver.CompleteAsync(message.LockToken);

Batch overloads Similar to the point about lock token overloads, batch versions of the settlement methods would have to be placed on the receiver. So if we put the single message settlement on the message itself we would end up with something like this:

IList<ServiceBusReceivedMessage> messages = await receiver.ReceiveBatchAsync(maximumMessageCount: 10);
// using the single message settlement
foreach (var message in messages)
{
    await message.CompleteAsync();
}
// or with the batch version
await receiver.CompleteAsync(messages);

Other considerations Another issue to consider is how users might think about a settlement method in the context of the ServiceBusReceivedMessage type. Might they think that they are performing a local operation rather than a service call, since they are not calling the method from the receiver type? Also, separating out the settlement methods from the receiver might lead users to believe that they can safely dispose of the receiver before settling the message. This isn’t the case as the message would still be using the receiver’s underlying link to do the message settlement.

One argument in favor of settlement methods being placed on the message, is that it allows for somewhat simpler user code. For instance, users wouldn’t need to pass both the receiver and message along to any method that they write for processing a received message.

Conclusion In spite of some of the simplifying benefits that placing settlement methods on the message allows, we are planning to put the settlement methods on the receiver. This allows for a consistent API when considering the lock token and batch settlement methods. It is also more consistent with the other new Azure SDK libraries, where service operations are generally located on the client types.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
SeanFeldmancommented, Mar 26, 2020

Track 0 had settlement operations on the BrokeredMessage. Track 1 had settlement operations on the clients (receivers).

After using both variants my conclusion that the desire to simplify things should not blind the users. While the API might be interpreted as easier to grasp, there’s the undeniable need to understand how the service works. A Message is never settled on the client. A message is a loaner copy given to the client. The broker is responsible for the settlement and it doesn’t care about message ID or any other property. Except for lock token.

In addition to that, adding the settlement responsibility to the ServiceBusReceivedMessage will turn it from a simple DTO to a type with cross-cutting concerns it shouldn’t have.

The arguments against having settlement methods on the message exceed the negatives associated with the settlement methods on the clients. Personally, I fully agree with the conclusion.

1reaction
danielmarbachcommented, Apr 28, 2020

I share the conclusion. I do agree the current design makes sense. The only other option apart from the one you mentioned I see would be to expose a behavior component as a property on the event args which then users have to transitively navigate into. That though wouldn’t allow to set the property on the args and in general I’m not a huge fan of transitive dependency train wrecks

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Discussion] Service Bus - Track 2 - Message Settlement # ...
This issue is focused on the mechanisms for settling a message during receipt (close, abandon, deadletter, defer). Background: The Track1 python ...
Read more >
Message replication and cross-region federation - Azure ...
This article provides an overview of event replication and cross-region federation with Azure Service Bus.
Read more >
Azure Service Bus Essentials — Message Settlement with ...
In this post, we'll discuss the message settlement options available at Azure Service Bus. Receive-and-Delete and Peek-Lock modes. To consume ...
Read more >
$19 million settlement proposed in NYC charter bus class ...
NEW YORK (Reuters) - Riders of two New York City tour bus companies have proposed a $19 million settlement to end a class-action...
Read more >
Should Public Buses Be Free?
Boston is piloting three zero-fare public bus routes, and New York City is expected to test free buses on five lines.
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