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
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.
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.
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).
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.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With