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); }
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); }
public RabbitMQService(RabbitPubAttribute rabbitMQInfo) => this.publisher = rabbitMQInfo;
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)); }
public static async Task Publish <T>(this RabbitPubAttribute rabbitMQInfo, T data, string key) { await Publish(data, rabbitMQInfo.Exchange, rabbitMQInfo.GetQueue(key)); }
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))); }
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)); }