|
123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using EasyNetQ;
- using HKLib.RabbitMQ.Config;
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace HKLib.RabbitMQ.Subscriber
- {
- public class ServiceQueryExcute
- {
- public static ServiceQueryExcute QueryExcute => new Lazy<ServiceQueryExcute>().Value;
- public void ExtuteMQ<TImpl,T>(string Key,MQEnum Type) where TImpl : IAccept, new()
- {
- Task.Run(() =>
- {
- AcceptEntity accept = new AcceptEntity();
- if (Type == MQEnum.Push)
- {
- accept.SendType = MQEnum.Push;
- accept.ExchangeName = "Message.Direct";
- accept.QueeName = "Meesage.DirectQuene";
- accept.RouteName = Key;
- }
- else if (Type == MQEnum.Sub)
- {
- accept.SendType = MQEnum.Sub;
- accept.ExchangeName = "Message.Fanout";
- accept.QueeName = "Meesage.FanoutQuene";
- }
- else
- {
- accept.SendType = MQEnum.Top;
- accept.ExchangeName = "Message.Topic";
- accept.QueeName = "Meesage.FanoutQuene";
- accept.RouteName = Key;
- }
- MQFactory.Subscriber<TImpl, T>(accept);
- });
- }
- }
- }
|