public RabbitMqMessageQueue(string connectionString, string inputQueueName)
        {
            connectionManager = new ConnectionManager(connectionString, inputQueueName);
            if (inputQueueName == null) return;

            this.inputQueueName = inputQueueName;
        }
Beispiel #2
0
        public RabbitMqMessageQueue(string connectionString, string inputQueueName, bool ensureExchangeIsDeclared = true)
        {
            connectionManager = new ConnectionManager(connectionString);
            if (inputQueueName == null) return;

            this.inputQueueName = inputQueueName;
            this.ensureExchangeIsDeclared = ensureExchangeIsDeclared;

            InitializeLogicalQueue(inputQueueName);
        }
        /// <summary>
        /// Constructs the transport with the given connection string and input queue name. Depending on
        /// further configuration, exchange, input queue, and bindings may/may not be initialized when the
        /// transport is used.
        /// </summary>
        public RabbitMqMessageQueue(string connectionString, string inputQueueName)
        {
            string exchange;
            GetExchangeAndRoutingKeyFor(inputQueueName, out exchange, out inputQueueName);

            connectionManager = new ConnectionManager(connectionString, inputQueueName);
            if (inputQueueName == null) return;

            this.inputQueueName = inputQueueName;
        }
Beispiel #4
0
        public void DoesntActuallyConnectWhenCreatingTheFactory()
        {
            using(var connectionManager = new ConnectionManager("amqp://would_throw_if_it_connected_immediately,amqp://would_also_throw_if_it_connected_immediately"))
            {
                // arrange

                // act

                //var connection = connectionManager.GetConnection();

                // assert
            }
        }
        public void CanSendMessagesDirectlyToExchangeWithRoutingKey(int mode)
        {
            // arrange
            var routeUsingExchanges = mode > 1;
            var exchangeAsAddress = mode > 2;
            var sender = GetQueue("test.sender", removeExiting: true, oneExchangePerType: routeUsingExchanges,
                inputExchange: exchangeAsAddress ? "ex-test.sender" : null);
            var recipient = GetQueue("test.recipient", removeExiting: true);

            using (var cm = new ConnectionManager(ConnectionString, "test.sender"))
            using (var conn = cm.GetConnection())
            using (var model = conn.CreateModel())
            {
                model.QueueBind("test.recipient", "ex-test.recipient", "sample");
            }

            // act
            using (var tx = new TransactionScope())
            {
                var ctx = new AmbientTransactionContext();
                var msg = new TransportMessageToSend { Body = Encoding.GetBytes("this is a message!") };

                sender.Send("*****@*****.**", msg, ctx);
                sender.Send("*****@*****.**", msg, ctx);
                sender.Send("*****@*****.**", msg, ctx);

                tx.Complete();
            }

            // assert
            var receivedTransportMessages = GetAllMessages(recipient);

            receivedTransportMessages.Count.ShouldBe(3);
        }