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.

[ServiceBus] ServiceBusMessage.clone() is not a pure immutable clone

See original GitHub issue
  • Package Name: service-bus
  • Package Version: 1.1.7 (but preview as well)
  • Operating system:
  • nodejs
    • version:
  • browser
    • name/version:
  • typescript
    • version:

Describe the bug When cloning a message the userProperties object is copied, not cloned.

Expected behavior Object should be cloned, or at least express that it is a shallow clone

https://github.com/Azure/azure-sdk-for-js/blob/e51a1d464e74be914f2e40bfd5c36d1fc2a4240c/sdk/servicebus/service-bus/src/serviceBusMessage.ts#L1025

Because ServiceBusMessage is built out of transported date (JSON) it is safe to assume it does not contain circular references, if you are willing to freeze it when creating it…

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
richardpark-msftcommented, Jul 9, 2020

This logic shouldnt be out for guess, it should be managed by the library.

Oh, definitely!

I wasn’t clear above but this is built-in and done internally in the Sender - if it was anything but that it’d be completely incorrect for us to claim clone() is obsolete/unneeded.

So you can just pass the message you received to all the send APIs and it will work.

Some example code:

// method of receiving doesn't matter
for await (const message of receiver.getMessageIterator()) {
  await message.complete();

  await sender.send(message);
  await sender.scheduleMessage(new Date(), message);
}
0reactions
richardpark-msftcommented, Jul 15, 2020

Going to close this issue, please let me know if you have more questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to clone message in Azure.Messaging.ServiceBus ...
The Clone() method is not there anymore. Instead you can use the new constructor overload that takes a recieved message.
Read more >
Message.Clone Method (Microsoft.Azure.ServiceBus)
Clones a message, so that it is possible to send a clone of an already received message as a new message. The system...
Read more >
Immutable.js
Immutable data cannot be changed once created, leading to much simpler application development, no defensive copying, and enabling advanced memoization and ...
Read more >
Using Immutable Data Structures in C# and .NET - YouTube
Immutable objects - aka objects whose properties and fields can't change after instantiation - are one of the fundamental pillars of ...
Read more >
Kombu Documentation - Read the Docs
Create a copy of the connection with same settings. info() ... Azure Service Bus Message Queue transport module for kombu.
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