putQMessage method
Put queue message
'qName': Name of the queue is mandatory.
'message': The message data is required
'vtimeout': Optional. If specified, the request must be made using an x-ms-version of 2011-08-18 or later. If not specified, the default value is 0. Specifies the new visibility timeout value, in seconds, relative to server time. The new value must be larger than or equal to 0, and cannot be larger than 7 days. The visibility timeout of a message cannot be set to a value later than the expiry time. visibilitytimeout should be set to a value smaller than the time-to-live value.
'messagettl': Optional. Specifies the time-to-live interval for the message, in seconds. Prior to version 2017-07-29, the maximum time-to-live allowed is 7 days. For version 2017-07-29 or later, the maximum time-to-live can be any positive number, as well as -1 indicating that the message does not expire. If this parameter is omitted, the default time-to-live is 7 days.
Implementation
Future<void> putQMessage({
required String qName,
int messagettl = 604800,
int vtimeout = 0,
required String message,
}) async {
String path = 'https://${config[accountName]}.queue.core.windows.net/$qName/messages?visibilitytimeout=$vtimeout&messagettl=$messagettl';
var request = http.Request('POST', Uri.parse(path));
request.body = '''<QueueMessage>
<MessageText>$message</MessageText>
</QueueMessage> ''';
_sign(request);
var res = await request.send();
if (res.statusCode >= 200 && res.statusCode < 300) {
return;
}
var rMessage = await res.stream.bytesToString(); //DEBUG
throw AzureStorageException(rMessage, res.statusCode, res.headers);
}