public IWorkerRoleHeartBeat Initialize() { // Set role heartbeat _heartbeatTimeObservable = Observable.Interval(TimeSpan.FromSeconds(PinkoConfiguration.HeartbeatIntervalSec), Scheduler.ThreadPool); _outboundMessageBus = PinkoApplication.GetBus<IBusMessageOutbound>(); // Send heartbeat _heartbeatTimeObservable .Subscribe(x => _outboundMessageBus.Publish( new PinkoServiceMessageEnvelop(PinkoApplication) { QueueName = PinkoConfiguration.PinkoMessageBusToWebRolesAllTopic, Message = new PinkoMsgRoleHeartbeat() })); return this; }
/// <summary> /// Start Heart Beat /// </summary> public void StartHeartBeat() { // Set role heartbeat _heartbeatTimeObservable = Observable.Interval(TimeSpan.FromSeconds(PinkoContainer.Resolve<IPinkoConfiguration>().HeartbeatIntervalSec), Scheduler.ThreadPool); _outboundMessageBus = PinkoApplication.GetBus<IBusMessageOutbound>(); // Send heartbeat _heartbeatTimeObservable .Subscribe(x => _outboundMessageBus.Publish(PinkoServiceMessageEnvelop.FactorClientMessage(PinkoContainer.Resolve<IPinkoConfiguration>().MessageBusWebRoleToClientsTopic, new PinkoRoleHeartbeat { ResponderDateTime = DateTime.Now, ResponderMachine = PinkoApplication .MachineName }))); }