public async Task ReceiveOnSubscribe_WHEN_SubscriberQueueDeleted_THEN_ItRecreates_SubscriberQueue_AND_ReceivesPublishedData()
        {
            const string message = "Test-Message-123";

            using (var receivedEvent = new ManualResetEvent(false))
            {
                using (var publisher = StartBus(_publisherQueueName))
                {
                    async Task HandlerMethod(string data)
                    {
                        if (string.Equals(data, message))
                        {
                            receivedEvent.Set();
                        }
                    }

                    using (var subscriber = StartBus(_subscriberQueueName, HandlerMethod))
                    {
                        await subscriber.Subscribe <string>();

                        // remove the input queue
                        RabbitMqTransportFactory.DeleteQueue(_subscriberQueueName);

                        // wait a short while
                        await Task.Delay(TimeSpan.FromSeconds(60));

                        // check that published message is received without problems
                        await publisher.Publish(message);

                        receivedEvent.WaitOrDie(TimeSpan.FromSeconds(2),
                                                "The event has not been receved by the subscriber within the expected time");
                    }
                }
            }
        }
示例#2
0
        public async Task AutomaticallyCreatesDestinationQueue()
        {
            var queueName = TestConfig.GetName("does_not_exist_yet");

            RabbitMqTransportFactory.DeleteQueue(queueName);

            Thread.Sleep(1000);

            // first we send a message to a queue that does not exist at this time
            Console.WriteLine($"Sending 'hej med dig min ven!' message to '{queueName}'");
            await _bus.Advanced.Routing.Send(queueName, "hej med dig min ven!");

            Thread.Sleep(1000);

            // then we start a server listening on the queue
            var gotTheMessage = new ManualResetEvent(false);

            StartServer(queueName).Handle <string>(async str =>
            {
                gotTheMessage.Set();
            });

            Console.WriteLine("Waiting for message to arrive");
            gotTheMessage.WaitOrDie(TimeSpan.FromSeconds(5));
            Console.WriteLine("Got it :)");
        }
示例#3
0
        public void ThrowExceptionWhenQueueDoesNotExist()
        {
            var queueName = TestConfig.GetName("non-existing-queue");

            RabbitMqTransportFactory.DeleteQueue(queueName);

            Assert.ThrowsAsync <RebusApplicationException>(() => _bus.Advanced.Routing.Send(queueName, "hej"));
        }
示例#4
0
        protected override void SetUp()
        {
            RabbitMqTransportFactory.DeleteQueue(_publisherQueueName);
            RabbitMqTransportFactory.DeleteQueue(_subscriber1QueueName);
            RabbitMqTransportFactory.DeleteQueue(_subscriber2QueueName);

            _publisher = GetBus(_publisherQueueName);
        }
示例#5
0
        public void Dispose()
        {
            try
            {
                RabbitMqTransportFactory.DeleteQueue(_queueName);

                Console.WriteLine($"Queue '{_queueName}' deleted");
            }
            catch { }
        }
        protected override void SetUp()
        {
            RabbitMqTransportFactory.DeleteQueue(_inputQueueName);

            _activator = Using(new BuiltinHandlerActivator());

            Configure.With(_activator)
            .Logging(l => l.Console(LogLevel.Warn))
            .Transport(t => t.UseRabbitMq(ConnectionString, _inputQueueName))
            .Serialization(s => s.Decorate(c => new Utf8Fallback(c.Get <ISerializer>())))
            .Start();
        }
示例#7
0
        protected override void SetUp()
        {
            var queueName = TestConfig.QueueName("expressperf");

            RabbitMqTransportFactory.DeleteQueue(queueName);

            _activator = Using(new BuiltinHandlerActivator());

            _bus = Configure.With(_activator)
                   .Logging(l => l.ColoredConsole(LogLevel.Info))
                   .Transport(t => t.UseRabbitMq(RabbitMqTransportFactory.ConnectionString, queueName))
                   .Options(o => o.SetMaxParallelism(100))
                   .Start();
        }
        public async Task ReceiveOnSubscribe_WHEN_SubscriberQueueDeleted_THEN_ItThrowsException()
        {
            const string message = "Test-Message-123";

            using (var receivedEvent = new ManualResetEvent(false))
            {
                using (var publisher = StartBus(_publisherQueueName))
                {
                    async Task HandlerMethod(string data)
                    {
                        if (string.Equals(data, message))
                        {
                            receivedEvent.Set();
                        }
                    }

                    using (var subscriber = StartBus(_subscriberQueueName, HandlerMethod, false, false))
                    {
                        // create the input queue
                        RabbitMqTransportFactory.CreateQueue(_subscriberQueueName);

                        await subscriber.Subscribe <string>();

                        // remove the input queue
                        RabbitMqTransportFactory.DeleteQueue(_subscriberQueueName);

                        // wait a short while
                        await Task.Delay(5000);

                        // check that published message is received without problems
                        await publisher.Publish(message);

                        var result = receivedEvent.WaitOne(TimeSpan.FromSeconds(2));
                        Assert.IsFalse(result);
                    }
                }
            }
        }
示例#9
0
 protected override void SetUp()
 {
     RabbitMqTransportFactory.DeleteQueue(_priorityQueueName);
 }
 protected override void TearDown()
 {
     base.TearDown();
     RabbitMqTransportFactory.DeleteQueue(_publisherQueueName);
     RabbitMqTransportFactory.DeleteQueue(_subscriberQueueName);
 }
 protected override void SetUp()
 {
     RabbitMqTransportFactory.DeleteQueue(_testQueue1);
 }
示例#12
0
 public void Dispose()
 {
     RabbitMqTransportFactory.DeleteQueue(QeueuName);
 }
示例#13
0
 protected override void SetUp()
 {
     RabbitMqTransportFactory.DeleteQueue(_noneExistingQueueName);
     RabbitMqTransportFactory.DeleteQueue(_mandatoryQueue);
 }