/// <summary> /// Subscribes the specified observer. /// </summary> /// <param name="observer">The observer.</param> /// <returns>An IDisposable.</returns> public IDisposable Subscribe(IObserver <T> observer) { if (_theObserver != null) { throw new InvalidOperationException( "There should be only one observer attached to the Firehose Observable"); } var messageTransportWaitCallBackId = Guid.Empty; try { _theObserver = observer; var topicObserver = new TopicObserver(_topic, observer); topicObserver.Start(); return (Disposable.Create( () => topicObserver.Stop())); } catch (Exception ex) { Tracer.TraceSource.TraceEvent( TraceEventType.Error, 0, "Fire hose observable - topic:{0}, waitCallbackId:{1}, unable to subscribe to fire hose observable - {2}", _topic, messageTransportWaitCallBackId, ex); throw; } }
public override void SetContext(IOperatorContext context) { if (!context.TryGetElement <MessageRouter>(MessageRouter.ContextHandle, out var messageRouter)) { throw new InvalidOperationException("Could not retrieve the message router from the operator context."); } _topicObserver = new TopicObserver(Params._topic, messageRouter, this); _scheduler = context.Scheduler; base.SetContext(context); }