/// <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())); }
public async Task <string> Foo() { await _session.Send <CreatePaymentForTestingCommand>(x => { x.PaymentId = 123; }).ConfigureAwait(false); Logger.Info("CreatePaymentForTestingCommand send for value 123"); return("bar"); }
/// <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())); }
/// <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)); }
/// <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)); }
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" }); }
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>(_ => { }); }
/// <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)); }
/// <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(); }
/// <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)); }
/// <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"; }
public Task DoSomethingElse() { return(_session.Send(new DoSomethingElseCommand())); }
public async Task SendCommand(ICommand command) { await session.Send(command).ConfigureAwait(false); }
public Task FireCommand(CancellationToken cancellationToken = default) => session.Send(new SomeCommand(), cancellationToken: cancellationToken);
public Task Do() { return(session.Send(new MyMessage())); }