public static async Task DomainCommand(this IMessageSession ctx, ICommand command) { var options = new NServiceBus.SendOptions(); options.RouteToThisEndpoint(); options.SetHeader(Aggregates.Defaults.RequestResponse, "1"); var response = await ctx.Request <IMessage>(command, options).ConfigureAwait(false); response.CommandResponse(); }
private async Task SendMessages(int batchSize, DateTimeOffset visibleTime, string endpointName = null) { var stopwatch = Stopwatch.StartNew(); var options = new NServiceBus.SendOptions(); Console.WriteLine($"Messages visible at {visibleTime:G}"); options.DoNotDeliverBefore(visibleTime); if (!string.IsNullOrEmpty(endpointName)) { options.SetDestination(endpointName); } var messages = CreateMessages(batchSize); foreach (var message in messages) { await endpointInstance.Send(message, options).ConfigureAwait(false); } Console.WriteLine($"Sent {batchSize} messages at {DateTime.Now:G}. Took: {stopwatch.ElapsedMilliseconds}ms"); }
/// <summary> /// Returns the delivery date configured by using <see cref="DoNotDeliverBefore" />. /// </summary> /// <param name="options">The options being extended.</param> /// <returns>The configured <see cref="DateTimeOffset" /> or <c>null</c>.</returns> public static DateTimeOffset?GetDeliveryDate(this SendOptions options) { Guard.AgainstNull(nameof(options), options); options.GetExtensions().TryGetDeliveryConstraint(out DoNotDeliverBefore deliveryDate); return(deliveryDate?.At); }
/// <summary> /// Returns the configured delivery delay by using <see cref="DelayDeliveryWith" />. /// </summary> /// <param name="options">The options being extended.</param> /// <returns>The configured <see cref="TimeSpan" /> or <c>null</c>.</returns> public static TimeSpan?GetDeliveryDelay(this SendOptions options) { Guard.AgainstNull(nameof(options), options); options.GetExtensions().TryGetDeliveryConstraint(out DelayDeliveryWith delay); return(delay?.Delay); }
public Task Send <T>(IBehaviorContext context, Action <T> messageConstructor, SendOptions options) { return(SendMessage(context, typeof(T), messageMapper.CreateInstance(messageConstructor), options)); }
public Task Send(IBehaviorContext context, object message, SendOptions options) { var messageType = messageMapper.GetMappedTypeFor(message.GetType()); return(SendMessage(context, messageType, message, options)); }
public Task Send <T>(Action <T> messageConstructor, SendOptions options) { return(messageSession.Send(messageConstructor, options)); }
public Task Send(object message, SendOptions options) { return(messageSession.Send(message, options)); }
static Task SendMessage(this IBehaviorContext context, Type messageType, object message, SendOptions options) { var cache = context.Extensions.Get <IPipelineCache>(); var pipeline = cache.Pipeline <IOutgoingSendContext>(); var outgoingContext = new OutgoingSendContext( new OutgoingLogicalMessage(messageType, message), options, context); return(pipeline.Invoke(outgoingContext)); }
public static void SetCorrelationId(this SendOptions options, string correlationId) { throw new NotImplementedException(); }
/// <inheritdoc /> public async Task Send <T>(Action <T> messageConstructor, SendOptions options, ExecutionContext executionContext, ILogger functionsLogger = null) { await InitializeEndpointUsedOutsideHandlerIfNecessary(executionContext, functionsLogger).ConfigureAwait(false); await endpoint.Send(messageConstructor, options).ConfigureAwait(false); }
static Task SendMessage(this IBehaviorContext context, Type messageType, object message, SendOptions options) { var cache = context.Extensions.Get <IPipelineCache>(); var pipeline = cache.Pipeline <IOutgoingSendContext>(); var messageId = options.UserDefinedMessageId ?? CombGuid.Generate().ToString(); var headers = new Dictionary <string, string>(options.OutgoingHeaders) { [Headers.MessageId] = messageId }; var outgoingContext = new OutgoingSendContext( new OutgoingLogicalMessage(messageType, message), messageId, headers, options.Context, context); if (options.DelayedDeliveryConstraint != null) { // we can't add the constraints directly to the SendOptions ContextBag as the options can be reused // and the delivery constraints might be removed by the TimeoutManager logic. outgoingContext.AddDeliveryConstraint(options.DelayedDeliveryConstraint); } return(pipeline.Invoke(outgoingContext)); }
public static Task Send <T>(IBehaviorContext context, Action <T> messageConstructor, SendOptions options) { var mapper = context.Extensions.Get <IMessageMapper>(); return(SendMessage(context, typeof(T), mapper.CreateInstance(messageConstructor), options)); }
/// <summary> /// Returns the delivery date configured by using <see cref="DoNotDeliverBefore" />. /// </summary> /// <param name="options">The options being extended.</param> /// <returns>The configured <see cref="DateTimeOffset" /> or <c>null</c>.</returns> public static DateTimeOffset?GetDeliveryDate(this SendOptions options) { Guard.AgainstNull(nameof(options), options); return((options.DelayedDeliveryConstraint as DoNotDeliverBefore)?.At); }
/// <summary> /// Returns the configured delivery delay by using <see cref="DelayDeliveryWith" />. /// </summary> /// <param name="options">The options being extended.</param> /// <returns>The configured <see cref="TimeSpan" /> or <c>null</c>.</returns> public static TimeSpan?GetDeliveryDelay(this SendOptions options) { Guard.AgainstNull(nameof(options), options); return((options.DelayedDeliveryConstraint as DelayDeliveryWith)?.Delay); }
public static string GetCorrelationId(this SendOptions options) { throw new NotImplementedException(); }
public static Task Send(IBehaviorContext context, object message, SendOptions options) { return(SendMessage(context, message.GetType(), message, options)); }