public static IMayWantOptionalSettings InRegions(params string[] regions) { var config = new MessagingConfig(); if (regions != null) { foreach (var region in regions) { config.Regions.Add(region); } } config.Validate(); var messageSerialisationRegister = new MessageSerialisationRegister(); var justSayingBus = new JustSayingBus(config, messageSerialisationRegister); var amazonQueueCreator = new AmazonQueueCreator(); var bus = new JustSayingFluently(justSayingBus, amazonQueueCreator); bus .WithMonitoring(new NullOpMessageMonitor()) .WithSerialisationFactory(new NewtonsoftSerialisationFactory()); return(bus); }
public static IMayWantOptionalSettings InRegions(this JustSayingFluentlyDependencies dependencies, IEnumerable <string> regions) { var config = new MessagingConfig(); if (dependencies.MessageSubjectProvider != null) { config.MessageSubjectProvider = dependencies.MessageSubjectProvider; } if (regions != null) { foreach (var region in regions) { config.Regions.Add(region); } } config.Validate(); var messageSerializationRegister = new MessageSerializationRegister(config.MessageSubjectProvider); var justSayingBus = new JustSayingBus(config, messageSerializationRegister, dependencies.LoggerFactory); var awsClientFactoryProxy = new AwsClientFactoryProxy(() => CreateMeABus.DefaultClientFactory()); var amazonQueueCreator = new AmazonQueueCreator(awsClientFactoryProxy, dependencies.LoggerFactory); var bus = new JustSayingFluently(justSayingBus, amazonQueueCreator, awsClientFactoryProxy, dependencies.LoggerFactory); bus .WithMonitoring(new NullOpMessageMonitor()) .WithSerializationFactory(new NewtonsoftSerializationFactory()); return(bus); }
/// <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); }
public virtual async Task InitializeAsync() { Given(); SystemUnderTest = CreateSystemUnderTest(); await WhenAsync().ConfigureAwait(false); }
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); }
private JustSaying.JustSayingBus CreateSystemUnderTest() { var serializerRegister = new FakeSerializationRegister(); var bus = new JustSaying.JustSayingBus(Config, serializerRegister, LoggerFactory, Monitor); bus.SetGroupSettings(new SubscriptionGroupSettingsBuilder() .WithDefaultConcurrencyLimit(8), new Dictionary <string, SubscriptionGroupConfigBuilder>()); return(bus); }
public virtual async Task InitializeAsync() { Given(); try { SystemUnderTest = CreateSystemUnderTest(); await WhenAsync().ConfigureAwait(false); } catch (Exception ex) when(_recordThrownExceptions) { ThrownException = ex; } }
public async Task Add_Different_Handler_Per_Queue() { // Arrange string group1 = "group1"; string group2 = "group2"; string queueName1 = "queue1"; string queueName2 = "queue2"; JustSaying.JustSayingBus bus = CreateBus(); var middleware1 = new InspectableMiddleware <TestJustSayingMessage>(); var middleware2 = new InspectableMiddleware <TestJustSayingMessage>(); bus.AddMessageMiddleware <TestJustSayingMessage>(queueName1, middleware1); bus.AddMessageMiddleware <TestJustSayingMessage>(queueName2, middleware2); ISqsQueue queue1 = TestQueue(bus.SerializationRegister, queueName1); ISqsQueue queue2 = TestQueue(bus.SerializationRegister, queueName2); bus.AddQueue(group1, queue1); bus.AddQueue(group2, queue2); using var cts = new CancellationTokenSource(); // Act await bus.StartAsync(cts.Token); await Patiently.AssertThatAsync(_outputHelper, () => { middleware1.Handler.ReceivedMessages.Count.ShouldBeGreaterThan(0); middleware2.Handler.ReceivedMessages.Count.ShouldBeGreaterThan(0); }); cts.Cancel(); await bus.Completion; foreach (var message in middleware1.Handler.ReceivedMessages) { message.QueueName.ShouldBe(queueName1); } foreach (var message in middleware2.Handler.ReceivedMessages) { message.QueueName.ShouldBe(queueName2); } bus.Dispose(); }
/// <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); }
private JustSaying.JustSayingBus CreateBus() { var config = Substitute.For <IMessagingConfig>(); var serializationRegister = new MessageSerializationRegister( new NonGenericMessageSubjectProvider(), new NewtonsoftSerializationFactory()); var bus = new JustSaying.JustSayingBus(config, serializationRegister, LoggerFactory, MessageMonitor); var defaultSubscriptionSettings = new SubscriptionGroupSettingsBuilder() .WithDefaultMultiplexerCapacity(1) .WithDefaultPrefetch(1) .WithDefaultBufferSize(1) .WithDefaultConcurrencyLimit(1); bus.SetGroupSettings(defaultSubscriptionSettings, new Dictionary <string, SubscriptionGroupConfigBuilder>()); return(bus); }
private JustSayingFluently CreateFluent(JustSayingBus bus, ILoggerFactory loggerFactory) { IAwsClientFactoryProxy proxy = CreateFactoryProxy(); IVerifyAmazonQueues queueCreator = new AmazonQueueCreator(proxy, loggerFactory); var fluent = new JustSayingFluently(bus, queueCreator, proxy, loggerFactory); IMessageMonitor messageMonitor = CreateMessageMonitor(); IMessageContextAccessor messageContextAccessor = CreateMessageContextAccessor(); fluent.WithMonitoring(messageMonitor) .WithMessageContextAccessor(messageContextAccessor); if (ServicesBuilder?.MessageLock != null) { fluent.WithMessageLockStoreOf(ServicesBuilder.MessageLock()); } return(fluent); }
/// <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); }