示例#1
0
        public void SetUp()
        {
            _publisher = new RabbitMqPublisher <string>(EmptyLogFactory.Instance, _settings);

            _publisher
            .SetPublishStrategy(new DefaultFanoutPublishStrategy(_settings))
            .DisableInMemoryQueuePersistence()
            .SetSerializer(new TestMessageSerializer());
        }
        public void SetUp()
        {
            var settings = new RabbitMqSubscriptionSettings
            {
                ConnectionString       = "",
                DeadLetterExchangeName = "",
                ExchangeName           = "",
                IsDurable  = true,
                QueueName  = "",
                RoutingKey = "RoutingKey"
            };

            _publisher = new RabbitMqPublisher <string>(new NullLoggerFactory(), settings);

            _publisher
            .SetPublishStrategy(new DefaultFanoutPublishStrategy(settings))
            .SetSerializer(new JsonMessageSerializer <string>());
        }
示例#3
0
        public void ShouldNotPublishNonSeriazableMessage()
        {
            var publisher = new RabbitMqPublisher <ComplexType>(EmptyLogFactory.Instance, _settings);

            publisher
            .SetPublishStrategy(new DefaultFanoutPublishStrategy(_settings))
            .DisableInMemoryQueuePersistence()
            .SetSerializer(new JsonMessageSerializer <ComplexType>())
            .Start();

            var invalidObj = new ComplexType
            {
                A = 10
            };

            invalidObj.B = invalidObj;

            Assert.ThrowsAsync <JsonSerializationException>(() => publisher.ProduceAsync(invalidObj));
        }
示例#4
0
        public async Task ShouldUseDeadLetterExchange()
        {
            const string expected = "GetDefaultHost message";


            _publisher.SetPublishStrategy(new DefaultFanoutPublishStrategy(_settings));

            _publisher.Start();

            SetupNormalQueue();
            SetupPoisonQueue();

            await _publisher.ProduceAsync(expected);


            // Reject the message
            ReadFromQueue(QueueName, false);

            var result = ReadFromQueue(PoisonQueueName);

            Assert.That(result, Is.EqualTo(expected));
        }
示例#5
0
        public Broker(
            RabbitMqSubscriber <OrderBook> subscriber,
            RabbitMqPublisher <Quote> publisher,
            ILog logger)
        {
            this.logger     = logger;
            this.subscriber = subscriber;
            this.publisher  = publisher;

            // Using default message reader strategy
            subscriber
            .SetMessageDeserializer(new MessageDeserializer())
            .Subscribe(HandleMessage)
            .SetLogger(logger);

            publisher
            .SetPublishStrategy(new DefaultFnoutPublishStrategy("", durable: true))
            .SetSerializer(new MessageSerializer())
            .SetLogger(logger);

            this.controller = new QuoteFeedController(this, logger, COMPONENT_NAME);
        }