public async Task Handle(MyMessage message, IMessageHandlerContext context)
            {
                var options = new PublishOptions();

                options.CustomizeNativeMessage(m => m.Subject = "abc");
                await context.Publish(message, options);
            }
コード例 #2
0
                public async Task Handle(MyEvent message, IMessageHandlerContext context)
                {
                    var options = new PublishOptions();

                    options.CustomizeNativeMessage(context, m => m.Label = "abc");
                    await context.Publish(message, options);
                }
コード例 #3
0
                public async Task Execute()
                {
                    var options = new PublishOptions();

                    options.CustomizeNativeMessage(m => m.Label = "abc");
                    await session.Publish(new MyEvent(), options);
                }
コード例 #4
0
                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();
                }
コード例 #5
0
                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));
                }
コード例 #6
0
            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
            }
コード例 #7
0
            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
            }
コード例 #8
0
        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();
        }