예제 #1
0
        public void SetUp()
        {
            var connectionFactory = new ConnectionFactoryWrapper(new ConnectionFactory
            {
                HostName = "localhost",
                VirtualHost = "/",
                UserName = "******",
                Password = "******"
            });

            var serializer = new JsonSerializer();
            var logger = new ConsoleLogger();
            var consumerErrorStrategy = new DefaultConsumerErrorStrategy(connectionFactory, serializer, logger);
            var conventions = new Conventions();

            advancedBus = new RabbitAdvancedBus(
                connectionFactory,
                TypeNameSerializer.Serialize,
                serializer,
                new QueueingConsumerFactory(logger, consumerErrorStrategy),
                logger,
                CorrelationIdGenerator.GetCorrelationId,
                conventions);

            while (!advancedBus.IsConnected)
            {
                Thread.Sleep(10);
            }
        }
        public void SetUp()
        {
            routingTopology  = new ConventionalRoutingTopology();
            receivedMessages = new BlockingCollection <TransportMessage>();

            var config = new ConnectionConfiguration();

            config.ParseHosts("localhost:5672");

            var selectionStrategy = new DefaultClusterHostSelectionStrategy <ConnectionFactoryInfo>();
            var connectionFactory = new ConnectionFactoryWrapper(config, selectionStrategy);

            connectionManager = new RabbitMqConnectionManager(connectionFactory, config);

            unitOfWork = new RabbitMqUnitOfWork
            {
                ConnectionManager      = connectionManager,
                UsePublisherConfirms   = true,
                MaxWaitTimeForConfirms = TimeSpan.FromSeconds(10)
            };

            sender = new RabbitMqMessageSender
            {
                UnitOfWork      = unitOfWork,
                RoutingTopology = routingTopology
            };


            dequeueStrategy = new RabbitMqDequeueStrategy
            {
                ConnectionManager = connectionManager,
                PurgeOnStartup    = true
            };

            MakeSureQueueAndExchangeExists(ReceiverQueue);


            MessagePublisher = new RabbitMqMessagePublisher
            {
                UnitOfWork      = unitOfWork,
                RoutingTopology = routingTopology
            };
            subscriptionManager = new RabbitMqSubscriptionManager
            {
                ConnectionManager = connectionManager,
                EndpointQueueName = ReceiverQueue,
                RoutingTopology   = routingTopology
            };

            dequeueStrategy.Init(Address.Parse(ReceiverQueue), TransactionSettings.Default, m =>
            {
                receivedMessages.Add(m);
                return(true);
            }, (s, exception) => { });

            dequeueStrategy.Start(MaximumConcurrency);
        }
        static RabbitMqConnectionManager SetupRabbitMqConnectionManager(string connectionString)
        {
            var config = new ConnectionStringParser().Parse(connectionString);
//            config.OverrideClientProperties();
            var selectionStrategy    = new DefaultClusterHostSelectionStrategy <ConnectionFactoryInfo>();
            var connectionFactory    = new ConnectionFactoryWrapper(config, selectionStrategy);
            var newConnectionManager = new RabbitMqConnectionManager(connectionFactory, config);

            return(newConnectionManager);
        }
예제 #4
0
 public void SetUp()
 {
     var logger = new ConsoleLogger();
     var eventBus = new EventBus();
     var parser = new ConnectionStringParser();
     var configuration = parser.Parse("host=localhost");
     var hostSelectionStrategy = new RandomClusterHostSelectionStrategy<ConnectionFactoryInfo>();
     var connectionFactory = new ConnectionFactoryWrapper(configuration, hostSelectionStrategy);
     connection = new PersistentConnection(connectionFactory, logger, eventBus);
     persistentChannel = new PersistentChannel(connection, logger, configuration, new EventBus());
 }
        public void SetUp()
        {
            var logger                = new ConsoleLogger();
            var eventBus              = new EventBus();
            var parser                = new ConnectionStringParser();
            var configuration         = parser.Parse("host=localhost");
            var hostSelectionStrategy = new RandomClusterHostSelectionStrategy <ConnectionFactoryInfo>();
            var connectionFactory     = new ConnectionFactoryWrapper(configuration, hostSelectionStrategy);

            connection        = new PersistentConnection(connectionFactory, logger, eventBus);
            persistentChannel = new PersistentChannel(connection, logger, configuration, new EventBus());
        }
예제 #6
0
        public PersistentChannelTests()
        {
            var eventBus              = new EventBus();
            var parser                = new ConnectionStringParser();
            var configuration         = parser.Parse("host=localhost");
            var hostSelectionStrategy = new RandomClusterHostSelectionStrategy <ConnectionFactoryInfo>();
            var connectionFactory     = new ConnectionFactoryWrapper(configuration, hostSelectionStrategy);

            connection        = new PersistentConnection(connectionFactory, eventBus);
            persistentChannel = new PersistentChannel(connection, configuration, new EventBus());
            connection.Initialize();
        }
        public void SetUp()
        {
            var eventBus = new EventBus();
            var logger = new ConsoleLogger();
            var parser = new ConnectionStringParser();
            var configuration = parser.Parse("host=localhost");
            var hostSelectionStrategy = new DefaultClusterHostSelectionStrategy<ConnectionFactoryInfo>();
            var connectionFactory = new ConnectionFactoryWrapper(configuration, hostSelectionStrategy);
            connection = new PersistentConnection(connectionFactory, logger, eventBus);
            var persistentChannelFactory = new PersistentChannelFactory(logger, configuration, eventBus);

            dispatcher = new ClientCommandDispatcher(connection, persistentChannelFactory);
        }
예제 #8
0
        public void SetUp()
        {
            var eventBus              = new EventBus();
            var logger                = new ConsoleLogger();
            var parser                = new ConnectionStringParser();
            var configuration         = parser.Parse("host=localhost");
            var hostSelectionStrategy = new DefaultClusterHostSelectionStrategy <ConnectionFactoryInfo>();
            var connectionFactory     = new ConnectionFactoryWrapper(configuration, hostSelectionStrategy);

            connection = new PersistentConnection(connectionFactory, logger, eventBus);
            var persistentChannelFactory = new PersistentChannelFactory(logger, configuration, eventBus);

            dispatcher = new ClientCommandDispatcher(connection, persistentChannelFactory);
        }