public ServiceBus(string localQueueName) { LocalEndpoint = new BusEndpoint("", localQueueName); MessageHandlers = new MessageHandlers(); TargetEndpoints = new TargetEndpoints(); MessageHandlers.Add <StartSubscriptionRequest>(Handle); MessageHandlers.Add <EndSubscriptionRequest>(Handle); // TODO: Should it be possible to reject a subscription request? //MessageHandlers.Add<SubscriptionStarted>(Handle); //MessageHandlers.Add<SubscriptionEnded>(Handle); _replyGenerators.AddFor <StartSubscriptionRequest>(r => new SubscriptionStarted(r.Subscription)); _replyGenerators.AddFor <EndSubscriptionRequest>(r => new SubscriptionEnded(r.Subscription)); }
public void SubscribeTo <TMessage>(BusEndpoint publisherEndpoint, Action <TMessage> handler, bool unsubscribeOnStop = true) where TMessage : class { MessageHandlers.Add(handler); var subscription = new Subscription(typeof(TMessage), LocalEndpoint, publisherEndpoint, unsubscribeOnStop); _subscriptions.Add(subscription); Send(new StartSubscriptionRequest(subscription), publisherEndpoint); }