// Demonstrates how to send a message
// Here we set the messagy body. This will be message payload.
var msgBody = { "message": txtMsg.value, "id": 1234 };
// Here we add two custom properties.
var props = [{ 'Name': 'Property1', 'Value': 'Hello' },
{ 'Name': 'Property2', 'Value': 1234 }]
// Message corresponds the BrokeredMessage from .NET SDK.
var msg = new BrokeredMessage(msgBody, props);
// This sends the message to the queue and registers the
// the callback to receive the result.
queueClient.sendMessage(msg, function (messagingResult) {
$("#result").html(messagingResult.result);
}, "application/json");
queueClient.receiveMessage(function (messagingResult) {
$("#result").html(messagingResult.brokeredMessage.body);
if (messagingResult.brokeredMessage.properties != null &&
messagingResult.brokeredMessage.properties.brokerProperties != null) {
$("#msgId").html(messagingResult.brokeredMessage.properties.brokerProperties.MessageId);
$("#txtMsgLockUri").val(messagingResult.brokeredMessage.properties.Location);
}
else
$("#msgId").html("No messages in queue.");
});
queueClient.peekLockMessage(function (messagingResult) {
$("#result").html(messagingResult.brokeredMessage.body);
if (messagingResult.brokeredMessage.properties != null &&
messagingResult.brokeredMessage.properties.brokerProperties != null) {
$("#msgId").html(messagingResult.brokeredMessage.properties.brokerProperties.MessageId);
$("#txtMsgLockUri").val(messagingResult.brokeredMessage.properties.Location);
}
});
Message URI
queueClient.completeMessage(txtMsgLockUri.value, function (messagingResult) {
$("#result").html(messagingResult.brokeredMessage.body);
if (messagingResult.brokeredMessage.properties != null &&
messagingResult.brokeredMessage.properties.brokerProperties != null) {
$("#msgId").html(messagingResult.brokeredMessage.properties.brokerProperties.MessageId);
}
});
queueClient.abandonMessage(txtMsgLockUri.value, function (messagingResult) {
$("#result").html(messagingResult.brokeredMessage.body);
if (messagingResult.brokeredMessage.properties != null &&
messagingResult.brokeredMessage.properties.brokerProperties != null) {
$("#msgId").html(messagingResult.brokeredMessage.properties.brokerProperties.MessageId);
}
});