public async Task Handle(MyMessage message, IMessageHandlerContext context) { var options = new PublishOptions(); options.CustomizeNativeMessage(m => m.Subject = "abc"); await context.Publish(message, options); }
public async Task Handle(MyEvent message, IMessageHandlerContext context) { var options = new PublishOptions(); options.CustomizeNativeMessage(context, m => m.Label = "abc"); await context.Publish(message, options); }
public async Task Execute() { var options = new PublishOptions(); options.CustomizeNativeMessage(m => m.Label = "abc"); await session.Publish(new MyEvent(), options); }
public override async Task Invoke(IIncomingLogicalMessageContext context, Func <Task> next) { var publishOptions = new PublishOptions(); publishOptions.CustomizeNativeMessage(context, m => m.Label = "custom-label"); await context.Publish(new MyEvent(), publishOptions); await next(); }
public Task Handle(MessageSessionPublishedEvent message, IMessageHandlerContext context) { var nativeMessage = context.Extensions.Get <ServiceBusReceivedMessage>(); testContext.MessageSessionPublishedMessageCustomizationReceived = nativeMessage.Subject == "IMessageSession.Publish"; var publishOptions = new PublishOptions(); publishOptions.CustomizeNativeMessage(m => m.Subject = "IMessageHandlerContext.Publish"); return(context.Publish(new MessageHandlerContextPublishedEvent(), publishOptions)); }
async Task AccessNativeOutgoingMessageFromHandler(IMessageHandlerContext context) { #region access-native-outgoing-message // send a command var sendOptions = new SendOptions(); sendOptions.CustomizeNativeMessage(m => m.Label = "custom-label"); await context.Send(new MyCommand(), sendOptions).ConfigureAwait(false); // publish an event var publishOptions = new PublishOptions(); publishOptions.CustomizeNativeMessage(m => m.Label = "custom-label"); await context.Publish(new MyEvent(), publishOptions).ConfigureAwait(false); #endregion }
async Task AccessNativeOutgoingMessageWithMessageSession(IEndpointInstance messageSession) { #region access-native-outgoing-message-with-messagesession 1.7 // send a command var sendOptions = new SendOptions(); sendOptions.CustomizeNativeMessage(m => m.Label = "custom-label"); await messageSession.Send(new MyCommand(), sendOptions).ConfigureAwait(false); // publish an event var publishOptions = new PublishOptions(); publishOptions.CustomizeNativeMessage(m => m.Label = "custom-label"); await messageSession.Publish(new MyEvent(), publishOptions).ConfigureAwait(false); #endregion }
public async Task Should_dispatch_native_message_with_the_customizations() { await Scenario.Define <Context>() .WithEndpoint <Endpoint>(b => b.When(async(session, c) => { var sendOptions = new SendOptions(); sendOptions.RouteToThisEndpoint(); sendOptions.CustomizeNativeMessage(m => m.Subject = "IMessageSession.Send"); await session.Send(new MessageSessionSentCommand(), sendOptions); var publishOptions = new PublishOptions(); publishOptions.CustomizeNativeMessage(m => m.Subject = "IMessageSession.Publish"); await session.Publish(new MessageSessionPublishedEvent(), publishOptions); })) .Done(c => c.Completed) .Run(); }