Ejemplo n.º 1
0
 private void PersistOffset(PullRequest pullRequest)
 {
     try
     {
         var consumedMinQueueOffset = pullRequest.ProcessQueue.GetConsumedMinQueueOffset();
         if (consumedMinQueueOffset >= 0)
         {
             if (!pullRequest.ProcessQueue.TryUpdatePreviousConsumedMinQueueOffset(consumedMinQueueOffset))
             {
                 return;
             }
             if (Setting.MessageModel == MessageModel.BroadCasting)
             {
                 _localOffsetStore.PersistQueueOffset(GroupName, pullRequest.MessageQueue, consumedMinQueueOffset);
             }
             else if (Setting.MessageModel == MessageModel.Clustering)
             {
                 var request = new UpdateQueueOffsetRequest(GroupName, pullRequest.MessageQueue, consumedMinQueueOffset);
                 var remotingRequest = new RemotingRequest((int)RequestCode.UpdateQueueOffsetRequest, _binarySerializer.Serialize(request));
                 _remotingClient.InvokeOneway(remotingRequest, 10000);
                 _logger.DebugFormat("Sent new queue offset to broker. group:{0}, consumerId:{1}, topic:{2}, queueId:{3}, offset:{4}",
                     GroupName,
                     Id,
                     pullRequest.MessageQueue.Topic,
                     pullRequest.MessageQueue.QueueId,
                     consumedMinQueueOffset);
             }
         }
     }
     catch (Exception ex)
     {
         _logger.Error(string.Format("PersistOffset has exception, consumerId:{0}, group:{1}, topic:{2}, queueId:{3}", Id, GroupName, pullRequest.MessageQueue.Topic, pullRequest.MessageQueue.QueueId), ex);
     }
 }
Ejemplo n.º 2
0
        private void PersistOffset(PullRequest pullRequest)
        {
            try
            {
                var consumedQueueOffset = pullRequest.ProcessQueue.GetConsumedQueueOffset();
                if (consumedQueueOffset >= 0)
                {
                    if (!pullRequest.ProcessQueue.TryUpdatePreviousConsumedQueueOffset(consumedQueueOffset))
                    {
                        return;
                    }

                    var request = new UpdateQueueOffsetRequest(GroupName, pullRequest.MessageQueue, consumedQueueOffset);
                    var remotingRequest = new RemotingRequest((int)RequestCode.UpdateQueueOffsetRequest, _binarySerializer.Serialize(request));
                    _adminRemotingClient.InvokeOneway(remotingRequest);
                    if (_logger.IsDebugEnabled)
                    {
                        _logger.DebugFormat("Sent queue consume offset to broker. group: {0}, topic: {1}, queueId: {2}, offset: {3}",
                            GroupName,
                            pullRequest.MessageQueue.Topic,
                            pullRequest.MessageQueue.QueueId,
                            consumedQueueOffset);
                    }
                }
            }
            catch (Exception ex)
            {
                if (_remotingClient.IsConnected)
                {
                    _logger.Error(string.Format("PersistOffset has exception, group: {0}, topic: {1}, queueId: {2}", GroupName, pullRequest.MessageQueue.Topic, pullRequest.MessageQueue.QueueId), ex);
                }
            }
        }
Ejemplo n.º 3
0
 private void PersistOffset(PullRequest pullRequest)
 {
     try
     {
         if (Setting.MessageModel == MessageModel.BroadCasting)
         {
             ((ILocalOffsetStore)_offsetStore).PersistQueueOffset(GroupName, pullRequest.MessageQueue);
         }
         else if (Setting.MessageModel == MessageModel.Clustering)
         {
             var queueOffset = _offsetStore.GetQueueOffset(GroupName, pullRequest.MessageQueue);
             var request = new UpdateQueueOffsetRequest(GroupName, pullRequest.MessageQueue, queueOffset);
             var remotingRequest = new RemotingRequest((int)RequestCode.UpdateQueueOffsetRequest, _binarySerializer.Serialize(request));
             _remotingClient.InvokeOneway(remotingRequest, 10000);
         }
     }
     catch (Exception ex)
     {
         _logger.Error(string.Format("[{0}]: PersistOffset has exception.", Id), ex);
     }
 }