예제 #1
0
        public IAOPResult PushToMainQueue(EventMessageHeader header)
        {
            var message = header.Message; header.Message = null;

            this.Redis.Set(this.RedisDb, this.MessagePrefix + message.MessageGuid, message.SerializeToBytes());
            this.Redis.Set(this.RedisDb, this.MessageHeaderPrefix + message.MessageGuid, header.SerializeToBytes());
            var messageKey = header.GetMessageKey();

            this.Redis.LeftPush(this.RedisDb, this.PublishQueueName, header.GetMessageKey());
            this.Redis.Publish(this.NotifyQueueName, messageKey);
            return(AOPResult.Success());
        }
예제 #2
0
 public IAOPResult PushToSubscribeQueue(string queueName, EventMessageHeader header)          //新消息分发到各个订阅队列
 {
     using (var storage = this.GetStorage(this.MainStorageName)) {
         storage.Pipeline(s => {
             s.LeftPush(this.SubscriberQueuePrefix + queueName, header.GetMessageKey()); //把消息ID入列
             s.Increment(this.MessageRefPrefix + header.MessageGuid);                    //增加消息的引用数
         });
     }
     return(AOPResult.Success());
 }
예제 #3
0
 //新消息分发到各个订阅队列
 public IAOPResult PushToSubscribeQueues(EventMessageHeader header, string[] queueNames)
 {
     if (queueNames != null && queueNames.Length > 0)
     {
         using (var storage = this.GetStorage(this.MainStorageName)) {
             storage.Pipeline(s => {
                 foreach (var queueName in queueNames)
                 {
                     s.LeftPush(this.SubscriberQueuePrefix + queueName, header.GetMessageKey());          //把消息ID入列
                     s.Increment(this.MessageRefPrefix + header.MessageGuid);                             //增加消息的引用数
                 }
                 //保存此消息分发到哪些订阅队列,以供排查分析
                 s.Set(this.MessageDispatchPrefix + header.MessageGuid, this.Encoding.GetBytes(string.Join(",", queueNames)));
             });
         }
     }
     return(AOPResult.Success());
 }
예제 #4
0
        public IAOPResult PushToMainQueue(EventMessageHeader header)          //新消息发布到主队列
        {
            var message = header.Message; header.Message = null;

            using (var storage = this.GetStorage(this.MainStorageName)) {
                storage.Pipeline(s => {
                    //保存消息主体和消息头
                    s.MultiSet(new Dictionary <string, byte[]> {
                        { this.MessagePrefix + message.MessageGuid, this.Serializer.Serialize(message, null) },
                        { this.MessageHeaderPrefix + message.MessageGuid, this.Serializer.Serialize(header, null) },
                    });
                    var messageKey = header.GetMessageKey();
                    s.LeftPush(this.PublishQueueName, messageKey);                  //把消息ID入列到消息队列里
                    s.Publish(this.NotifyQueueName, messageKey);                    //通知分发器有新消息过来了
                });
            }
            return(AOPResult.Success());
        }
예제 #5
0
 public IAOPResult PushToSubscribeQueue(string queueName, EventMessageHeader header)
 {
     this.Redis.LeftPush(this.RedisDb, this.SubscriberQueuePrefix + queueName, header.GetMessageKey());
     this.Redis.Increment(this.RedisDb, this.MessageRefPrefix + header.MessageGuid);
     return(AOPResult.Success());
 }