Exemple #1
0
        protected void Post(T message)
        {
            var msg = new BeeMessage <T>(message);

            _mailbox.Post(msg);
            OnMessageEnter();
        }
Exemple #2
0
        private async Task Handle(BeeMessage <T> msg)
        {
            try
            {
                await HandleMessage(msg.Message);

                OnMessageExit();
            }
            catch (Exception e)
            {
                msg.OnError(e);
                var result = await HandleError(msg, e);

                switch (result)
                {
                case OkHandleResult x:
                    OnMessageExit();
                    break;

                case NeedRetry x:
                    _mailbox.Post(msg);
                    break;

                case NeedRetryWithDelay x:
                    var _ = Task.Delay(x.Delay).ContinueWith(s => _mailbox.Post(msg));
                    break;


                default: throw new NotImplementedException("Not implemented handler for result");
                }
            }
        }
Exemple #3
0
 protected abstract Task <HandleResult> HandleError(BeeMessage <T> msg, Exception ex);