// This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //services.AddMvc();

            services.AddControllers();
            services.AddAutoMapper(typeof(Startup));

            int chosenDB = Configuration.GetValue("ChosenDB", 1);

            DataConfiguration.configure((DataProviderEnum)chosenDB, Configuration, services);

            ServiceConfiguration.configure(Configuration, services);
            RabbitMqConfiguration.configure(Configuration, services);

            services.AddCors();

            // ********************
            // Setup CORS
            // ********************
            // var corsBuilder = new CorsPolicyBuilder();
            // corsBuilder.AllowAnyHeader();
            // corsBuilder.AllowAnyMethod();
            // corsBuilder.AllowAnyOrigin(); // For anyone access.
            // //corsBuilder.WithOrigins("http://localhost:56573"); // for a specific url. Don't add a forward slash on the end!
            // corsBuilder.AllowCredentials();

            // services.AddCors(options =>
            // {
            //     options.AddPolicy("SiteCorsPolicy", corsBuilder.Build());
            // });
        }
        private void TryCreateConnection(RabbitMqConfiguration configuration, string consumerApi)
        {
            const int retryCount = 3;

            for (int i = 0; i < retryCount; i++)
            {
                try
                {
                    CreateConnection(configuration, consumerApi);

                    return;
                }
                catch (Exception e)
                {
                    if (i == retryCount - 1)
                    {
                        var errorMessage =
                            $"Unable to establish RabbitMQ connection to {configuration.HostName}:{configuration.Port}, queue {configuration.ResponseQueueName}: {e.Message}";
                        _logger.LogError(errorMessage);

                        throw new Exception(errorMessage);
                    }
                }
            }
        }
        public void Should_be_able_to_use_fluent_configuration()
        {
            var rabbitMqConfig = new RabbitMqConfiguration() as IRabbitMqConfiguration;

            rabbitMqConfig
            .DefineExchange("exchange-fluent")
            .Type("direct")
            .IsDurable(true)
            .DeclareQueue("rabbitmq://./inbox-work-1")
            .IsDurable(false);

            var factory  = new RabbitMqQueueFactory(rabbitMqConfig);
            var exchange = factory.Configuration.FindExchangeConfiguration("exchange-fluent");
            var queue    = factory.Configuration.FindQueueConfiguration(new Uri("rabbitmq://./inbox-work-1"));

            Assert.IsNotNull(exchange, "The exchange not found asking the QueueFactory configuration.");
            Assert.IsNotNull(queue, "The queue not found asking the QueueFactory configuration.");


            Assert.AreEqual("exchange-fluent", exchange.Name);
            Assert.AreEqual("direct", exchange.Type);
            Assert.IsTrue(exchange.IsDurable);

            Assert.AreEqual("rabbitmq://./inbox-work-1", queue.Uri);
            Assert.IsFalse(queue.IsDurable);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            RabbitMqConfiguration configuration = new RabbitMqConfiguration();
            MsgPublisher          publisher     = new MsgPublisher(configuration);

            publisher.Publish("Hello...");
        }
Ejemplo n.º 5
0
        public OrderService(IOptions <RabbitMqConfiguration> rabbitMqOptions, ILogger <OrderService> logger)
        {
            _rabbitMqOptions = rabbitMqOptions.Value;
            _logger          = logger;

            InitializeRabbitMqListener();
        }
Ejemplo n.º 6
0
        public void SetUp()
        {
            sendEndpointProviderMock = new Mock <ISendEndpointProvider>();

            rabbitMqConfigurationMock = new Mock <IOptions <RabbitMqConfiguration> >();

            sendEndpointMock = new Mock <ISendEndpoint>();

            RabbitMqConfiguration rabbitMqConfiguration = new RabbitMqConfiguration();

            rabbitMqConfiguration.Host     = "localhost";
            rabbitMqConfiguration.Port     = 15672;
            rabbitMqConfiguration.Username = "******";
            rabbitMqConfiguration.Password = "******";

            sendEndpointProviderMock
            .Setup(x => x.GetSendEndpoint(It.IsAny <Uri>()))
            .Returns(Task.FromResult(sendEndpointMock.Object));

            rabbitMqConfigurationMock.Setup(x => x.Value).Returns(rabbitMqConfiguration);

            sendEndpointMock.Setup(x => x.Send <PersonSearchOrdered>(It.IsAny <PersonSearchOrdered>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(sendEndpointMock));

            sut = new Dispatcher(sendEndpointProviderMock.Object, rabbitMqConfigurationMock.Object);
        }
Ejemplo n.º 7
0
        protected RabbitMqServer(RabbitMqConfiguration config, IIpcPacketHandlersContainer packetHandlersContainer)
        {
            _configuration           = config;
            _packetHandlersContainer = packetHandlersContainer;
            var factory = new ConnectionFactory {
                HostName = _configuration.Address, Password = _configuration.Password, Port = _configuration.Port
            };

            _requestQueueName   = _configuration.RequestQueueName;
            _responseQueueName  = _configuration.ResponseQueueName;
            _broadcastQueueName = _configuration.BroadcastQueueName;

            _packetContainerFactory = new PacketContainerFactory();

            _connection = factory.CreateConnection();
            _channel    = _connection.CreateModel();

            _channel.QueueDeclare(_requestQueueName, true, false, false, null);
            _channel.QueueDeclare(_responseQueueName, true, false, false, null);
            _channel.QueueDeclare(_broadcastQueueName, true, false, false, null);

            var consumer = new EventingBasicConsumer(_channel);

            consumer.Received += OnMessage;
            _channel.BasicConsume(_requestQueueName, true, consumer);
            _channel.BasicConsume(_broadcastQueueName, true, consumer);
            Log.Info("IPC Server launched !");
        }
Ejemplo n.º 8
0
 public MqService(RabbitMqConfiguration mqConfig, ILogger logger, BotConfiguration botConfiguration, IIrcClient client)
 {
     this.mqConfig         = mqConfig;
     this.logger           = logger;
     this.botConfiguration = botConfiguration;
     this.client           = client;
 }
        public void SetUp()
        {
            _sendEndpointProviderMock = new Mock <ISendEndpointProvider>();

            _rabbitMqConfigurationMock = new Mock <IOptions <RabbitMqConfiguration> >();

            _sendEndpointMock = new Mock <ISendEndpoint>();

            _loggerMock = new Mock <ILogger <SearchRequestEventPublisher> >();

            RabbitMqConfiguration rabbitMqConfiguration = new RabbitMqConfiguration();

            rabbitMqConfiguration.Host     = "localhost";
            rabbitMqConfiguration.Port     = 15672;
            rabbitMqConfiguration.Username = "******";
            rabbitMqConfiguration.Password = "******";

            _sendEndpointProviderMock
            .Setup(x => x.GetSendEndpoint(It.IsAny <Uri>()))
            .Returns(Task.FromResult(_sendEndpointMock.Object));

            _rabbitMqConfigurationMock.Setup(x => x.Value).Returns(rabbitMqConfiguration);

            _sendEndpointMock.Setup(x => x.Send <SearchRequestFailedEvent>(It.IsAny <SearchRequestFailed>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(_sendEndpointMock));

            _baseEvent = new FakeSearchRequestEvent()
            {
                SearchRequestKey = "key"
            };

            _sut = new SearchRequestEventPublisher(_sendEndpointProviderMock.Object, _rabbitMqConfigurationMock.Object, _loggerMock.Object);
        }
Ejemplo n.º 10
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc();
     services.AddControllers();
     ConfigureSwagger(services);
     services.AddAutoMapper(typeof(Startup));
     services.AddEventFlow(ef =>
     {
         var envconfig = EnvironmentConfiguration.Bind(Configuration);
         services.AddSingleton(envconfig);
         ef.AddDefaults(typeof(Startup).Assembly);
         //ef.Configure(cfg => cfg.IsAsynchronousSubscribersEnabled = true);
         ef.PublishToRabbitMq(
             RabbitMqConfiguration.With(new Uri(envconfig.RabbitMqConnection),
                                        true, 5, envconfig.RabbitExchange));
         ef.AddAspNetCore();
         //ef.UseHangfireJobScheduler();
         ef.UseConsoleLog();
         ef.RegisterModule <DomainModule>();
         ef.RegisterModule <AccountingReadModelModule>();
         ef.RegisterServices(s =>
         {
             s.Register <ICustomerCommandService, CustomerCommandService>();
             s.Register <IAccountCommandService, AccountCommandService>();
             s.Register <ITransactionCommandService, TransactionCommandService>();
         });
     });
 }
        public static IServiceCollection AddRabbitMqMessaging(
            this IServiceCollection services,
            RabbitMqConfiguration configuration,
            params Action <IServiceCollectionBusConfigurator>[] addConsumerActions)
        {
            return(services
                   .AddScoped(typeof(INotificationHandler <>), typeof(DomainEventHandler <>))
                   .AddMassTransit(x =>
            {
                foreach (var addConsumerAction in addConsumerActions)
                {
                    addConsumerAction(x);
                }

                x.SetKebabCaseEndpointNameFormatter();
                x.UsingRabbitMq((context, cfg) =>
                {
                    cfg.Host(configuration.GetUri(), h =>
                    {
                        h.Username(configuration.Username);
                        h.Password(configuration.Password);
                    });

                    cfg.ConfigureEndpoints(context);
                });
            })
                   .AddMassTransitHostedService());
        }
Ejemplo n.º 12
0
 //, IDeepSearchService deepSearchService
 public Dispatcher(ILogger <IDispatcher> logger, ISendEndpointProvider sendEndpointProvider, IOptions <RabbitMqConfiguration> rabbitMqOptions, ICacheService cacheService)
 {
     _cacheService          = cacheService;
     _sendEndpointProvider  = sendEndpointProvider;
     _rabbitMqConfiguration = rabbitMqOptions.Value;
     _logger = logger;
 }
Ejemplo n.º 13
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            var eventStoreUri = new Uri("tcp://localhost:1113", UriKind.Absolute);
            var rabbmitMqUri  = new Uri("amqp://localhost", UriKind.Absolute);
            var mongoUrl      = "mongodb://localhost:27017";

            services.AddMvc();
            var builder   = new ContainerBuilder();
            var container = EventFlowOptions.New
                            .UseAutofacContainerBuilder(builder)
                            .ConfigureMongoDb(mongoUrl, "pages")
                            .PublishToRabbitMq(RabbitMqConfiguration.With(rabbmitMqUri))
                            //.ConfigureElasticsearch(new Uri("http://localhost:9200"))
                            //.UseElasticsearchReadModel<StoryReadModel>()
                            .UseEventStoreEventStore(eventStoreUri)
                            .UseInMemorySnapshotStore()
                            .AddDefaults(Assembly)
                            .UseMongoDbReadModel <UserReadModel>()
                            .AddMetadataProvider <AddGuidMetadataProvider>()
                            .AddAspNetCoreMetadataProviders();

            builder.Populate(services);
            ApplicationContainer = builder.Build();
            return(new AutofacServiceProvider(ApplicationContainer));
        }
Ejemplo n.º 14
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddSwaggerGen(x =>
            {
                x.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Read Api Eventflow Demo - API", Version = "v1"
                });
            });

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);

            string           elasticSearchUrl = Environment.GetEnvironmentVariable("ELASTICSEARCHURL");
            ContainerBuilder containerBuilder = new ContainerBuilder();
            Uri node = new Uri(elasticSearchUrl);
            ConnectionSettings settings = new ConnectionSettings(node);

            settings.DisableDirectStreaming();

            ElasticClient elasticClient      = new ElasticClient(settings);
            string        rabbitMqConnection = Environment.GetEnvironmentVariable("RABBITMQCONNECTION");

            Options = EventFlowOptions.New
                      .UseAutofacContainerBuilder(containerBuilder)
                      .AddDefaults(typeof(Employee).Assembly)
                      .ConfigureElasticsearch(() => elasticClient)
                      .RegisterServices(sr => sr.Register <IScopedContext, ScopedContext>(Lifetime.Scoped))
                      .RegisterServices(sr => sr.RegisterType(typeof(EmployeeLocator)))
                      .UseElasticsearchReadModel <EmployeeReadModel, EmployeeLocator>()
                      .RegisterServices(sr => sr.RegisterType(typeof(TransactionLocator)))
                      .UseElasticsearchReadModel <TransactionReadModel, TransactionLocator>()
                      .AddQueryHandlers(typeof(ESTransactionGetQueryHandler), typeof(ESEmployeeGetQueryHandler))
                      .AddAsynchronousSubscriber <EmployeeAggregate, EmployeeId, EmployeeAddedEvent, AddNewEmployeeSubscriber>()
                      .AddSubscribers(typeof(AllEventsSubscriber))
                      .Configure(c => c.IsAsynchronousSubscribersEnabled = true)
                      .Configure(c => c.ThrowSubscriberExceptions        = true)
                      .SubscribeToRabbitMq(
                RabbitMqConfiguration.With(new Uri(rabbitMqConnection),
                                           true, 5, "eventflow"))

                      .AddAspNetCore();

            containerBuilder.Populate(services);
            var container = containerBuilder.Build();

            using (var scope = container.BeginLifetimeScope())
            {
                var subscriber           = scope.Resolve <IRabbitMqSubscriber>();
                var configuration        = scope.Resolve <IRabbitMqConfiguration>();
                var domainEventPublisher = scope.Resolve <IDomainEventPublisher>();
                subscriber.SubscribeAsync(configuration.Exchange, configuration.Exchange + "Queue", EventFlowOptionsRabbitMqExtensions.Listen,
                                          domainEventPublisher, cancellationToken: CancellationToken.None).Wait();
            }

            var _tenantIndex = new ElasticSearchIndex(elasticSearchUrl);

            _tenantIndex.CreateIndex("employeeindex", elasticSearchUrl);
            services.AddSingleton(_tenantIndex.ElasticClient);
            return(new AutofacServiceProvider(container));
        }
Ejemplo n.º 15
0
        protected RabbitMqClient(RabbitMqConfiguration config)
        {
            _configuration = config;
            var factory = new ConnectionFactory {
                HostName = _configuration.Address, Password = _configuration.Password, Port = _configuration.Port
            };

            _requestQueueName   = _configuration.RequestQueueName;
            _responseQueueName  = _configuration.ResponseQueueName;
            _broadcastQueueName = _configuration.BroadcastQueueName;

            _packetFactory  = new PacketContainerFactory();
            _requestFactory = new PendingRequestFactory();

            _connection = factory.CreateConnection();
            _channel    = _connection.CreateModel();

            _channel.QueueDeclare(_requestQueueName, true, false, false, null);
            _channel.QueueDeclare(_responseQueueName, true, false, false, null);
            _channel.QueueDeclare(_broadcastQueueName, true, false, false, null);

            var consumer = new EventingBasicConsumer(_channel);

            consumer.Received += OnMessage;

            _channel.BasicConsume(_responseQueueName, true, consumer);

            _pendingRequests = new ConcurrentDictionary <Guid, PendingRequest>();
        }
Ejemplo n.º 16
0
        private void InitializeBroadcastExchange(RabbitMqConfiguration rabbitMqConfiguration)
        {
            _exchangeName = string.IsNullOrEmpty(rabbitMqConfiguration.ExchangeName)
                ? throw new ArgumentException(
                                      $"{nameof(RabbitMqConfiguration)} exchange name string cannot be null or empty.",
                                      nameof(RabbitMqConfiguration))
                : rabbitMqConfiguration.ExchangeName;

            // declare the exchange
            _rabbitMqModel.ExchangeDeclare(_exchangeName, ExchangeType.Fanout);

            // declare the temporary queue for this service and bind it to the exchange
            var queueName = _rabbitMqModel.QueueDeclare().QueueName;

            _rabbitMqModel.QueueBind(queueName, rabbitMqConfiguration.ExchangeName, string.Empty);

            var consumerEventingService = new EventingBasicConsumer(_rabbitMqModel);

            consumerEventingService.Received += async(model, ea) =>
            {
                var jsonWrappingObject = Encoding.UTF8.GetString(ea.Body.ToArray());
                var wrappingObject     = JsonSerializer.Deserialize <RabbitMqMessage>(jsonWrappingObject);

                var messageId = wrappingObject.Id;
                _subscriptionDictionary.TryGetValue(messageId, out var rawHandler);
                if (rawHandler == null)
                {
                    return;
                }

                var handler = (IMessageHandler <IMessage>)rawHandler;
                await handler.HandleAsync(wrappingObject.Data);
            };
        }
Ejemplo n.º 17
0
        public static async Task Main(string[] args)
        {
            var builder = new HostBuilder()
                          .ConfigureAppConfiguration((host, config) => {
                config.SetBasePath(Directory.GetCurrentDirectory());
                config.AddJsonFile("appsettings.json", true, true);
                config.AddJsonFile($"appsettings.{host.HostingEnvironment.EnvironmentName}.json", true, true);
                config.AddEnvironmentVariables();
            })
                          .ConfigureServices(
                (hostcontext, services) => {
                var envconfig = EnvironmentConfiguration.Bind(hostcontext.Configuration);
                services.AddSingleton(envconfig);

                EventFlowOptions.New
                .Configure(cfg => cfg.IsAsynchronousSubscribersEnabled = true)
                .UseServiceCollection(services)
                .AddAspNetCoreMetadataProviders()
                .PublishToRabbitMq(RabbitMqConfiguration.With(new Uri($"{envconfig.RabbitMqConnection}"),
                                                              true, 5, envconfig.RabbitExchange))
                .RegisterModule <DomainModule>()

                //
                // subscribe services changed
                //
                .AddAsynchronousSubscriber <VehicleAggregate, VehicleId, LocationUpdatedEvent, RabbitMqConsumePersistanceService>()
                .RegisterServices(s => {
                    s.Register <IHostedService, RabbitConsumePersistenceService>(Lifetime.Singleton);
                    s.Register <IHostedService, RabbitMqConsumePersistanceService>(Lifetime.Singleton);
                });
            })
                          .ConfigureLogging((hostingContext, logging) => { });

            await builder.RunConsoleAsync();
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Create new instance of <see cref="HostedRabbitMqService"/>.
 /// </summary>
 public HostedRabbitMqService(IOptions <RabbitMqServicebusConfiguration> options, ILogger <HostedRabbitMqService> logger, IConnectionService connectionService, IMessageReceiver messageReceiver)
 {
     _configuration     = options.Value.RabbitMQ;
     _logger            = logger;
     _connectionService = connectionService;
     _messageReceiver   = messageReceiver;
 }
Ejemplo n.º 19
0
        public async Task AddProductToCart()
        {
            var rmqUri = new Uri("amqp://*****:*****@localhost:5672/vhost");

            var services = new ServiceCollection();

            services.AddTransient <IProductRepository, FakeProductRepository>();
            using var resolver = EventFlowOptions.New
                                 .UseServiceCollection(services)
                                 .AddDefaults(typeof(CartContext).Assembly)
                                 .UseEntityFrameworkEventStore <CartContext>()
                                 .ConfigureEntityFramework(EntityFrameworkConfiguration.New)
                                 .AddDbContextProvider <CartContext, MySqlCartContextProvider>()
                                 .AddEvents(typeof(ProductAddedEvent))
                                 .AddCommands(typeof(AddProductCommand))
                                 .AddCommandHandlers(typeof(AddProductCommandHandler))
                                 .PublishToRabbitMq(RabbitMqConfiguration.With(rmqUri))
                                 .CreateResolver();

            var commandBus     = resolver.Resolve <ICommandBus>();
            var aggregateStore = resolver.Resolve <IAggregateStore>();

            CartId cartId = CartId.NewCartId();
            await commandBus.PublishAsync(
                new AddProductCommand(cartId, new ProductId(Guid.Empty)),
                CancellationToken.None);

            Cart cart = await aggregateStore.LoadAsync <Cart, CartId>(cartId, CancellationToken.None);

            Assert.AreEqual(1, cart.Products.Count);
        }
Ejemplo n.º 20
0
 protected ProducerBase(
     ConnectionFactory connectionFactory,
     RabbitMqConfiguration <IRabbitMqItem> rabbitMqConfiguration,
     ILogger logger
     ) : base(connectionFactory, rabbitMqConfiguration, logger)
 {
 }
        public void GetConfiguration_HasNoQueueWithId_ReturnsNull()
        {
            var configuration = new RabbitMqConfiguration();

            var result = configuration.GetQueueConfiguration("id");

            Assert.That(result == null);
        }
Ejemplo n.º 22
0
        public RabbitMqClient(ILogWriter logWriter, RabbitMqConfiguration config)
        {
            _logWriter         = logWriter;
            _connectionFactory = BuildConnectionFactory(config);

            Connect();
            DeclareQueue(config.QueueName);
        }
Ejemplo n.º 23
0
 public RabbitManager(RabbitMqConfiguration rabbitMqConfiguration,
                      ILifetimeScope lifetimeScope,
                      ILogger <RabbitManager> logger)
 {
     _rabbitMqConfiguration = rabbitMqConfiguration;
     _lifetimeScope         = lifetimeScope;
     _logger = logger;
 }
Ejemplo n.º 24
0
 public LinkController(IRepository <Link> linkRepository,
                       IUnitOfWorkFactory unitOfWorkFactory,
                       RabbitMqConfiguration rabbitMqConfiguration)
 {
     _linkRepository    = linkRepository;
     _unitOfWorkFactory = unitOfWorkFactory;
     _rabbitMqService   = new RabbitMqService(rabbitMqConfiguration);
 }
Ejemplo n.º 25
0
 public LinkHandler(RabbitMqConfiguration configuration,
                    GlobalSettings globalSettings,
                    IDistributedCache distributedCache)
 {
     _configuration    = configuration;
     _globalSettings   = globalSettings;
     _distributedCache = distributedCache;
 }
Ejemplo n.º 26
0
        public void SetUp()
        {
            sendEndpointProviderMock  = new Mock <ISendEndpointProvider>();
            _cacheServiceMock         = new Mock <ICacheService>();
            rabbitMqConfigurationMock = new Mock <IOptions <RabbitMqConfiguration> >();
            _loggerMock      = new Mock <ILogger <IDispatcher> >();
            sendEndpointMock = new Mock <ISendEndpoint>();

            RabbitMqConfiguration rabbitMqConfiguration = new RabbitMqConfiguration();

            rabbitMqConfiguration.Host     = "localhost";
            rabbitMqConfiguration.Port     = 15672;
            rabbitMqConfiguration.Username = "******";
            rabbitMqConfiguration.Password = "******";

            _cacheServiceMock.Setup(x => x.Get($"deepsearch-{NotSearchRequestKey}-{dataPartner}"))
            .Returns(Task.FromResult(JsonConvert.SerializeObject(wave)));
            _cacheServiceMock.Setup(x => x.SaveRequest(It.IsAny <SearchRequest>()))
            .Returns(Task.CompletedTask);

            _cacheServiceMock.Setup(x => x.GetRequest(It.IsAny <string>()))
            .Returns(Task.FromResult(new SearchRequest {
                DataPartners = new List <DataPartner>()
                {
                    new DataPartner {
                        Completed = false, Name = "ICBC"
                    }
                }
            }));


            _cacheServiceMock.Setup(x => x.Get($"deepsearch-{SearchRequestKey}-{dataPartner}"))
            .Returns(Task.FromResult(""));
            wave = new WaveSearchData
            {
                AllParameter       = new List <Person>(),
                CurrentWave        = 2,
                DataPartner        = dataPartner,
                NewParameter       = new List <Person>(),
                SearchRequestKey   = SearchRequestKey,
                NumberOfRetries    = 1,
                TimeBetweenRetries = 3
            };
            _cacheServiceMock.Setup(x => x.Get($"deepsearch-{NotSearchRequestKey}-{dataPartner}"))
            .Returns(Task.FromResult(JsonConvert.SerializeObject(wave)));

            sendEndpointProviderMock
            .Setup(x => x.GetSendEndpoint(It.IsAny <Uri>()))
            .Returns(Task.FromResult(sendEndpointMock.Object));


            rabbitMqConfigurationMock.Setup(x => x.Value).Returns(rabbitMqConfiguration);

            sendEndpointMock.Setup(x => x.Send <PersonSearchOrdered>(It.IsAny <PersonSearchOrdered>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(sendEndpointMock));

            sut = new Dispatcher(_loggerMock.Object, sendEndpointProviderMock.Object, rabbitMqConfigurationMock.Object, _cacheServiceMock.Object);
        }
Ejemplo n.º 27
0
        private IRootResolver BuildResolver(Exchange exchange, Func <IEventFlowOptions, IEventFlowOptions> configure = null)
        {
            configure = configure ?? (e => e);

            return(configure(EventFlowOptions.New
                             .PublishToRabbitMq(RabbitMqConfiguration.With(_uri, false, exchange: exchange.Value))
                             .AddDefaults(EventFlowTestHelpers.Assembly))
                   .CreateResolver(false));
        }
        public static void AddRabbitmq(this EventLogOptions eventLogOptions, RabbitMqConfiguration options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            eventLogOptions.RegisterExtension(new RabbitMQExtension(options));
        }
Ejemplo n.º 29
0
 public RabbitMqProducer(IConfiguration configuration, ILogger <RabbitMqProducer> logger)
 {
     _logger        = logger;
     _defaultConfig = new RabbitMqConfiguration(configuration);
     if (!int.TryParse(configuration["WAIT_TIME"], out _waitTimeMilliseconds))
     {
         _waitTimeMilliseconds = 10;
     }
 }
Ejemplo n.º 30
0
        public void With_no_param_should_set_default_rabbit_config()
        {
            var sut = new RabbitMqConfiguration();

            Assert.AreEqual("localhost", sut.Host);
            Assert.AreEqual(5672, sut.Port);
            Assert.AreEqual("guest", sut.Username);
            Assert.AreEqual("guest", sut.Password);
        }