[rabbitmq-discuss] New to Rabbit in C#

Andre andretodd at verizon.net
Wed Jun 11 00:18:44 BST 2014


I'm new to RabbitMQ and trying to write to a Queue and verify the message
was sent. If it fails I need to know about it. I made a fake queue to watch
it fail but no matter what I see no exceptions and when I am looking for a
ack I always get one. I never see the BasicNack.

 

I'm not even sure i'm the BasicAcks is the way to go.

 

 

private void button1_Click(object sender, EventArgs e)

    {

        var factory = new ConnectionFactory() { HostName = "localhost" };

        using (var connection = factory.CreateConnection())

        {

            using (var channel = connection.CreateModel())

            {

                channel.QueueDeclare("task_queue", true, false, false,
null);

 

                var message = ("Helllo world");

                var body = Encoding.UTF8.GetBytes(message);

                channel.ConfirmSelect();

 

                var properties = channel.CreateBasicProperties();

                properties.SetPersistent(true);

                properties.DeliveryMode = 2;

                channel.BasicAcks += channel_BasicAcks;

                channel.BasicNacks += channel_BasicNacks;

                //fake queue should be task_queue

                channel.BasicPublish("", "task_2queue", true, properties,
body);

 

                channel.WaitForConfirmsOrDie();

 

                Console.WriteLine(" [x] Sent {0}", message);

            }

        }

    }

 

    void channel_BasicNacks(IModel model, BasicNackEventArgs args)

    {

 

    }

 

    void channel_BasicAcks(IModel model, BasicAckEventArgs args)

    {

 

    }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140610/d06d4c1e/attachment.html>


More information about the rabbitmq-discuss mailing list