public async Task Handle(SendMessage message, IMessageHandlerContext context) { var withAttachment = await context.Attachments().GetBytes("withMetadata"); Assert.Equal("value", withAttachment.Metadata["key"]); var replyOptions = new ReplyOptions(); var outgoingAttachment = replyOptions.Attachments(); outgoingAttachment.Add(() => { var incomingAttachment = context.Attachments(); return(incomingAttachment.GetStream()); }); await context.Reply(new ReplyMessage(), replyOptions); }
public async Task Handle(AMessage message, IMessageHandlerContext context) { var attachment = context.Attachments(); var bytes = await attachment.GetBytes(); Trace.WriteLine(bytes); }
public async Task Handle(ReplyMessage message, IMessageHandlerContext context) { var incomingAttachments = context.Attachments(); var attachment = await incomingAttachments.GetBytes("bar"); Console.WriteLine($"Hello from MyHandler. ReplyMessage. bytes: {attachment.Bytes.Length}"); }
public Task Handle(MyMessage message, IMessageHandlerContext context) { log.Info("MyMessage received. Attachment will be streamed to the console."); var attachments = context.Attachments(); return(attachments.ProcessStream( name: "attachmentName", action: async stream => { using (var reader = new StreamReader(stream)) { while (true) { var line = await reader.ReadLineAsync() .ConfigureAwait(false); if (line == null) { break; } Console.WriteLine(line); } } })); }
public async Task Handle(MyMessage message, IMessageHandlerContext context) { var incomingAttachments = context.Attachments(); var bytes = await incomingAttachments.GetBytes("attachment1") .ConfigureAwait(false); // use the byte array }
public async Task Handle(MyMessage message, IMessageHandlerContext context) { var incomingAttachment = context.Attachments(); Assert.NotNull(await incomingAttachment.GetBytes("fooFile")); Assert.NotNull(await incomingAttachment.GetBytes()); Assert.Equal("Value", message.Property); resetEvent.Set(); }
public Task Handle(SendMessage message, IMessageHandlerContext context) { var replyOptions = new ReplyOptions(); var outgoingAttachment = replyOptions.Attachments(); var incomingAttachment = context.Attachments(); outgoingAttachment.Add(incomingAttachment.GetStream); return(context.Reply(new ReplyMessage(), replyOptions)); }
public Task Handle(SampleMessage message, IMessageHandlerContext context) { Console.WriteLine("MyHandler"); foreach (var header in context.MessageHeaders) { Console.WriteLine($"{header.Key.Replace("NServiceBus.","")}={header.Value}"); } return(context.Attachments().ProcessStreams(WriteAttachment)); }
public async Task Handle(SendMessage message, IMessageHandlerContext context) { var incomingAttachment = context.Attachments(); using (var stream = await incomingAttachment.GetStream()) { Debug.WriteLine(stream); } IntegrationTests.SagaEvent.Set(); }
public async Task Handle(MyMessage message, IMessageHandlerContext context) { var incomingAttachments = context.Attachments(); using (var fileToCopyTo = File.Create("FilePath.txt")) { await incomingAttachments.CopyTo("attachment1", fileToCopyTo) .ConfigureAwait(false); } }
public Task Handle(SampleMessage message, IMessageHandlerContext context) { log.Info("SampleMessage received"); log.Info($"Property={message.Property}"); foreach (var header in context.MessageHeaders) { var headerSuffix = header.Key.Replace("NServiceBus.", ""); log.Info($"{headerSuffix}={header.Value}"); } return(context.Attachments().ProcessStreams(WriteAttachment)); }
public async Task Handle(MyMessage message, IMessageHandlerContext context) { var incomingAttachments = context.Attachments(); await incomingAttachments.ProcessStreams( action : async(name, stream) => { using (var fileToCopyTo = File.Create($"{name}.txt")) { await stream.CopyToAsync(fileToCopyTo) .ConfigureAwait(false); } }); }
public async Task Handle(MyMessage message, IMessageHandlerContext context) { Console.WriteLine("Hello from MyHandler."); using (var memoryStream = new MemoryStream()) { var incomingAttachments = context.Attachments(); await incomingAttachments.CopyTo("foo", memoryStream); memoryStream.Position = 0; var buffer = memoryStream.GetBuffer(); Debug.WriteLine(buffer); } }
public async Task Handle(MyMessage message, IMessageHandlerContext context) { var incomingAttachments = context.Attachments(); await incomingAttachments.ProcessStream( name : "attachment1", action : async stream => { // Use the attachment stream. in this example copy to a file using (var fileToCopyTo = File.Create("FilePath.txt")) { await stream.CopyToAsync(fileToCopyTo).ConfigureAwait(false); } }); }
public async Task Handle(ReplyMessage message, IMessageHandlerContext context) { var randomFileName = Path.GetRandomFileName(); var incomingAttachment = context.Attachments(); using (var target = File.Create(randomFileName)) { await incomingAttachment.CopyTo(target).ConfigureAwait(false); } File.Delete(randomFileName); AttachmentsRunner.countdownEvent.Signal(); Console.WriteLine(AttachmentsRunner.countdownEvent.CurrentCount); }
public async Task Handle(SendMessage message, IMessageHandlerContext context) { Console.WriteLine("Hello from MyHandler. SendMessage"); var incomingAttachments = context.Attachments(); var attachment = await incomingAttachments.GetStream("foo"); var sendOptions = new SendOptions(); sendOptions.RouteToThisEndpoint(); var outgoingAttachments = sendOptions.Attachments(); outgoingAttachments.Add("bar", attachment); await context.Send(new ReplyMessage(), sendOptions); }
public async Task Handle(ReplyMessage message, IMessageHandlerContext context) { using (var memoryStream = new MemoryStream()) { var incomingAttachment = context.Attachments(); await incomingAttachment.CopyTo(memoryStream); memoryStream.Position = 0; var buffer = memoryStream.GetBuffer(); Debug.WriteLine(buffer); } resetEvent.Set(); }
public async Task Handle(MyMessage message, IMessageHandlerContext context) { var incomingAttachments = context.Attachments(); using (var attachmentStream = incomingAttachments.GetStream("attachment1")) { // Use the attachment stream. in this example copy to a file using (var fileToCopyTo = File.Create("FilePath.txt")) { await attachmentStream.CopyToAsync(fileToCopyTo) .ConfigureAwait(false); } } }
public async Task Handle(MyMessage message, IMessageHandlerContext context) { var incomingAttachments = context.Attachments(); await incomingAttachments.ProcessStreamsForMessage( messageId : "theMessageId", action : async(name, stream) => { // Use the attachment stream. in this example copy to a file using (var fileToCopyTo = File.Create($"{name}.txt")) { await stream.CopyToAsync(fileToCopyTo) .ConfigureAwait(false); } }) .ConfigureAwait(false); }
public async Task Handle(ReplyMessage message, IMessageHandlerContext context) { var incomingAttachment = context.Attachments(); IntegrationTests.PerformNestedConnection(); var buffer = await incomingAttachment.GetBytes(); Debug.WriteLine(buffer); using (var stream = await incomingAttachment.GetStream()) { Debug.WriteLine(stream); } IntegrationTests.HandlerEvent.Set(); }
public Task Handle(SendMessage message, IMessageHandlerContext context) { try { context.Attachments(); } catch (Exception e) { exception = e; } finally { resetEvent.Set(); } return(Task.CompletedTask); }
public async Task Handle(SendMessage message, IMessageHandlerContext context) { var replyOptions = new SendOptions(); replyOptions.RouteToThisEndpoint(); var attachment = await context.Attachments().GetBytes("withMetadata"); Assert.Equal("value", attachment.Metadata["key"]); Assert.NotNull(attachment); var outgoingAttachment = replyOptions.Attachments(); outgoingAttachment.AddBytes(attachment); IntegrationTests.PerformNestedConnection(); await context.Send(new ReplyMessage(), replyOptions); }
public async Task Handle(MyMessage message, IMessageHandlerContext context) { var attachment = context.Attachments(); var bytes = await attachment.GetBytes(); }