示例#1
0
 private void RunMessageHandler(int actorId, IActor actor, Message message)
 {
     try
     {
         actor.OnMessage(message.Code, _runtime, actorId, message);
     }
     catch (Exception ex)
     {
         _logger.Error("Exception in actor OnMessage", ex);
     }
 }
 private void RunMessageHandler(Parcel parcel)
 {
     try
     {
         parcel.Actor.OnMessage(parcel.Message.Code, _runtime, parcel.ActorId, parcel.Message);
     }
     catch (Exception ex)
     {
         _logger.Error("Exception in actor OnMessage", ex);
         IActor newActor = _errorHandler.OnError(_runtime, parcel.ActorId, parcel.Actor, ex);
         if (newActor != null)
         {
             _logger.Info(String.Format("Replacing actor {0}, type: {1}", parcel.ActorId, newActor.GetType().Name));
             ReplaceActor(parcel.ActorId, newActor);
         }
     }
 }
 private void RunMessageHandler(Message message)
 {
     try
     {
         _actor.OnMessage(_runtime, _actorId, message);
     }
     catch (Exception ex)
     {
         _logger.Error("Exception in actor OnMessage", ex);
         IActor newActor = _errorHandler.OnError(_runtime, _actorId, _actor, ex);
         if (newActor != null)
         {
             _logger.Info(String.Format("Replacing actor {0}, type: {1}", _actorId, newActor.GetType().Name));
             _actor = newActor;
         }
     }
 }
示例#4
0
        public int StartVoidCall(Func <Task> method, int callerId)
        {
            int  callId   = _data.RegisterCall(callerId);
            Task mainTask = method();

            mainTask.ContinueWith((t) =>
            {
                if (t.IsFaulted)
                {
                    _logger.Error(String.Format("Error. Caller id: {0}, call id: {1}.", callerId, callId), t.Exception);
                    SendResult(callerId, callId, CallResult.Error, t.Exception, 0);
                }
                else if (t.IsCanceled)
                {
                    _logger.Info(String.Format("Cancelled. Caller id: {0}, call id: {1}.", callerId, callId));
                    SendResult(callerId, callId, CallResult.Cancelled, null, 0);
                }
                else
                {
                    SendResult(callerId, callId, CallResult.Completed, null, 0);
                }
            }, TaskContinuationOptions.AttachedToParent);
            return(callId);
        }