コード例 #1
0
        /// <summary>
        /// Sends the provided message.
        /// </summary>
        /// <param name="session">The instance of <see cref="IUniformSession" /> to use for the action.</param>
        /// <param name="message">The message to send.</param>
        public static Task Send(this IUniformSession session, object message)
        {
            Guard.AgainstNull(nameof(session), session);
            Guard.AgainstNull(nameof(message), message);

            return(session.Send(message, new SendOptions()));
        }
コード例 #2
0
ファイル: PaymentManager.cs プロジェクト: eraj2587/NSB7
        public async Task <string> Foo()
        {
            await _session.Send <CreatePaymentForTestingCommand>(x => { x.PaymentId = 123; }).ConfigureAwait(false);

            Logger.Info("CreatePaymentForTestingCommand send for value 123");
            return("bar");
        }
コード例 #3
0
        /// <summary>
        /// Instantiates a message of <typeparamref name="T" /> and sends it.
        /// </summary>
        /// <typeparam name="T">The type of message, usually an interface.</typeparam>
        /// <param name="session">The instance of <see cref="IUniformSession" /> to use for the action.</param>
        /// <param name="messageConstructor">An action which initializes properties of the message.</param>
        /// <remarks>
        /// The message will be sent to the destination configured for <typeparamref name="T" />.
        /// </remarks>
        public static Task Send <T>(this IUniformSession session, Action <T> messageConstructor)
        {
            Guard.AgainstNull(nameof(session), session);
            Guard.AgainstNull(nameof(messageConstructor), messageConstructor);

            return(session.Send(messageConstructor, new SendOptions()));
        }
コード例 #4
0
        /// <summary>
        /// Instantiates a message of <typeparamref name="T" /> and sends it.
        /// </summary>
        /// <typeparam name="T">The type of message, usually an interface.</typeparam>
        /// <param name="session">The instance of <see cref="IUniformSession" /> to use for the action.</param>
        /// <param name="messageConstructor">An action which initializes properties of the message.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe.</param>
        /// <remarks>
        /// The message will be sent to the destination configured for <typeparamref name="T" />.
        /// </remarks>
        public static Task Send <T>(this IUniformSession session, Action <T> messageConstructor, CancellationToken cancellationToken = default)
        {
            Guard.AgainstNull(nameof(session), session);
            Guard.AgainstNull(nameof(messageConstructor), messageConstructor);

            return(session.Send(messageConstructor, new SendOptions(), cancellationToken));
        }
コード例 #5
0
        /// <summary>
        /// Sends the provided message.
        /// </summary>
        /// <param name="session">The instance of <see cref="IUniformSession" /> to use for the action.</param>
        /// <param name="message">The message to send.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe.</param>
        public static Task Send(this IUniformSession session, object message, CancellationToken cancellationToken = default)
        {
            Guard.AgainstNull(nameof(session), session);
            Guard.AgainstNull(nameof(message), message);

            return(session.Send(message, new SendOptions(), cancellationToken));
        }
コード例 #6
0
        public async Task Startup()
        {
            //await instance.Send(new CreatePaymentForTestingCommand()).ConfigureAwait(false);
            await session.Send(new CreatePaymentForTestingCommand()).ConfigureAwait(false);

            //Set release schedules
            // Bus.SendLocal(new StartPaymentReleaseSaga { TaskName = "ReleasePaymentSaga" });
        }
コード例 #7
0
        public static Task SendLocal(this IUniformSession uniformSession, object message, TimeSpan delay)
        {
            var sendOptions = new SendOptions();

            sendOptions.DelayDeliveryWith(delay);
            sendOptions.RouteToThisEndpoint();

            return(uniformSession.Send(message, sendOptions));
        }
            public async Task DoSomething(IMessageSession messageSession)
            {
                await messageSession.Send <ISomeOtherCommand>(_ => { });

                await messageSession.Publish <ISomeOtherEvent>(_ => { });

                await uniformSession.Send <ISomeOtherCommand>(_ => { });

                await uniformSession.Publish <ISomeOtherEvent>(_ => { });
            }
コード例 #9
0
        /// <summary>
        /// Sends the message back to the current endpoint.
        /// </summary>
        /// <param name="session">Object being extended.</param>
        /// <param name="message">The message to send.</param>
        public static Task SendLocal(this IUniformSession session, object message)
        {
            Guard.AgainstNull(nameof(session), session);
            Guard.AgainstNull(nameof(message), message);

            var options = new SendOptions();

            options.RouteToThisEndpoint();

            return(session.Send(message, options));
        }
コード例 #10
0
        /// <summary>
        /// Instantiates a message of type T and sends it back to the current endpoint.
        /// </summary>
        /// <typeparam name="T">The type of message, usually an interface.</typeparam>
        /// <param name="session">Object being extended.</param>
        /// <param name="messageConstructor">An action which initializes properties of the message.</param>
        public static Task SendLocal <T>(this IUniformSession session, Action <T> messageConstructor)
        {
            Guard.AgainstNull(nameof(session), session);
            Guard.AgainstNull(nameof(messageConstructor), messageConstructor);

            var options = new SendOptions();

            options.RouteToThisEndpoint();

            return(session.Send(messageConstructor, options));
        }
            public async Task Handle(SomeCommand message, IMessageHandlerContext context)
            {
                await context.Send(new SomeCommand());

                await context.Publish(new SomeEvent());

                await uniformSession.Send(new SomeCommand());

                await uniformSession.Publish(new SomeEvent());

                context.DoNotContinueDispatchingCurrentMessageToHandlers();
            }
コード例 #12
0
        /// <summary>
        /// Instantiates a message of type T and sends it to the given destination.
        /// </summary>
        /// <typeparam name="T">The type of message, usually an interface.</typeparam>
        /// <param name="session">The instance of <see cref="IUniformSession" /> to use for the action.</param>
        /// <param name="destination">The destination to which the message will be sent.</param>
        /// <param name="messageConstructor">An action which initializes properties of the message.</param>
        public static Task Send <T>(this IUniformSession session, string destination, Action <T> messageConstructor)
        {
            Guard.AgainstNull(nameof(session), session);
            Guard.AgainstNullAndEmpty(nameof(destination), destination);
            Guard.AgainstNull(nameof(messageConstructor), messageConstructor);

            var options = new SendOptions();

            options.SetDestination(destination);

            return(session.Send(messageConstructor, options));
        }
コード例 #13
0
        /// <summary>
        /// Sends the message.
        /// </summary>
        /// <param name="session">The instance of <see cref="IUniformSession" /> to use for the action.</param>
        /// <param name="destination">The address of the destination to which the message will be sent.</param>
        /// <param name="message">The message to send.</param>
        public static Task Send(this IUniformSession session, string destination, object message)
        {
            Guard.AgainstNull(nameof(session), session);
            Guard.AgainstNullAndEmpty(nameof(destination), destination);
            Guard.AgainstNull(nameof(message), message);

            var options = new SendOptions();

            options.SetDestination(destination);

            return(session.Send(message, options));
        }
            public override async Task Invoke(IIncomingLogicalMessageContext context, Func <Task> next)
            {
                await uniformSession.Send(new SomeCommand());

                await uniformSession.Publish(new SomeEvent());

                await context.Send(new SomeCommand());

                await context.Publish(new SomeEvent());

                await next();

                context.Headers["testHeader"] = "testValue";
            }
コード例 #15
0
 public Task DoSomethingElse()
 {
     return(_session.Send(new DoSomethingElseCommand()));
 }
コード例 #16
0
 public async Task SendCommand(ICommand command)
 {
     await session.Send(command).ConfigureAwait(false);
 }
 public Task FireCommand(CancellationToken cancellationToken = default) => session.Send(new SomeCommand(), cancellationToken: cancellationToken);
コード例 #18
0
ファイル: Usage.cs プロジェクト: wushian/docs.particular.net
 public Task Do()
 {
     return(session.Send(new MyMessage()));
 }