Ejemplo n.º 1
0
        /// <summary>
        /// Send a message to an established source (will be routed to destinations by key)
        /// </summary>
        public void Send(string sourceName, string typeDescription, string senderName, string correlationId, byte[] data)
        {
            if (data == null)
            {
                data = new byte[0];
            }

            var properties = TaggedBasicProperties(typeDescription ?? sourceName, senderName, correlationId);

            _longTermConnection.WithChannel(channel => channel?.BasicPublish(
                                                exchange: sourceName,
                                                routingKey: "",
                                                mandatory: false, // if true, there must be at least one routing output otherwise the send will error
                                                basicProperties: properties,
                                                body: data)
                                            );
        }
        public void Can_pick_up_a_message_from_a_different_connection_after_its_acknowledged_but_not_received()
        {
            router.AddSource("src", null);
            router.AddDestination("dst");
            router.Link("src", "dst");
            router.Send("src", null, null, null, "Hello, World");

            channelAction.WithChannel(channel => channel.BasicAck(0, true));

            var conn = ConfigurationHelpers.FreshConnectionFromAppConfig();

            var conn2    = conn.ConfigureConnectionFactory().CreateConnection();
            var channel2 = conn2.CreateModel();
            var result   = channel2.BasicGet("dst", false);
            var message  = Encoding.UTF8.GetString(result.Body);

            Assert.That(message, Is.EqualTo("Hello, World"));
        }