public IActionResult Post([FromBody] MQMsg data)
        {
            // 创建连接工厂
            //ConnectionFactory connectionFactory = new ConnectionFactory()
            //{
            //    UserName = "******",
            //    Password = "******",
            //    HostName = "localhost"
            //};

            // 创建连接
            using (var conn = _service.GetConnection())
            {
                // 创建通道
                using (var channel = conn.CreateModel())
                {
                    // 声明一个队列
                    channel.QueueDeclare("myQueue", false, false, false);

                    // 定义发送内容
                    string input = JsonConvert.SerializeObject(data);

                    var sendBytes = Encoding.UTF8.GetBytes(input);

                    channel.BasicPublish("", "myQueue", null, sendBytes);
                }
                // conn.Close();
            }

            return(new JsonResult(new MQResult {
                Message = "Post Info Successed"
            }));
        }
        public IActionResult PostDirectMsg([FromBody] MQMsg data)
        {
            // 创建连接工厂
            //ConnectionFactory connectionFactory = new ConnectionFactory()
            //{
            //    UserName = "******",
            //    Password = "******",
            //    HostName = "localhost"
            //};

            // 创建连接
            using (var conn = _service.GetConnection()) // connectionFactory.CreateConnection();
            {
                // 创建通道
                using var channel = conn.CreateModel();
                string exchangeName = "myDirectExchange";
                string routeKey     = "xxxx";

                ///
                channel.ExchangeDeclare(exchangeName, ExchangeType.Direct, false, false);
                //声明一个队列
                var queueDeclareOk = channel.QueueDeclare("myQueue", false, false, false);

                channel.QueueBind("myQueue", exchangeName, routeKey, null);

                // 定义发送内容
                string input = JsonConvert.SerializeObject(data);

                var sendBytes = Encoding.UTF8.GetBytes(input);

                channel.BasicPublish(exchangeName, routeKey, null, sendBytes);
            }

            return(new JsonResult(new MQResult {
                Message = "Post Info Successed"
            }));
        }
 public IActionResult PostFanoutMsg([FromBody] MQMsg data)
 {
     return(null);
 }