Beispiel #1
0
        public override Task <Error> Cancel(MessageStatusRequest request, ServerCallContext context)
        {
            var resp = new Error();

            if (string.IsNullOrEmpty(request.MessageId))
            {
                resp.ErrCode = -1;
                resp.ErrMsg  = "Wrong message id";
            }
            else
            {
                var messageStatus = new MessageStatus(_redis, request.MessageId);
                if (messageStatus.GetInfo().Time > Util.GetTimestamp())
                {
                    BackgroundJob.Enqueue <MessageStatus>(x => x.CancelJob(messageStatus.GetMessageId(), null));
                }
                else
                {
                    resp.ErrCode = 9999;
                    resp.ErrMsg  = "Can't Cancel, already processed!";
                }
            }
            return(Task.FromResult(resp));
        }