protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { _handler = Handler <DataMessage>(configurator, async context => { _data = await context.Message.Data.Value; }); }
protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { configurator.LockDuration = TimeSpan.FromMinutes(5); configurator.MaxAutoRenewDuration = TimeSpan.FromMinutes(20); configurator.Consumer <PingConsumer>(); }
protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { configurator.RequiresSession = true; configurator.EnablePartitioning = true; configurator.Saga(_repository); }
protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { Handler <PingMessage>(configurator, async context => { throw new SerializationException("This is fine, forcing death"); }); }
protected override void ConfigureInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { Handler<PingMessage>(configurator, async context => { throw new SerializationException("This is fine, forcing death"); }); }
protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { _repository = new InMemorySagaRepository <TestState>(); _machine = new TestStateMachine(); configurator.StateMachineSaga(_machine, _repository); }
protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { configurator.UseDelayedRedelivery(r => r.Interval(1, TimeSpan.FromMilliseconds(100))); configurator.UseRetry(r => r.Interval(1, TimeSpan.FromMilliseconds(100))); configurator.UseInMemoryOutbox(); configurator.Consumer <TestHandler>(); }
protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { configurator.LockDuration = TimeSpan.FromSeconds(60); configurator.UseRenewLock(TimeSpan.FromSeconds(20)); configurator.Consumer <PingConsumer>(); }
protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { configurator.ConfigureConsumeTopology = false; configurator.Subscribe("private-topic", "input-queue-subscription"); _handler = Handled <PrivateMessage>(configurator); }
protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { configurator.RequiresSession = true; configurator.EnablePartitioning = true; configurator.UseInMemoryOutbox(); configurator.ConfigureSaga <TestInstance>(_provider.GetRequiredService <IBusRegistrationContext>()); }
// For Azure Service Bus private static void TuneForReportExecution(IServiceBusReceiveEndpointConfigurator r) { // Report execution is single-threaded and typically has both idle // periods (waiting on query results) and CPU-bound periods // (rendering). Thus SSRS *should* be able to support more // concurrent reports than the number of processors in the system. // However, while investigating tuning options and future load // compensation mechanisms, this will stay at a safer number. // // WARNING: // Do not use int.MaxValue here, or the bus will never start! // MassTransit will start this many async 'receive' operations // against the queue. Choose a number that balances the desire // for max utilization against the danger of creating too many // connections to Azure Service Bus. Each connection adds delay // to bus start and reduces the number of connections available // to other clients. The cap is 5000 ASB connections/receives. // // TODO: Consider physical memory in concurrency calculation. // TODO: Make loading factor(s) configurable. var concurrency = Math.Min(Environment.ProcessorCount, 32); r.MaxConcurrentCalls = concurrency; // RSMassTransit expects multiple service instances, competing for // infrequent, long-running requests. Prefetch optimizes for the // opposite case and actually *hinders* the spread of infrequent // messages across instances. Therefor, turn prefetch off here. // // WARNING: This must come *AFTER* MaxConcurrentCalls above. // Otherwise, the setting is overwritten. r.PrefetchCount = 0; // When RSMassTransit tries to pause or stop message consumption, // unwanted messages continue to be received, due to limitations in // the Azure Service Bus OnMessageAsync API. The messages accrue // unconsumed up to the MaxConcurrentCalls limit. To ensure those // messages quickly become consumable by a competing instance, use // a short message lock duration. r.LockDuration = TimeSpan.FromMinutes(1); // While a message is being consumed, its lock must be refreshed // regularly so that it does not expire. r.MaxAutoRenewDuration = TimeSpan.FromDays(1); // It is reasonable to assume that any client will have given up // waiting for their response after a day. r.DefaultMessageTimeToLive = TimeSpan.FromDays(1); // The short lock period, combined with several paused instances, // can cause many failed delivery attempts. Use a high enough // maximum delivery count to avoid these actionable messages // getting dead-lettered. r.MaxDeliveryCount = concurrency * 4; // Do transport-independent tuning TuneForReportExecution((IReceiveEndpointConfigurator)r); }
protected override void ConfigureInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { _first = Handler<FirstMessage>(configurator, async context => { await context.SchedulePublish(TimeSpan.FromSeconds(1), new SecondMessage()); }); _second = Handled<SecondMessage>(configurator); }
protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { _first = Handler <FirstMessage>(configurator, async context => { await context.SchedulePublish(TimeSpan.FromSeconds(1), new SecondMessage()); }); _second = Handled <SecondMessage>(configurator); }
protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { _first = Handler <FirstMessage>(configurator, async context => { await context.ScheduleSend(DateTime.Now, new SecondMessage()); }); _second = Handled <SecondMessage>(configurator); }
protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { _first = Handler <FirstMessage>(configurator, async context => { var scheduledMessage = await context.ScheduleSend(TimeSpan.FromSeconds(5), new SecondMessage()); await context.CancelScheduledSend(scheduledMessage); }); _second = Handled <SecondMessage>(configurator); }
protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { base.ConfigureServiceBusReceiveEndpoint(configurator); configurator.EnableDuplicateDetection(TimeSpan.FromSeconds(30)); _receivedA = Handled <FirstInterface>(configurator, context => context.Message.Value == "A"); _receivedB = Handled <FirstInterface>(configurator, context => context.Message.Value == "B"); configurator.Handler <FirstInterface>(async context => Interlocked.Increment(ref _count)); }
protected override void ConfigureInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { base.ConfigureInputQueueEndpoint(configurator); _completed = Handled <JobCompleted>(configurator); configurator.Turnout <ProcessFile>(_busFactoryConfigurator, x => { x.SuperviseInterval = TimeSpan.FromSeconds(1); x.SetJobFactory(async context => await Task.Delay(context.Message.Size)); }); }
protected override void ConfigureInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { base.ConfigureInputQueueEndpoint(configurator); _completed = Handled<JobCompleted>(configurator); configurator.Turnout<ProcessFile>(_busFactoryConfigurator, x => { x.SuperviseInterval = TimeSpan.FromSeconds(1); x.SetJobFactory(async context => await Task.Delay(context.Message.Size)); }); }
/// <summary> /// Configures a Turnout on the receive endpoint, which executes a long-running job and supervises the job until it /// completes. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="configurator">The receive endpoint configurator</param> /// <param name="busFactoryConfigurator">The bus factory configuration to use a separate endpoint for the control traffic</param> /// <param name="configure"></param> public static void Turnout <T>(this IServiceBusReceiveEndpointConfigurator configurator, IServiceBusBusFactoryConfigurator busFactoryConfigurator, Action <ITurnoutHostConfigurator <T> > configure) where T : class { var temporaryQueueName = busFactoryConfigurator.GetTemporaryQueueName("turnout-"); busFactoryConfigurator.ReceiveEndpoint(configurator.Host, temporaryQueueName, turnoutEndpointConfigurator => { turnoutEndpointConfigurator.AutoDeleteOnIdle = TimeSpan.FromMinutes(5); turnoutEndpointConfigurator.EnableExpress = true; configurator.ConfigureTurnoutEndpoints(busFactoryConfigurator, turnoutEndpointConfigurator, configure); }); }
protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { _testId = NewId.NextGuid(); _first = Handler <FirstMessage>(configurator, async context => { ScheduledMessage <SecondMessage> scheduledMessage = await context.ScheduleSend(TimeSpan.FromSeconds(15), new SecondMessage { Id = _testId }); await Task.Delay(1000); await context.CancelScheduledSend(scheduledMessage); }); _second = Handled <SecondMessage>(configurator, context => context.Message.Id == _testId); }
protected override void ConfigureInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { configurator.PrefetchCount = 64; configurator.Handler <PingMessage>(async context => { try { await context.RespondAsync(new PongMessage(context.Message.CorrelationId)); } catch (Exception ex) { Console.WriteLine(ex); } }); }
protected override void ConfigureInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { configurator.PrefetchCount = 64; configurator.Handler<PingMessage>(async context => { try { await context.RespondAsync(new PongMessage(context.Message.CorrelationId)); } catch (Exception ex) { Console.WriteLine(ex); } }); }
/// <summary> /// Creates a management endpoint which can be used by controllable filters on a bus intance /// </summary> /// <param name="configurator"></param> /// <param name="host">The service bus host</param> /// <param name="configure"></param> /// <returns></returns> public static IManagementEndpointConfigurator ManagementEndpoint(this IServiceBusBusFactoryConfigurator configurator, IServiceBusHost host, Action <IReceiveEndpointConfigurator> configure = null) { var queueName = host.Topology.CreateTemporaryQueueName("manage-"); IServiceBusReceiveEndpointConfigurator specification = null; configurator.ReceiveEndpoint(host, queueName, x => { x.AutoDeleteOnIdle = Defaults.TemporaryAutoDeleteOnIdle; configure?.Invoke(x); specification = x; }); return(new ManagementEndpointConfigurator(specification)); }
protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { configurator.RequiresSession = true; TaskCompletionSource <string> handlerSessionId = GetTask <string>(); _handlerSessionId = handlerSessionId.Task; _handler = Handler <PingMessage>(configurator, async context => { await context.Publish <PingReceived>(context.Message); await context.Send <PingAccepted>(InputQueueAddress, context.Message); handlerSessionId.TrySetResult(context.SessionId()); }); _accepted = Handled <PingAccepted>(configurator); _received = Handled <PingReceived>(configurator); }
/// <summary> /// Creates a management endpoint which can be used by controllable filters on a bus intance /// </summary> /// <param name="configurator"></param> /// <param name="host">The service bus host</param> /// <param name="configure"></param> /// <returns></returns> public static IManagementEndpointConfigurator ManagementEndpoint(this IServiceBusBusFactoryConfigurator configurator, IServiceBusHost host, Action <IReceiveEndpointConfigurator> configure = null) { var queueName = host.GetTemporaryQueueName("manage-"); IServiceBusReceiveEndpointConfigurator specification = null; configurator.ReceiveEndpoint(host, queueName, x => { x.AutoDeleteOnIdle = TimeSpan.FromMinutes(5); x.EnableExpress = true; configure?.Invoke(x); specification = x; }); return(new ManagementEndpointConfigurator(specification)); }
private void TuneForReportExecution(IServiceBusReceiveEndpointConfigurator r) { // RSMassTransit expects multiple service instances, competing for // infrequent, long-running requests. Prefetch optimizes for the // opposite case and actually *hinders* the spread of infrequent // messages across instances. Therefor, turn prefetch off here. r.PrefetchCount = 0; // Report execution is single-threaded and typically has both idle // periods (waiting on query results) and CPU-bound periods // (rendering). Thus SSRS *should* be able to support more // concurrent reports than the number of processors in the system. //r.MaxConcurrentCalls = Environment.ProcessorCount * 2; // // However, while investigating tuning options and future load // compensation mechanisms, this will stay at a safer number. r.MaxConcurrentCalls = Environment.ProcessorCount; // When RSMassTransit tries to pause or stop message consumption, // unwanted messages continue to be received, due to limitations in // the Azure Service Bus OnMessageAsync API. The messages accrue // unconsumed up to the MaxConcurrentCalls limit. To ensure those // messages quickly become consumable by a competing instance, use // a short message lock duration, and auto-renew the lock while // consuming a message. r.LockDuration = TimeSpan.FromSeconds(60); r.UseRenewLock(TimeSpan.FromSeconds(30)); // The short lock period, combined with several paused instances, // can cause many failed delivery attempts. Use a high enough // maximum delivery count to avoid these actionable messages // getting dead-lettered. r.MaxDeliveryCount = 16; // It is reasonable to assume that any client will have given up // waiting for their response after a day. r.DefaultMessageTimeToLive = TimeSpan.FromDays(1); }
/// <summary> /// We may want to have a builder/endpoint context that could store things like management endpoint, etc. to configure /// filters and add configuration interfaces for things like concurrency limit and prefetch count /// </summary> /// <param name="configurator"></param> /// <param name="definition"></param> /// <param name="configure">The callback to invoke after the definition configuration has been applied</param> internal static void Apply(this IServiceBusReceiveEndpointConfigurator configurator, IEndpointDefinition definition, Action <IServiceBusReceiveEndpointConfigurator> configure = null) { if (definition.IsTemporary) { configurator.AutoDeleteOnIdle = Defaults.TemporaryAutoDeleteOnIdle; configurator.RemoveSubscriptions = true; } if (definition.PrefetchCount.HasValue) { configurator.PrefetchCount = (ushort)definition.PrefetchCount.Value; } if (definition.ConcurrentMessageLimit.HasValue) { var concurrentMessageLimit = definition.ConcurrentMessageLimit.Value; // if there is a prefetchCount, and it's greater than the concurrent message limit, we need a filter if (!definition.PrefetchCount.HasValue || definition.PrefetchCount.Value > concurrentMessageLimit) { configurator.MaxConcurrentCalls = concurrentMessageLimit; // we should determine a good value to use based upon the concurrent message limit if (definition.PrefetchCount.HasValue == false) { var calculatedPrefetchCount = concurrentMessageLimit * 12 / 10; configurator.PrefetchCount = (ushort)calculatedPrefetchCount; } } } definition.Configure(configurator); configure?.Invoke(configurator); }
protected override void ConfigureInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { configurator.RequiresSession = true; _handler = Handled<PingMessage>(configurator); }
protected virtual void ConfigureInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { }
protected override void ConfigureInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { _first = Handler<FirstMessage>(configurator, async context => { var scheduledMessage = await context.ScheduleSend(TimeSpan.FromSeconds(5), new SecondMessage()); await context.CancelScheduledSend(scheduledMessage); }); _second = Handled<SecondMessage>(configurator); }
protected override void ConfigureSecondInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { }
protected override void ConfigureInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { configurator.RequiresSession = true; configurator.Saga(_repository); }
protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { _handler = Handled <PingMessage>(configurator); }
protected override void ConfigureInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { _ping = Handler<PingMessage>(configurator, async x => await x.RespondAsync(new PongMessage(x.Message.CorrelationId))); }
protected override void ConfigureSecondInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { _secondHandler = Handled<PingMessage>(configurator); }
protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { _handler = Handled <TurnoutJobCompleted>(configurator); }
protected override void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { _handler = Handler <PingMessage>(configurator, context => context.RespondAsync(new PongMessage(context.Message.CorrelationId))); }
protected override void ConfigureInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { _handler = Handled<PingMessage>(configurator); configurator.SelectBasicTier(); }
protected virtual void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { OnConfigureServiceBusReceiveEndpoint?.Invoke(configurator); }
protected override void ConfigureInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { _completed = Handled<JobCompleted>(configurator, context => context.Message.GetArguments<ProcessFile>().Size == 1); _completed2 = Handled<JobCompleted>(configurator, context => context.Message.GetArguments<ProcessFile>().Size == 2); }
protected virtual void ConfigureServiceBusReceiveEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { }
protected override void ConfigureInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { _started = Handled<JobStarted>(configurator); _canceled = Handled<JobCanceled<ProcessFile>>(configurator); }
protected override void ConfigureInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { _handler = Handler<PingMessage>(configurator, context => context.RespondAsync(new PongMessage(context.Message.CorrelationId))); }
protected override void ConfigureInputQueueEndpoint(IServiceBusReceiveEndpointConfigurator configurator) { Handled<MessageA>(configurator); Handled<MessageA>(configurator); }