Mark-VII
Mark-VII

Reputation: 373

how to get Azure Service Bus Queue response in json format

As I am new to Microsoft Azure. I just wanna know that how to get the response(receiving message) form the service bus queue in the JSON format.

Is their is any way to do so?

Please suggest with your valuable suggestion.

Upvotes: 0

Views: 1618

Answers (2)

Sean Feldman
Sean Feldman

Reputation: 26047

Documentation has a lot of information. As you've tagged Java, I assume you're looking on how to send/receive messages using Java client. A good starting point would be this documentation.

Content (body/payload) of Azure Service Bus message is stored in whatever format the original message was sent in. You can't pick a format and retrieve message body in that format. Depending on the original message was sent (using stream or an object) and the client, you'll have to receive the message and de-serialize it.

Another great resource is GitHub repo with Azure Service Bus samples in Java.

This should help you to familiarize yourself with Azure Service Bus and its Java Client.

Upvotes: 1

SumanthMarigowda-MSFT
SumanthMarigowda-MSFT

Reputation: 2354

For an example:

var getToken = function (queueName) {
     var uri = "http://" + serviceNamespace + environment + "/" + queueName;
     var endocedResourceUri = encodeURIComponent(uri.toLowerCase());
     var t0 = new Date(1970, 1, 1, 0, 0, 0, 0);
     var t1 = new Date();
     var expireInSeconds = +(31 * 24 * 3600) + 3600 +
    (((t1.getTime() - t0.getTime()) / 1000) | 0);
     var plainSignature = endocedResourceUri.toLowerCase() + "\n" + expireInSeconds;
     var hash = CryptoJS.HmacSHA256(plainSignature, sasKey);
     var base64HashValue = CryptoJS.enc.Base64.stringify(hash);
     var str = encodeURIComponent(base64HashValue);
     str = str.replace("%3D", "%3d");
     var token = "SharedAccessSignature sr=" + endocedResourceUri.toLowerCase() + "&sig=" +
     str + "&se=" + expireInSeconds + "&skn=" +
     sasKeyName;

     return token;
 }

https://github.com/ddobric/ServiceBusJavaScriptSdk/blob/master/ServiceBusJS/Scripts/servicebusjssdk-1.2.js

Additional information: http://fabriccontroller.net/iot-with-azure-service-bus-event-hubs-authenticating-and-sending-from-any-type-of-device-net-and-js-samples/

Upvotes: 1

Related Questions