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);
        }
        void SetupQueueListener(string queueName)
        {
            receivedMessages = new BlockingCollection <TransportMessage>();
            dequeueStrategy  = new RabbitMqDequeueStrategy(connectionManager, null, new ReceiveOptions(s => SecondaryReceiveSettings.Disabled(), new MessageConverter(), 1, 1000, true, "Cluster test"));
            dequeueStrategy.Init(Address.Parse(queueName), new TransactionSettings(true, TimeSpan.FromSeconds(30), IsolationLevel.ReadCommitted, 5, false, false), m =>
            {
                receivedMessages.Add(m);
                return(true);
            }, (s, exception) =>
            {
            });

            dequeueStrategy.Start(1);
        }
        void SetupQueueListener(string queueName)
        {
            receivedMessages = new BlockingCollection <TransportMessage>();
            dequeueStrategy  = new RabbitMqDequeueStrategy {
                ConnectionManager = connectionManager, PurgeOnStartup = true
            };
            dequeueStrategy.Init(Address.Parse(queueName), TransactionSettings.Default, m =>
            {
                receivedMessages.Add(m);
                return(true);
            }, (s, exception) =>
            {
            });

            dequeueStrategy.Start(1);
        }
Пример #4
0
        public void SetUp()
        {
            routingTopology  = new ConventionalRoutingTopology(true);
            receivedMessages = new BlockingCollection <TransportMessage>();

            var config = new ConnectionConfiguration();

            config.ParseHosts("localhost:5672");

            var connectionFactory = new RabbitMqConnectionFactory(config);

            connectionManager = new RabbitMqConnectionManager(connectionFactory, config);

            publishChannel = connectionManager.GetPublishConnection().CreateModel();

            var channelProvider = new FakeChannelProvider(publishChannel);

            sender = new RabbitMqMessageSender(routingTopology, channelProvider, new IncomingContext(null, null));

            dequeueStrategy = new RabbitMqDequeueStrategy(connectionManager, new RepeatedFailuresOverTimeCircuitBreaker("UnitTest", TimeSpan.FromMinutes(2), e => {}),
                                                          new ReceiveOptions(s => SecondaryReceiveSettings.Enabled(CallbackQueue, 1), new MessageConverter(), 1, 1000, false, "Unit test"));


            MakeSureQueueAndExchangeExists(ReceiverQueue);


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

            dequeueStrategy.Init(Address.Parse(ReceiverQueue), new TransactionSettings(true, TimeSpan.FromSeconds(30), IsolationLevel.ReadCommitted, 5, false, false), m =>
            {
                receivedMessages.Add(m);
                return(true);
            }, (s, exception) => { });

            dequeueStrategy.Start(MaximumConcurrency);
        }
Пример #5
0
        public void SetUp()
        {
            var 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 };

            MakeSureQueueExists(MYRECEIVEQUEUE);

            DeleteExchange(MYRECEIVEQUEUE);
            MakeSureExchangeExists(ExchangeNameConvention(Address.Parse(MYRECEIVEQUEUE),null));

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

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

            dequeueStrategy.Start(1);
        }
        void SetupQueueListener(string queueName) {
            receivedMessages = new BlockingCollection<TransportMessage>();
            dequeueStrategy = new RabbitMqDequeueStrategy {ConnectionManager = connectionManager, PurgeOnStartup = true};
            dequeueStrategy.Init(Address.Parse(queueName), TransactionSettings.Default, m =>
                {
                    receivedMessages.Add(m);
                    return true;
                }, (s, exception) =>
                    {
                    });

            dequeueStrategy.Start(1);
        }
        void SetupQueueListener(string queueName)
        {
            receivedMessages = new BlockingCollection<TransportMessage>();
            dequeueStrategy = new RabbitMqDequeueStrategy(connectionManager, null, new ReceiveOptions(s => SecondaryReceiveSettings.Disabled(), new MessageConverter(),1,1000,true,"Cluster test"));
            dequeueStrategy.Init(Address.Parse(queueName), new TransactionSettings(true, TimeSpan.FromSeconds(30), IsolationLevel.ReadCommitted, 5, false, false), m =>
                {
                    receivedMessages.Add(m);
                    return true;
                }, (s, exception) =>
                    {
                    });

            dequeueStrategy.Start(1);
        }