Exemple #1
0
        /// <summary>
        /// 接收
        /// </summary>
        public void TestRabbit()
        {
            //获取所有的当前brokerName下的某个Exchange下的所有消费者配置名称
            List <string> consumerData = ClientConfiguration.Instance.GetConsumerDatas(YemRabbitMqConst.Test_EXCHANGE_NAME);

            foreach (var consummerkey in consumerData)
            {
                RabbitMqProvider.Receive(consummerkey, body =>
                {
                    try
                    {
                        TestRabbitModel test = JsonConvert.DeserializeObject <TestRabbitModel>(body);
                        Console.WriteLine(test.ToJson());
                        return(true);
                    }
                    catch (Exception)
                    {
                        return(true);
                    }
                });
            }
            Console.ReadKey();
        }
Exemple #2
0
 /// <summary>
 /// 发送
 /// </summary>
 /// <param name="input"></param>
 /// <returns></returns>
 public async Task <bool> SendTestAsync(TestRabbitModel input)
 {
     return(await Task.FromResult(RabbitMqProvider.Send(YemRabbitMqConst.Test_QUEUE_NAME_PRODUCER_KEY, input)));
 }