Beispiel #1
0
        public async Task PublishMessage()
        {
            await _mq.SubscibeAsync <ClassGrade>(cg =>
            {
                this.WriteLine($"Test1_{nameof(ClassGrade)}:{cg.Id}");
            });

            await _mq.SubscibeAsync <Student>(s =>
            {
                this.WriteLine($"1:{nameof(Student)}:name={s.Name},sex={s.Sex},age={s.Age}");
            });

            await _mq.SubscibeAssemblyAsync();

            _mq.SubscibeAssembly()
            .SubscibeType <SudentHandle>();
            await _mq.SubscibeTypeAsync <SudentHandle>();

            Init();
            Thread.Sleep(5 * 1000);
        }
Beispiel #2
0
 /// <summary>
 /// 订阅<typeparamref name="THandler"/>的所有<seealso cref="IHandler{TMessage}"/>接口的实现
 /// </summary>
 /// <typeparam name="THandler"></typeparam>
 /// <param name="mq"></param>
 /// <returns></returns>
 public static Task <IMQ> SubscibeTypeAsync <THandler>(this IMQ mq) where THandler : IHandler
 {
     return(mq.SubscibeTypeAsync(typeof(THandler)));
 }