Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

MessageSender.OnScheduleMessageAsync returns 0 when AmqpResponseStatusCode is not OK #456

Closed
fhyvrier opened this issue May 7, 2018 · 1 comment
Labels
Milestone

Comments

@fhyvrier
Copy link

fhyvrier commented May 7, 2018

Actual Behavior

Sometimes when QueueClient.ScheduleMessageAsync(Message, DateTimeOffset) is called, the returned sequence number is equal to 0, and the message is not added to the queue.

I had a look at the code and found that in method MessageSender.OnScheduleMessageAsync(Message), if the status of the AmqpResponseMessage is not AmqpResponseStatusCode.OK, a MessagingContractException is created, but never thrown. As a result, the caller receives 0 as a sequence number and has to test this value in order to determine wether the scheduling succeeded or not.

Expected Behavior

I suppose the MessagingContractException should be thrown when AmqpResponseMessage.StatusCode is not AmqpResponseStatusCode.OK.

Also, the current return statement return sequenceNumbers?.FirstOrDefault() ?? 0; makes me wonder if it's really possible for an AmqpResponse to contain zero sequence numbers (or several), when the operation is a ScheduleMessageOperation and it succeeded.

Versions

  • OS platform and version: N/A.
  • .NET Version: N/A.
  • NuGet package version: Microsoft.Azure.ServiceBus 2.0.0.
@nemakam
Copy link
Contributor

nemakam commented May 7, 2018

@fhyvrier
Thanks for debugging through the code and pointing out the exact error.

if it's really possible for an AmqpResponse to contain zero sequence numbers (or several), when the operation is a ScheduleMessageOperation and it succeeded.

Ideally, no. That should not happen. But the null checks there are just defensive coding. To think of it, throwing would be a better option than returning 0 even in that case. Will update the code accordingly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants