# MQShell **Repository Path**: KTwoQ/MQShell ## Basic Information - **Project Name**: MQShell - **Description**: No description available - **Primary Language**: C# - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2019-10-08 - **Last Updated**: 2022-01-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MQShell MQShell 介绍 **首先,这是一个消息队列快速创建消费者的外壳** MQShell 目的在于快速的使用接入某个消息队列,创建消费者,监听队列,目前本人用的是RabbitMQ,说实在的,我想的不多,就只是想偷个懒,用起来方便点,或许以后我不用RabbitMQ,改用云端消息队列也难说,当然,Rabbit MQ对于我来说,我并不熟,或许以后会熟悉 tips:后续补充,还是用cap吧,香的很,这个纯粹练手 MQShell 说明 1. IPublishClient.cs:就是一个发送消息的接口而已,目前就写了两个,关于RabbitMQ中众多方式中的两种 2. IRabbitMQConsumerApplication.cs :创建消费者的类,简直就是最核心的地方,当然也是最垃圾的地方 3. RabbitMQConfig.cs:就是几个相关的配置信息 4. SubscribeAttribute.cs:特性 5. StartupExtensions.cs:启动配置 #### 使用说明 1. 在Startup的ConfigureServices方法中添加MQShell服务 public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); //添加MQShell服务 services.AddRabbitMQ(x => { x.UserName = "guest"; x.Password = "guest"; x.HostName = "localhost"; x.SetAssemblyApplication(new List() { "TaskClient" });//消费者所在程序集 }); } 2. 在相对应的方法上加上特性 [Subscribe("队列名")] public class TestService { public void PrintEvent(string Name) { Console.WriteLine(Name); } [Subscribe("Test")] public bool StartTest(string msg) { Console.WriteLine($"收到订阅消息:{msg}"); return true; } [Subscribe("TestModel")] public bool StartTestTwo(TestModel test) { Console.WriteLine($"收到订阅消息:{JsonConvert.SerializeObject(test)}"); return true; } } 3. 没了