public void CanStartMessageBroker()
        {
            var queueFactory = Substitute.For<IQueueFactory>();
            var messageBrokerConfig = new MessageBrokerConfig { RemoteQueueName = "MyRemoteQueueName", ServiceName = "TestBroker" };
            var entityConnectionConfig = new EntityConnectionConfig(new DatabaseConnectionConfig("(localdb)\\MSSQLLocalDB", "ABJA_Ripples"));
            var logger = NullLogger.Instance;
            var repositoryContextFactory = new RepositoryContextFactory(logger, entityConnectionConfig);
            var queueHandlerFactory = new QueueHandlerFactory(logger, queueFactory);
            var processInformation = new ProcessInformation();

            using (var messageBroker = new MessageBroker(logger, messageBrokerConfig, repositoryContextFactory, queueHandlerFactory, queueFactory, processInformation))
            {
                var cancellationToken = new CancellationToken();
                messageBroker.Start(cancellationToken);

                messageBroker.Handler(new MessageBusServiceHandshakeMessage
                {
                    ServiceName = "MyServiceName",
                    ServerName = "MyTestServer",
                    ReplyQueue = "MyQueue",
                    SendDateTime = DateTimeOffset.Now,
                    SubscribeHandlers = new List<SubscribeHandler> { new SubscribeHandler { Name = "MySubscriber", QueueName = "MyQueue", Durable = true, MessageType = "string", Topic = "MyTopic" } }
                });
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Build Message Broker
        /// </summary>
        /// <returns>The Message Bus</returns>
        public IMessageBroker Build()
        {
            var messageBrokerConfig = new MessageBrokerConfig
            {
                ServiceName     = _serviceName,
                RemoteQueueName = _remoteQueueName
            };

            var queueFactory        = new QueueFactory(_logger);
            var queueHandlerFactory = new QueueHandlerFactory(_logger, queueFactory);

            return(new MessageBroker(_logger, messageBrokerConfig, _repositoryContextFactory, queueHandlerFactory, queueFactory, _processInformation));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Build Message Bus
        /// </summary>
        /// <returns></returns>
        public IMessageBus Build()
        {
            var messageBusConfig = new MessageBusConfig
            {
                ServiceName = ServiceName
            };

            var queueFactory        = new QueueFactory(_logger);
            var queueNameUtility    = new QueueNameUtility(messageBusConfig.ServiceName);
            var messageBroker       = new MessageBroker(_logger, messageBusConfig, queueFactory, _processInformation, queueNameUtility);
            var queueHandlerFactory = new QueueHandlerFactory(_logger, queueFactory);

            return(new MessageBus(_logger, messageBroker, queueHandlerFactory, queueNameUtility));
        }
        /// <inheritdoc />
        public TestMessageBroker()
        {
            var logger = NullLogger.Instance;

            var messageBusConfig = new MessageBusConfig
            {
                ServiceName = "TestRipplesMQ"
            };

            _queueFactory = new TestQueueFactory(this);

            var processInformation = new ProcessInformation();
            var queueNameUtility   = new QueueNameUtility(messageBusConfig.ServiceName);

            _messageBroker = new MessageBroker(logger, messageBusConfig, _queueFactory, processInformation, queueNameUtility);

            var queueHandlerFactory = new QueueHandlerFactory(logger, _queueFactory);

            MessageBus = new MessageBus(logger, this, queueHandlerFactory, queueNameUtility);
        }