Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while deserializing Azure ServiceBus Queue message sent from node.js (azure sdk)

Here's my scenario:

I'm sending an Azure ServiceBus Queue message from Node.js using the node azure sdk like so:

var message = {
    body: JSON.stringify({ foo: 'Bar' })
};

serviceBusService.sendQueueMessage('myQueue', message, function (error) {
    if (!error) {
        console.log('msessage sent');
    }
});

I have a c# worker role that is listening to the Queue:

QueueClient Client = QueueClient.CreateFromConnectionString(connStr, QueueName);

Client.OnMessage((receivedMessage) =>
{
    var body = receivedMessage.GetBody<string>();
});

When the GetBody method gets executed, i get the following error:

There was an error deserializing the object of type System.String. The input source is not correctly formatted

like image 533
ctv Avatar asked Feb 20 '15 19:02

ctv


People also ask

How do I process messages in dead letter queue Azure?

To receive messages from DLQ through SB explorer, you need to click on that particular queue and then click on “Deadletter” tab then one dialogue box will pop up then you need to click on “Receive and Delete”. The default value is Top10 so top10 messages will be received from DLQ.

How do you clear the dead letter queue in Azure Service Bus?

Basically you connect to your Dead Letter Queue in exactly the same way as your normal queue, but you need to contatenate “$DeadLetterQueue” to the queue name. After running the following code in my unit test I successfully managed to clear all the messages from my Dead Letter Queue.

Should ServiceBusClient be Singleton?

The Service Bus objects that interact with the service, such as ServiceBusClient, ServiceBusSender, ServiceBusReceiver, and ServiceBusProcessor, should be registered for dependency injection as singletons (or instantiated once and shared).

What are user errors in Azure Service Bus?

User errors generally occur due to mistakes in the client application like, InvalidOperationException, The requested user operation is not allowed within the server or service. For example, Complete() generates InvalidOperationException if the message was received in ReceiveAndDelete mode.


1 Answers

To anyone who found this question if they were getting this error from sending the message using Service Bus Explorer (like me).

Make sure you specify the correct message type in the drop down: enter image description here

like image 90
David Klempfner Avatar answered Oct 02 '22 23:10

David Klempfner