/// <summary> /// Publish the message to subscribers. /// </summary> /// <param name="session">The instance of <see cref="IUniformSession" /> to use for the action.</param> /// <param name="message">The message to publish.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe.</param> public static Task Publish(this IUniformSession session, object message, CancellationToken cancellationToken = default) { Guard.AgainstNull(nameof(session), session); Guard.AgainstNull(nameof(message), message); return(session.Publish(message, new PublishOptions(), cancellationToken)); }
/// <summary> /// Instantiates a message of type T and publishes 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> public static Task Publish <T>(this IUniformSession session, Action <T> messageConstructor) { Guard.AgainstNull(nameof(session), session); Guard.AgainstNull(nameof(messageConstructor), messageConstructor); return(session.Publish(messageConstructor, new PublishOptions())); }
/// <summary> /// Publish the message to subscribers. /// </summary> /// <param name="session">The instance of <see cref="IUniformSession" /> to use for the action.</param> /// <param name="message">The message to publish.</param> public static Task Publish(this IUniformSession session, object message) { Guard.AgainstNull(nameof(session), session); Guard.AgainstNull(nameof(message), message); return(session.Publish(message, new PublishOptions())); }
/// <summary> /// Instantiates a message of type T and publishes 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> public static Task Publish <T>(this IUniformSession session, Action <T> messageConstructor, CancellationToken cancellationToken = default) { Guard.AgainstNull(nameof(session), session); Guard.AgainstNull(nameof(messageConstructor), messageConstructor); return(session.Publish(messageConstructor, new PublishOptions(), cancellationToken)); }
public async Task DoSomething(IMessageSession messageSession) { await messageSession.Send <ISomeOtherCommand>(_ => { }); await messageSession.Publish <ISomeOtherEvent>(_ => { }); await uniformSession.Send <ISomeOtherCommand>(_ => { }); await uniformSession.Publish <ISomeOtherEvent>(_ => { }); }
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(); }
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"; }
/// <summary> /// Publish the message to subscribers. /// </summary> /// <param name="session">The instance of <see cref="IUniformSession" /> to use for the action.</param> /// <typeparam name="T">The message type.</typeparam> public static Task Publish <T>(this IUniformSession session) { Guard.AgainstNull(nameof(session), session); return(session.Publish <T>(_ => { }, new PublishOptions())); }
public async Task PublicEvent(IEvent @event) { await _session.Publish(@event).ConfigureAwait(false); }
/// <summary> /// Publish the message to subscribers. /// </summary> /// <param name="session">The instance of <see cref="IUniformSession" /> to use for the action.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe.</param> /// <typeparam name="T">The message type.</typeparam> public static Task Publish <T>(this IUniformSession session, CancellationToken cancellationToken = default) { Guard.AgainstNull(nameof(session), session); return(session.Publish <T>(_ => { }, new PublishOptions(), cancellationToken)); }
public Task PublishEvent(CancellationToken cancellationToken = default) => session.Publish(new SomeEvent(), cancellationToken: cancellationToken);