private static void StartDeadLetterExchange(IModel channel, DeadLetterExchange exchange)
 {
     channel.ExchangeDeclare(
         exchange: exchange.Name,
         type: exchange.Type,
         durable: true,
         autoDelete: false,
         arguments: null);
 }
Ejemplo n.º 2
0
 private static void StartDeadLetterExchangePassive(IModel channel, DeadLetterExchange exchange)
 {
     channel.ExchangeDeclarePassive(exchange: exchange.Name);
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            try
            {
                #region 架构师VIP班-1
                {
                    ////生产者消费者
                    //ProductionConsumer.Show();
                }
                {
                    /////多生产者多消费者
                    //IConfigurationRoot config = new ConfigurationBuilder()
                    // .SetBasePath(Directory.GetCurrentDirectory())
                    // .AddCommandLine(args)//支持命令行参数
                    // .Build();

                    //string strMinute = config["minute"];  //什么时候开始执行
                    //string No = config["no"]; //生产者编号
                    //int minute = Convert.ToInt32(strMinute);
                    //bool flg = true;
                    //while (flg)
                    //{
                    //    if (DateTime.Now.Minute == minute)
                    //    {
                    //        Console.WriteLine($"到{strMinute}分钟,开始写入消息。。。");
                    //        flg = false;
                    //        MultiProductionConsumer.Show(No);
                    //    }
                    //}
                }
                {
                    //互为生产者消费者
                    //Task.Run(() => { MutualProductionConsumer.ShowProductio(); });
                    //Task.Run(() => { MutualProductionConsumer.ShowConsumer(); });
                }
                {
                    ////秒杀
                    //IConfigurationRoot config = new ConfigurationBuilder()
                    // .SetBasePath(Directory.GetCurrentDirectory())
                    // .AddCommandLine(args)//支持命令行参数
                    // .Build();
                    //string strMinute = config["minute"];  //什么时候开始执行
                    //int minute = Convert.ToInt32(strMinute);

                    //bool flg = true;
                    //while (flg)
                    //{
                    //    Console.WriteLine($"到{strMinute}分钟,开始写入消息。。。");
                    //    if (DateTime.Now.Minute == minute)
                    //    {
                    //        flg = false;
                    //        SeckillConsumer.Show();
                    //    }
                    //}
                }
                {
                    ////优先级 队列
                    // PriorityQueue.Show();
                }
                {
                    ////发布订阅模式
                    //PublishSubscribeConsumer.Show();
                }

                #endregion

                #region 架构师VIP班-2
                {
                    //写日志 错误日志发送邮件
                    // 需要分支去处理的时候就可以用DirectExchange
                    //  DirectExchange.Show();
                }
                {
                    //发布订阅模式
                    //FanoutExchange.Show();
                }
                {
                    //打标签 实现关键词的过滤 分组
                    // TopicExchange.Show();
                }
                {
                    //HeaderExchange.Show();
                }

                {
                    //延时队列 DeadLetter
                    DeadLetterExchange.Show();
                }
                #endregion

                #region 架构师VIP班-3
                {
                    //ProductionMessageTx.Show();
                }
                {
                    //ProductionMessageConfirm.Show();
                }
                {
                    //ConsumptionACKConfirm.Show();
                }
                #endregion

                Console.Read();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }