[Service Bus] How to properly deserialize application properties of a message?
See original GitHub issue- Package Name:
- @azure/service-bus
- Package Version:
- 7.0.3
- Operating system:
- MacOS
- nodejs
- version: 14.15.1
- browser
- name/version:
- typescript
- version:
- Is the bug related to documentation in
- README.md
- source code documentation
- SDK API docs on https://docs.microsoft.com
Describe the bug
When sending a message to a queue, we are setting one of the application properties of type Date
. However when we receive the message, we get that application property as number
. How can we properly deserialize that property to Date
type.
To Reproduce Please see this sample code:
const { ServiceBusClient } = require("@azure/service-bus");
const connectionString = 'connection-string';
const client = new ServiceBusClient(connectionString);
const sender = client.createSender('test');
const msg = {
body: 'This is a test',
applicationProperties: {
'bool': true,
'number': 123,
'string': 'some string',
'date': new Date(),
'number2': 1614257296160
}
};
console.log('msg');
console.log(msg);
console.log('===========================');
sender.sendMessages([msg]);
console.log('message sent...')
console.log('===========================');
const receiver = client.createReceiver('test');
receiver.receiveMessages(1)
.then((result) => {
console.log(result[0].applicationProperties);
})
.catch((error) => {
console.log(error);
});
Expected behavior
Printing msg
to console prints the following:
{
body: 'This is a test',
applicationProperties: {
bool: true,
number: 123,
string: 'some string',
date: 2021-02-25T13:17:48.085Z,
number2: 1614257296160
}
}
However when we receive the message and print the applicationProperties
to console, we get the following:
applicationProperties: {
bool: true,
number: 123,
string: 'some string',
date: 1614259068085,
number2: 1614257296160
}
Additional context When I view the message in Service Bus Explorer, it gets deserialized properly.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Azure ServiceBus Message Serialization/Deserialization
It is possible to use JSON serialization to enable transferring these objects/entities. Assume the following class is the type of which ...
Read more >Azure Service Bus messages, payloads, and serialization
This article provides an overview of Azure Service Bus messages, payloads, message routing, and serialization.
Read more >ServiceBusMessage (Azure SDK for Java Reference ... - NET
The data structure encapsulating the message being sent-to Service Bus. Here's how AMQP message sections map to ServiceBusMessage .
Read more >Certain byte values in Message.Body throw deserialization ...
Host: Exception binding parameter 'message'. Microsoft.Azure.WebJobs.ServiceBus: The Message with ContentType 'null' failed to deserialize to a ...
Read more >Reliable Messaging using Azure Functions and Service Bus
In this presentation, we will demonstrate how to construct messaging listeners known as triggers, as well as how to easily send messages ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @gmantri, this conversion happens a bit lower in the stack (in the
rhea
package). I’ve opened up a thread there to see what can be done.Transferring this to @chradek as he is the new Service Bus package maintainer.
I will note the change has made it’s way into
rhea
and has been absorbed into Service Bus. We need to understand how to properly expose it, however, as exposing it directly would be a breaking change.