/// <summary> /// Creates a new instance of <see cref="IMessagingBus"/>. /// </summary> /// <returns> /// The created instance of <see cref="IMessagingBus"/> /// </returns> public IMessagingBus BuildSubscribers() { IMessagingConfig config = CreateConfig(); config.Validate(); ILoggerFactory loggerFactory = ServicesBuilder?.LoggerFactory?.Invoke() ?? ServiceResolver.ResolveService <ILoggerFactory>(); JustSayingBus bus = CreateBus(config, loggerFactory); JustSayingFluently fluent = CreateFluent(bus, loggerFactory); if (ServicesBuilder?.NamingStrategy != null) { fluent.WithNamingStrategy(ServicesBuilder.NamingStrategy); } if (ServicesBuilder?.MessageContextAccessor != null) { fluent.WithMessageContextAccessor(ServicesBuilder.MessageContextAccessor()); } if (SubscriptionBuilder != null) { SubscriptionBuilder.Configure(fluent); } return(bus); }
private JustSayingBus CreateBus(IMessagingConfig config, ILoggerFactory loggerFactory) { IMessageSerializationRegister register = ServicesBuilder?.SerializationRegister?.Invoke() ?? ServiceResolver.ResolveService <IMessageSerializationRegister>(); return(new JustSayingBus(config, register, loggerFactory)); }
private JustSayingBus CreateBus(IMessagingConfig config, ILoggerFactory loggerFactory) { IMessageSerializationRegister register = ServiceResolver.ResolveService <IMessageSerializationRegister>(); IMessageMonitor monitor = ServiceResolver.ResolveOptionalService <IMessageMonitor>() ?? new NullOpMessageMonitor(); var bus = new JustSayingBus(config, register, loggerFactory, monitor); return(bus); }
private JustSayingBus CreateBus(IMessagingConfig config, ILoggerFactory loggerFactory) { IMessageSerializationRegister register = ServicesBuilder?.SerializationRegister?.Invoke() ?? ServiceResolver.ResolveService <IMessageSerializationRegister>(); var bus = new JustSayingBus(config, register, loggerFactory); bus.Monitor = CreateMessageMonitor(); bus.MessageContextAccessor = CreateMessageContextAccessor(); return(bus); }
/// <summary> /// Adds a middleware of type <typeparamref name="TMiddleware"/> to the pipeline which will be resolved from the /// <see cref="IServiceResolver"/>. It will be resolved once when the pipeline is built, and cached /// for the lifetime of the bus. /// </summary> /// <typeparam name="TMiddleware">The type of the middleware to add.</typeparam> /// <returns>The current HandlerMiddlewareBuilder.</returns> /// <exception cref="InvalidOperationException">When the middleware is not registered as Transient, an exception will be thrown if the resolved middleware is already part of a pipeline.</exception> public HandlerMiddlewareBuilder Use <TMiddleware>() where TMiddleware : MiddlewareBase <HandleMessageContext, bool> { var newMiddleware = ServiceResolver.ResolveService <TMiddleware>(); if (newMiddleware.HasNext) { throw new InvalidOperationException( @"Middlewares must be registered into your DI container such that each resolution creates a new instance. For StructureMap use Transient(), and for Microsoft.Extensions.DependencyInjection, use AddTransient(). Please check the documentation for your container for more details."); } _middlewares.Add(() => newMiddleware); return(this); }
/// <summary> /// Creates a new instance of <see cref="IMessagingBus"/>. /// </summary> /// <returns> /// The created instance of <see cref="IMessagingBus"/> /// </returns> public IMessagingBus BuildSubscribers() { IMessagingConfig config = MessagingConfig.Build(); config.Validate(); ILoggerFactory loggerFactory = ServiceResolver.ResolveService <ILoggerFactory>(); JustSayingBus bus = CreateBus(config, loggerFactory); IAwsClientFactoryProxy proxy = CreateFactoryProxy(); IVerifyAmazonQueues creator = new AmazonQueueCreator(proxy, loggerFactory); SubscriptionBuilder.Configure(bus, ServiceResolver, creator, proxy, loggerFactory); return(bus); }
/// <summary> /// Creates a new instance of <see cref="IMessagePublisher"/>. /// </summary> /// <returns> /// The created instance of <see cref="IMessagePublisher"/> /// </returns> public IMessagePublisher BuildPublisher() { IMessagingConfig config = MessagingConfig.Build(); config.Validate(); ILoggerFactory loggerFactory = ServiceResolver.ResolveService <ILoggerFactory>(); JustSayingBus bus = CreateBus(config, loggerFactory); IAwsClientFactoryProxy proxy = CreateFactoryProxy(); if (PublicationsBuilder != null) { PublicationsBuilder.Configure(bus, proxy, loggerFactory); } return(bus); }
/// <summary> /// Creates a new instance of <see cref="IMessagePublisher"/>. /// </summary> /// <returns> /// The created instance of <see cref="IMessagePublisher"/> /// </returns> public IMessagePublisher BuildPublisher() { IMessagingConfig config = CreateConfig(); config.Validate(); ILoggerFactory loggerFactory = ServicesBuilder?.LoggerFactory?.Invoke() ?? ServiceResolver.ResolveService <ILoggerFactory>(); JustSayingBus publisher = CreateBus(config, loggerFactory); JustSayingFluently fluent = CreateFluent(publisher, loggerFactory); if (PublicationsBuilder != null) { PublicationsBuilder.Configure(fluent); } return(publisher); }
/// <summary> /// Creates a new instance of <see cref="IMessagingBus"/>. /// </summary> /// <returns> /// The created instance of <see cref="IMessagingBus"/> /// </returns> public IMessagingBus BuildSubscribers() { IMessagingConfig config = CreateConfig(); config.Validate(); ILoggerFactory loggerFactory = ServicesBuilder?.LoggerFactory?.Invoke() ?? ServiceResolver.ResolveService <ILoggerFactory>(); JustSayingBus bus = CreateBus(config, loggerFactory); IVerifyAmazonQueues creator = CreateQueueCreator(loggerFactory); if (ServicesBuilder?.MessageContextAccessor != null) { bus.MessageContextAccessor = ServicesBuilder.MessageContextAccessor(); } if (SubscriptionBuilder != null) { SubscriptionBuilder.Configure(bus, ServiceResolver, creator, loggerFactory); } return(bus); }
/// <summary> /// Adds a middleware of type <typeparamref name="TMiddleware"/> to the pipeline which will be resolved from the /// <see cref="IServiceResolver"/>. It will be resolved once when the pipeline is built, and cached /// for the lifetime of the bus. /// </summary> /// <typeparam name="TMiddleware">The type of the middleware to add.</typeparam> /// <returns>The current HandlerMiddlewareBuilder.</returns> public HandlerMiddlewareBuilder Use <TMiddleware>() where TMiddleware : MiddlewareBase <HandleMessageContext, bool> { _middlewares.Add(() => ServiceResolver.ResolveService <TMiddleware>()); return(this); }
private IMessageContextAccessor CreateMessageContextAccessor() { return(ServicesBuilder?.MessageContextAccessor?.Invoke() ?? ServiceResolver.ResolveService <IMessageContextAccessor>()); }
private IMessageMonitor CreateMessageMonitor() { return(ServicesBuilder?.MessageMonitoring?.Invoke() ?? ServiceResolver.ResolveService <IMessageMonitor>()); }
private IAwsClientFactoryProxy CreateFactoryProxy() { return(ClientFactoryBuilder != null ? new AwsClientFactoryProxy(new Lazy <IAwsClientFactory>(ClientFactoryBuilder.Build)) : ServiceResolver.ResolveService <IAwsClientFactoryProxy>()); }
private IMessagingConfig CreateConfig() { return(MessagingConfig != null? MessagingConfig.Build() : ServiceResolver.ResolveService <IMessagingConfig>()); }
/// <summary> /// Creates a new instance of <see cref="IAwsClientFactory"/>. /// </summary> /// <returns> /// The created instance of <see cref="IAwsClientFactory"/> /// </returns> public IAwsClientFactory BuildClientFactory() { return(ClientFactoryBuilder?.Build() ?? ServiceResolver.ResolveService <IAwsClientFactory>()); }
private IMessageSerializationFactory CreateMessageSerializationFactory() { return(ServicesBuilder?.MessageSerializationFactory?.Invoke() ?? ServiceResolver.ResolveService <IMessageSerializationFactory>()); }