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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        public static IMayWantOptionalSettings InRegion(string region)
        {
            var config = new MessagingConfig {
                Region = region
            };

            config.Validate();

            var bus = new JustSayingFluently(new JustSayingBus(config, new MessageSerialisationRegister()), new AmazonQueueCreator());

            bus.WithMonitoring(new NullOpMessageMonitor());
            bus.WithSerialisationFactory(new NewtonsoftSerialisationFactory());

            return(bus);
        }
Ejemplo n.º 5
0
        /// <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);
        }
Ejemplo n.º 6
0
        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);
        }