EventDeclare CreateEventDeclare(SubscribeAttribute attr, MethodInfo method) { var key = attr?.Name; var func = Core.DynamicMethodHelper.CreateMethodInvoker(method); var args1 = method.GetParameters().FirstOrDefault(); if (args1 == null) { throw new Exception("至少一个参数"); } if (string.IsNullOrEmpty(key)) { key = args1.ParameterType.Name; } var isArry = typeof(System.Collections.IEnumerable).IsAssignableFrom(args1.ParameterType); var isAsync = method.ReturnType == typeof(Task); var ed = new EventDeclare() { EventDataType = args1.ParameterType, Name = key, Method = method, MethodInvoke = func, IsAsync = isAsync, IsArray = isArry, ListTake = attr.ListTake, QueueName = attr.QueueName, ThreadSleepSecond = attr.ThreadSleepSecond }; return(ed); }
public static AbsQueue GetQueueClient(QueueConfig config, EventDeclare eventDeclare) { var _queueName = config.QueueName; var key = $"CRL_{_queueName}_{eventDeclare.IsAsync}"; var a = clients.TryGetValue(key, out AbsQueue client); if (!a) { client = CreateClient(config, eventDeclare.IsAsync); clients.TryAdd(key, client); } return(client); }