示例#1
0
        public RabbitPubAttribute GetAttribute(Type type)
        {
            var rabbitMQAttributes          = type.GetCustomAttributes(rabbitMQType, true);
            RabbitPubAttribute pubAttribute = null;

            if (rabbitMQAttributes.Length > 0)
            {
                pubAttribute = rabbitMQAttributes[0] as RabbitPubAttribute;
                if (string.IsNullOrEmpty(pubAttribute.Exchange))
                {
                    pubAttribute.Exchange = type.Namespace;
                }
                if (string.IsNullOrEmpty(pubAttribute.Queue))
                {
                    pubAttribute.Queue = type.Name;
                }
            }
            if (pubAttribute == null)
            {
                pubAttribute = new RabbitPubAttribute(type.Namespace, type.Name);
            }
            pubAttribute.Init(client);
            return(pubAttribute);
        }
示例#2
0
        public static RabbitPubAttribute GetRabbitMQAttr(Type type)
        {
            var rabbitMQAttributes    = type.GetCustomAttributes(rabbitMQType, true);
            RabbitPubAttribute mqAttr = null;

            if (rabbitMQAttributes.Length > 0)
            {
                mqAttr = rabbitMQAttributes[0] as RabbitPubAttribute;
                if (string.IsNullOrEmpty(mqAttr.Exchange))
                {
                    mqAttr.Exchange = type.Namespace;
                }
                if (string.IsNullOrEmpty(mqAttr.Queue))
                {
                    mqAttr.Queue = type.Name;
                }
            }
            if (mqAttr == null)
            {
                mqAttr = new RabbitPubAttribute(type.Namespace, type.Name);
            }
            mqAttr.Init();
            return(mqAttr);
        }
示例#3
0
 public RabbitMQService(RabbitPubAttribute rabbitMQInfo) => this.publisher = rabbitMQInfo;
示例#4
0
 public static async Task PublishByCmd <T>(this RabbitPubAttribute rabbitMQInfo, UInt16 cmd, T data, string key)
 {
     await PublishByCmd <T>(cmd, data, rabbitMQInfo.Exchange, rabbitMQInfo.GetQueue(key));
 }
示例#5
0
 public static async Task Publish <T>(this RabbitPubAttribute rabbitMQInfo, T data, string key)
 {
     await Publish(data, rabbitMQInfo.Exchange, rabbitMQInfo.GetQueue(key));
 }
示例#6
0
 public static Task PublishByCmd <T>(this RabbitPubAttribute rabbitMQInfo, UInt16 cmd, T data, string key)
 {
     return(RabbitMQClient.PublishByCmd <T>(cmd, data, rabbitMQInfo.Exchange, rabbitMQInfo.GetQueue(key)));
 }
示例#7
0
 public static Task PublishByCmd <T>(this RabbitPubAttribute rabbitMQInfo, UInt16 cmd, T data, string key, bool persistent = true)
 {
     return(rabbitMQInfo.Client.PublishByCmd <T>(cmd, data, rabbitMQInfo.Exchange, rabbitMQInfo.GetQueue(key), persistent));
 }