示例#1
0
        private static void SendDelayMsg()
        {
            RabbitmqConfigOptions rabbitmqOption = new RabbitmqConfigOptions();
            string           queueName           = "test_delayqueues";
            RabbitMQProducer producer            = new RabbitMQProducer(rabbitmqOption);

            producer.Open();
            for (int i = 0; i < 500; i++)
            {
                //producer.SendDelayQueues("这是延迟消息" + i.ToString(), queueName, (double)(10000 + i * 1000), "beDeadLetter_");
                var isPublished = producer.SendDelayQueuesWithConfirmSelect("这是延迟消息" + i.ToString(), queueName, (double)(10000 + i * 1000), "beDeadLetter_");
                Console.WriteLine($"发送{(isPublished?"成功":"失败")}");
            }
            producer.Close();
        }
示例#2
0
        private static void LoadMsg()
        {
            int    doSeconds     = 2;
            ushort prefetchCount = 1;
            RabbitmqConfigOptions rabbitmqOption = new RabbitmqConfigOptions();
            var queueName             = "queue_test_workqueues";
            RabbitMQConsumer consumer = new RabbitMQConsumer(rabbitmqOption);

            consumer.Open();
            consumer.SetWorkQueuesReceivedAction(delegate(string msg)
            {
                Console.WriteLine(DateTime.Now.ToString("HH:mm:ss") + " 1接收到消息:" + msg);
                //Thread.Sleep(doSeconds * 100 * Program.GetRandomNum(1, 50));
            }, queueName, prefetchCount, false, 20);
        }
示例#3
0
        private static void SendMsg()
        {
            RabbitmqConfigOptions rabbitmqOption = new RabbitmqConfigOptions();
            var queueName = "queue_test_workqueues";
            //var queueName = "test_delayqueues";
            RabbitMQProducer producer = new RabbitMQProducer(rabbitmqOption);

            producer.Open();
            for (int i = 0; i < 500; i++)
            {
                //producer.SendWorkQueues("这是工作队列消息" + i.ToString(), queueName);
                var isPublished = producer.SendWorkQueuesWithConfirmSelect("这是工作队列消息" + i.ToString(), queueName);
                Console.WriteLine($"发送{(isPublished?"成功":"失败")}");
            }
            producer.Close();
        }