public IHaveFulfilledSubscriptionRequirements WithMessageHandler <T>(IHandlerResolver handlerResolver) where T : Message { var thing = _subscriptionConfig.SubscriptionType == SubscriptionType.PointToPoint ? PointToPointHandler <T>() : TopicHandler <T>(); Bus.SerialisationRegister.AddSerialiser <T>(_serialisationFactory.GetSerialiser <T>()); if (!handlerResolver.ResolveHandlers <T>().Any()) { throw new HandlerNotRegisteredWithContainerException(string.Format("IHandler<{0}> is not regsistered in the container.", typeof(T).Name)); } if (handlerResolver.ResolveHandlers <T>().Count() > 1) { throw new NotSupportedException(string.Format("There are more than one registration for IHandler<{0}>. JustSaying currently does not support multiple registration for IHandler<T>.", typeof(T).Name)); } foreach (var region in Bus.Config.Regions) { Bus.AddMessageHandler(region, _subscriptionConfig.QueueName, () => handlerResolver.ResolveHandlers <T>().Single()); } Log.Info(string.Format("Added a message handler - Topic: {0}, QueueName: {1}, HandlerName: IHandler<{2}>", _subscriptionConfig.Topic, _subscriptionConfig.QueueName, typeof(T))); return(thing); }