public void Publishing_message_to_fanout_exchange_publishes_to_all_queues() { using (IConnection connection = mqFactory.CreateConnection()) using (IModel channel = connection.CreateModel()) { channel.RegisterFanoutExchange(ExchangeFanout); RegisterQueue(channel, QueueNames <HelloRabbit> .In, exchange: ExchangeFanout); RegisterQueue(channel, QueueNames <HelloRabbit> .Priority, exchange: ExchangeFanout); byte[] payload = new HelloRabbit { Name = "World!" }.ToJson().ToUtf8Bytes(); var props = channel.CreateBasicProperties(); props.Persistent = true; channel.BasicPublish(ExchangeFanout, QueueNames <HelloRabbit> .In, props, payload); var basicGetMsg = channel.BasicGet(QueueNames <HelloRabbit> .In, noAck: true); Assert.That(basicGetMsg, Is.Not.Null); basicGetMsg = channel.BasicGet(QueueNames <HelloRabbit> .Priority, noAck: true); Assert.That(basicGetMsg, Is.Not.Null); } }
private static void PublishHelloRabbit(IModel channel, string text = "World!") { byte[] payload = new HelloRabbit { Name = text }.ToJson().ToUtf8Bytes(); var props = channel.CreateBasicProperties(); props.Persistent = true; channel.BasicPublish(Exchange, QueueNames <HelloRabbit> .In, props, payload); }
public void Can_publish_messages_to_RabbitMQ() { using (IConnection connection = mqFactory.CreateConnection()) using (IModel channel = connection.CreateModel()) { 5.Times(i => { byte[] payload = new HelloRabbit { Name = "World! #{0}".Fmt(i) }.ToJson().ToUtf8Bytes(); var props = channel.CreateBasicProperties(); props.SetPersistent(true); channel.BasicPublish(exchange: Exchange, routingKey: QueueNames <HelloRabbit> .In, basicProperties: props, body: payload); Console.WriteLine("Sent Message " + i); Thread.Sleep(1000); }); } }
public void Can_publish_messages_to_RabbitMQ() { using (IConnection connection = mqFactory.CreateConnection()) using (IModel channel = connection.CreateModel()) { 5.Times(i => { byte[] payload = new HelloRabbit { Name = "World! #{0}".Fmt(i) }.ToJson().ToUtf8Bytes(); var props = channel.CreateBasicProperties(); props.Persistent = true; channel.BasicPublish(exchange: Exchange, routingKey: QueueNames<HelloRabbit>.In, basicProperties: props, body: payload); Console.WriteLine("Sent Message " + i); Thread.Sleep(1000); }); } }
public void Publishing_message_to_fanout_exchange_publishes_to_all_queues() { using (IConnection connection = mqFactory.CreateConnection()) using (IModel channel = connection.CreateModel()) { channel.RegisterFanoutExchange(ExchangeFanout); RegisterQueue(channel, QueueNames<HelloRabbit>.In, exchange: ExchangeFanout); RegisterQueue(channel, QueueNames<HelloRabbit>.Priority, exchange: ExchangeFanout); byte[] payload = new HelloRabbit { Name = "World!" }.ToJson().ToUtf8Bytes(); var props = channel.CreateBasicProperties(); props.Persistent = true; channel.BasicPublish(ExchangeFanout, QueueNames<HelloRabbit>.In, props, payload); var basicGetMsg = channel.BasicGet(QueueNames<HelloRabbit>.In, noAck: true); Assert.That(basicGetMsg, Is.Not.Null); basicGetMsg = channel.BasicGet(QueueNames<HelloRabbit>.Priority, noAck: true); Assert.That(basicGetMsg, Is.Not.Null); } }
private static void PublishHelloRabbit(IModel channel, string text = "World!") { byte[] payload = new HelloRabbit {Name = text}.ToJson().ToUtf8Bytes(); var props = channel.CreateBasicProperties(); props.Persistent = true; channel.BasicPublish(Exchange, QueueNames<HelloRabbit>.In, props, payload); }