protected override void Setup(FeatureConfigurationContext context) { if (!context.Settings.TryGet("NServiceBus.Heartbeat.Interval", out TimeSpan interval)) { interval = TimeSpan.FromSeconds(10); } if (!context.Settings.TryGet("NServiceBus.Heartbeat.Ttl", out TimeSpan ttl)) { ttl = TimeSpan.FromTicks(interval.Ticks * 4); } var replyToAddress = !context.Settings.GetOrDefault <bool>("Endpoint.SendOnly") ? context.Settings.LocalAddress() : null; var destinationQueue = context.Settings.Get <string>("NServiceBus.Heartbeat.Queue"); var backend = new ServiceControlBackend(destinationQueue, replyToAddress); context.RegisterStartupTask(b => new HeartbeatSender(b.GetRequiredService <IMessageDispatcher>(), b.GetRequiredService <HostInformation>(), backend, context.Settings.EndpointName(), interval, ttl)); }
public HeartbeatSender(IMessageDispatcher dispatcher, HostInformation hostInfo, ServiceControlBackend backend, string endpointName, TimeSpan interval, TimeSpan timeToLive) { this.dispatcher = dispatcher; this.backend = backend; this.endpointName = endpointName; heartbeatInterval = interval; ttlTimeSpan = timeToLive; this.hostInfo = hostInfo; }