コード例 #1
0
 /// <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);
     }));
 }
コード例 #2
0
 /// <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);
     }));
 }
コード例 #3
0
 /// <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;
     }));
 }
コード例 #4
0
 /// <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);
     }));
 }
コード例 #5
0
 /// <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));
 }
コード例 #6
0
 /// <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>(""));
 }
コード例 #7
0
 /// <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));
 }
コード例 #8
0
 /// <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));
 }