static async Task <DataBusAttachment> CreateAttachment(IDataBus dataBus, string text, Dictionary <string, string> optionalMetadata = null)
 {
     using (var source = new MemoryStream(Encoding.UTF8.GetBytes(text)))
     {
         return(await dataBus.CreateAttachment(source, optionalMetadata));
     }
 }
예제 #2
0
    async Task DehydrateTransportMessage(OutgoingStepContext context, TransportMessage transportMessage)
    {
        var messageId = transportMessage.GetMessageId();

        try
        {
            using (var source = new MemoryStream(transportMessage.Body))
            {
                var attachment = await _dataBus.CreateAttachment(source);

                var headers = transportMessage.Headers.Clone();

                headers[Headers.MessagePayloadAttachmentId] = attachment.Id;

                context.Save(new TransportMessage(headers, EmptyMessageBody));
            }
        }
        catch (Exception exception)
        {
            throw new RebusApplicationException(exception,
                                                $"Could not create (automatic claim check) attachment for outgoing message with ID {messageId}");
        }
    }