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

[BUG] ServiceBusMessageBatch does not preserve message order reliably #25112

Closed
paulbandler opened this issue Oct 29, 2021 · 5 comments · Fixed by #27366
Closed

[BUG] ServiceBusMessageBatch does not preserve message order reliably #25112

paulbandler opened this issue Oct 29, 2021 · 5 comments · Fixed by #27366
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus
Milestone

Comments

@paulbandler
Copy link

Describe the bug
When the ServiceBusMessageBatch class is used to send batches of ServiceBus messages, the order of adding the messages to the ServiceBusMessageBatch object is not reliably the order the messages are added to the destination queue.

Exception or Stack Trace
Add the exception log and stack trace if available

To Reproduce
It was confirmed by testing and comparing the resulting order of the messages on the queue. When not using ServiceBusMessageBatch the send order was reliably the message order on the queue, but when using ServiceBusMessageBatch the order was frequently not preserved, leading to erroneous processing by the received.

Code Snippet
I have a simple wrapper around the ServiceBus client that enable switching between batched sends and un-batched sends - the actual send method looks like this:
void sendMessage(ServiceBusMessage serviceBusMessage){
if(!batchingEnabled) {
log.trace("Send single service bus messages to {}", getNameQualifier());
senderClient.sendMessage(serviceBusMessage);
} else {
if(!serviceBusMessageBatch.get().tryAddMessage(serviceBusMessage)){
flush();
if(!serviceBusMessageBatch.get().tryAddMessage(serviceBusMessage)){
String msg = String.format("Unable to add SB message to batch - too large - %d?", serviceBusMessage.getBody().toBytes().length);
ServiceBusSink.this.senderClient = null;
throw new RuntimeException(msg);
}
}
}
}

Expected behavior
Batches of messages assembled using ServiceBusMessageBatch should be written to the destination queue in the order in which they are added to the ServiceBusMessageBatch object.
Screenshots
If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • OS: Linux in K8S Container
  • IDE: n/a
  • Library/Libraries: com.azure:azure-messaging-servicebus:7.4.2
  • Java version: 11
  • App Server/Environment: AKS Pod
  • Frameworks: Micronaut,

If you suspect a dependency version mismatch (e.g. you see NoClassDefFoundError, NoSuchMethodError or similar), please provide

  • verbose dependency tree (mvn dependency:tree -Dverbose)

Additional context
Add any other context about the problem here.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • [ X] Bug Description Added
  • [ X] Repro Steps Added
  • [ X] Setup information Added
@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Oct 29, 2021
@joshfree joshfree added Client This issue points to a problem in the data-plane of the library. Service Bus labels Oct 29, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Oct 29, 2021
@joshfree
Copy link
Member

@ki1729 can you please follow up with @paulbandler?

@joshfree
Copy link
Member

joshfree commented Dec 9, 2021

@ki1729 can you please give an update?

@ki1729
Copy link
Contributor

ki1729 commented Dec 10, 2021

Sure Josh, the fix for this causes a significant hit in performance, but giveth that this is a fix and not a perf enhancement, will be going ahead with it. This fix should be done and hopefully be out in the Jan release of the sdk

@ramya-rao-a ramya-rao-a added this to the [2022] February milestone Jan 13, 2022
@paulbandler
Copy link
Author

Has there been any progress on this issue?

@ki1729
Copy link
Contributor

ki1729 commented Mar 1, 2022

@paulbandler The changes are merged, so it should be a part of the the March release

@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants