Esempio n. 1
0
 /// <summary>
 /// 添加订阅消息处理事件
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="builder"></param>
 /// <param name="subscriptionId"></param>
 /// <param name="onMessage"></param>
 /// <returns></returns>
 public static IEasyNetQConsumerBuilder AddSubscriber <T>(this IEasyNetQConsumerBuilder builder, string subscriptionId, Action <IServiceProvider, T> onMessage) where T : class
 {
     return(builder.AddSubscriber <T>(subscriptionId, async(s, t) =>
     {
         onMessage?.Invoke(s, t);
         await Task.CompletedTask;
     }));
 }
Esempio n. 2
0
 /// <summary>
 /// 添加订阅消息处理事件
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <typeparam name="TSubscriber"></typeparam>
 /// <param name="builder"></param>
 /// <param name="subscriptionId"></param>
 /// <returns></returns>
 public static IEasyNetQConsumerBuilder AddSubscriber <T, TSubscriber>(this IEasyNetQConsumerBuilder builder, string subscriptionId)
     where T : class
     where TSubscriber : class, IEasyNetQSubscriber <T>
 {
     builder.Services.AddTransient <TSubscriber>();
     builder.AddSubscriber <T>(subscriptionId, async(serviceProvider, t) =>
     {
         var subscriber = serviceProvider.GetRequiredService <TSubscriber>();
         await subscriber.SubscribeAsync(t);
     });
     return(builder);
 }
Esempio n. 3
0
 /// <summary>
 /// 添加订阅消息处理事件
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="subscriberType"></param>
 /// <returns></returns>
 public static IEasyNetQConsumerBuilder AddSubscriber(this IEasyNetQConsumerBuilder builder, Type subscriberType)
 {
     return(builder.AddSubscriber("", subscriberType));
 }
Esempio n. 4
0
 /// <summary>
 /// 添加订阅消息处理事件
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <typeparam name="TSubscriber"></typeparam>
 /// <param name="builder"></param>
 /// <returns></returns>
 public static IEasyNetQConsumerBuilder AddSubscriber <T, TSubscriber>(this IEasyNetQConsumerBuilder builder)
     where T : class
     where TSubscriber : class, IEasyNetQSubscriber <T>
 {
     return(builder.AddSubscriber <T, TSubscriber>(""));
 }
Esempio n. 5
0
 /// <summary>
 /// 添加订阅消息处理事件
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="builder"></param>
 /// <param name="subscriptionId"></param>
 /// <param name="onMessage"></param>
 /// <returns></returns>
 public static IEasyNetQConsumerBuilder AddSubscriber <T>(this IEasyNetQConsumerBuilder builder, string subscriptionId, Func <T, Task> onMessage) where T : class
 {
     return(builder.AddSubscriber <T>(subscriptionId, (_, t) => onMessage?.Invoke(t)));
 }
Esempio n. 6
0
 /// <summary>
 /// 添加订阅消息处理事件
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="builder"></param>
 /// <param name="onMessage"></param>
 /// <returns></returns>
 public static IEasyNetQConsumerBuilder AddSubscriber <T>(this IEasyNetQConsumerBuilder builder, Func <IServiceProvider, T, Task> onMessage) where T : class
 {
     return(builder.AddSubscriber("", onMessage));
 }
Esempio n. 7
0
 /// <summary>
 /// 添加订阅消息处理事件
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="builder"></param>
 /// <param name="onMessage"></param>
 /// <returns></returns>
 public static IEasyNetQConsumerBuilder AddSubscriber <T>(this IEasyNetQConsumerBuilder builder, Action <T> onMessage) where T : class
 {
     return(builder.AddSubscriber("", onMessage));
 }