/// <summary>
 /// 启动订阅
 /// </summary>
 /// <param name="serviceInstanceCtor">core 传入服务实例化委托</param>
 public void StartSubscribe(Func <Type, object> serviceInstanceCtor = null)
 {
     //var queueConfig = QueueConfig.GetConfig();
     foreach (var ed in eventRegister.Values)
     {
         var queue = QueueFactory.GetQueueClient(queueConfig, ed);
         ed.IQueue = queue;
         ed.ServiceInstanceCtor = serviceInstanceCtor;//core 传入服务实例化委托
         if (ed.IsCopy)
         {
             ed.StartPublishThread();
         }
         if (ed.IsAsync)
         {
             queue.SubscribeAsync(ed);
         }
         else
         {
             queue.Subscribe(ed);
         }
     }
 }
        /// <summary>
        /// 手动指定订阅
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="attr"></param>
        /// <param name="func"></param>
        public void StartSubscribe <T>(SubscribeAttribute attr, Action <T> func)
        {
            var ed = CreateEventDeclare <T>(attr, (i, b) =>
            {
                func((T)b.First());
                return(null);
            });
            var queue = QueueFactory.GetQueueClient(queueConfig, ed);

            ed.IQueue = queue;
            if (ed.IsCopy)
            {
                ed.StartPublishThread();
            }
            if (ed.IsAsync)
            {
                queue.SubscribeAsync(ed);
            }
            else
            {
                queue.Subscribe(ed);
            }
        }
Beispiel #3
0
 public Publisher(QueueConfig _queueConfig)
 {
     queue = QueueFactory.CreateClient(_queueConfig, false);
 }
Beispiel #4
0
 public Publisher(Microsoft.Extensions.Options.IOptions <QueueConfig> options)
 {
     queue = QueueFactory.CreateClient(options.Value, false);
 }
 public void StopSubscribe()
 {
     QueueFactory.DisposeAll();
 }