Example #1
0
        private async Task <Message> CreateMessageWithBlobStorageAsync(Message message, string content, CancellationToken cancellationToken)
        {
            var key = content.Substring(BlobMessagePublisher <T> .StorageKey.Length + 1);

            using (var stream = await _blobContainer.OpenReadAsync(key, cancellationToken))
            {
                byte[] buffer = new byte[16 * 1024];
                using (var memoryStream = new MemoryStream())
                {
                    int read;
                    while ((read = await stream.ReadAsync(buffer, 0, buffer.Length)) > 0)
                    {
                        memoryStream.Write(buffer, 0, read);
                    }

                    var properties = message.Properties.ToDictionary(p => p.Key, p => p.Value);
                    properties[BlobMessagePublisher <T> .StorageKey] = key;

                    return(new Message(message.Id, memoryStream.ToArray(), properties, message.SystemProperties, message.PartitionId));
                }
            }
        }
 public virtual Task <Stream> OpenReadAsync(string path, CancellationToken cancellationToken = default)
 {
     return(_blobContainer.OpenReadAsync(path, cancellationToken));
 }