/// <summary> /// 添加接收消息处理事件 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="builder"></param> /// <param name="queue"></param> /// <param name="onMessage"></param> /// <returns></returns> public static IEasyNetQConsumerBuilder AddReceiver <T>(this IEasyNetQConsumerBuilder builder, string queue, Func <T, Task> onMessage) where T : class { return(builder.AddReceiver <T>(queue, async(_, t) => { await onMessage?.Invoke(t); })); }
/// <summary> /// 添加接收消息处理事件 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="builder"></param> /// <param name="queue"></param> /// <param name="onMessage"></param> /// <returns></returns> public static IEasyNetQConsumerBuilder AddReceiver <T>(this IEasyNetQConsumerBuilder builder, string queue, Action <T> onMessage) where T : class { return(builder.AddReceiver <T>(queue, (_, t) => { onMessage?.Invoke(t); })); }
/// <summary> /// 添加接收消息处理事件 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="builder"></param> /// <param name="queue"></param> /// <param name="onMessage"></param> /// <returns></returns> public static IEasyNetQConsumerBuilder AddReceiver <T>(this IEasyNetQConsumerBuilder builder, string queue, Action <IServiceProvider, T> onMessage) where T : class { return(builder.AddReceiver <T>(queue, async(s, t) => { onMessage?.Invoke(s, t); await Task.CompletedTask; })); }
/// <summary> /// 添加接收消息处理事件 /// </summary> /// <typeparam name="T"></typeparam> /// <typeparam name="TReceiver"></typeparam> /// <param name="builder"></param> /// <param name="queue"></param> /// <returns></returns> public static IEasyNetQConsumerBuilder AddReceiver <T, TReceiver>(this IEasyNetQConsumerBuilder builder, string queue) where T : class where TReceiver : class, IEasyNetQReceiver <T> { builder.Services.AddTransient <TReceiver>(); return(builder.AddReceiver <T>(queue, async(serviceProvicer, t) => { var receiver = serviceProvicer.GetRequiredService <TReceiver>(); await receiver.ReceiveAsync(t); })); }
/// <summary> /// 添加接收消息处理事件 /// </summary> /// <param name="builder"></param> /// <param name="receiverType"></param> /// <returns></returns> public static IEasyNetQConsumerBuilder AddReceiver(this IEasyNetQConsumerBuilder builder, Type receiverType) { return(builder.AddReceiver("", receiverType)); }
/// <summary> /// 添加接收消息处理事件 /// </summary> /// <typeparam name="T"></typeparam> /// <typeparam name="TReceiver"></typeparam> /// <param name="builder"></param> /// <returns></returns> public static IEasyNetQConsumerBuilder AddReceiver <T, TReceiver>(this IEasyNetQConsumerBuilder builder) where T : class where TReceiver : class, IEasyNetQReceiver <T> { return(builder.AddReceiver <T, TReceiver>("")); }
/// <summary> /// 添加接收消息处理事件 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="builder"></param> /// <param name="onMessage"></param> /// <returns></returns> public static IEasyNetQConsumerBuilder AddReceiver <T>(this IEasyNetQConsumerBuilder builder, Func <IServiceProvider, T, Task> onMessage) where T : class { return(builder.AddReceiver("", onMessage)); }
/// <summary> /// 添加接收消息处理事件 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="builder"></param> /// <param name="onMessage"></param> /// <returns></returns> public static IEasyNetQConsumerBuilder AddReceiver <T>(this IEasyNetQConsumerBuilder builder, Action <T> onMessage) where T : class { return(builder.AddReceiver <T>("", onMessage)); }