コード例 #1
0
        private CloudQueueMessage PrepareCloudMessage(byte[] buffer)
        {
            if (buffer.Length < AzureMessageOverflows.CloudQueueLimit)
            {
                // write queue to queue
                return(new CloudQueueMessage(buffer));
            }
            // ok, we didn't fit, so create reference queue
            var referenceId = DateTimeOffset.UtcNow.ToString(DateFormatInBlobName) + "-" + Guid.NewGuid().ToString().ToLowerInvariant();

            this._cloudBlob.GetBlockBlobReference(referenceId).UploadFromByteArray(buffer, 0, buffer.Length);
            var reference = new EnvelopeReference(this._cloudBlob.Uri.ToString(), referenceId);
            var blob      = AzureMessageOverflows.SaveEnvelopeReference(reference);

            return(new CloudQueueMessage(blob));
        }
コード例 #2
0
        MessageTransportContext DownloadPackage(CloudQueueMessage message)
        {
            var buffer = message.AsBytes;

            EnvelopeReference reference;

            if (AzureMessageOverflows.TryReadAsEnvelopeReference(buffer, out reference))
            {
                if (reference.StorageContainer != _cloudBlob.Uri.ToString())
                {
                    throw new InvalidOperationException("Wrong container used!");
                }
                var blob = _cloudBlob.GetBlobReference(reference.StorageReference);
                buffer = blob.DownloadByteArray();
            }
            return(new MessageTransportContext(message, buffer, _queueName));
        }