public void TestContextFixtureSetup()
        {
            Logger.Trace("Running TestContextFixtureSetup");
            CaptureExistingErlangProcesses();
            StartUpRabbitNodes();
            ClusterRabbitNodes();
            SetHAPolicy();

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

            Logger.Fatal("RabbitMQ cluster setup complete");
        }
Ejemplo n.º 2
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);
        }