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.

[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

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:open
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
richardpark-msftcommented, Feb 25, 2021

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.

0reactions
richardpark-msftcommented, Jul 7, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

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