コード例 #1
0
ファイル: Eventsourced.cs プロジェクト: supadmins/akka.net
 public void Unstash()
 {
     _userStash.Unstash();
 }
コード例 #2
0
        internal override void UnhandledMessage(object message)
        {
            switch (message)
            {
            case WriteSuccess ws:
                if (writesInProgress.Contains(ws.CorrelationId) && ws.InstanceId == InstanceId)
                {
                    writeReplyHandling = true;
                    try
                    {
                        foreach (var e in ws.Events)
                        {
                            ReceiveEvent(e);
                            writeHandlers.First.Value(Try.Success(e.Payload));
                            writeHandlers.RemoveFirst();
                        }

                        if (StateSync)
                        {
                            writing = false;
                            messageStash.Unstash();
                        }
                    }
                    finally
                    {
                        writeReplyHandling = false;
                        writesInProgress   = writesInProgress.Remove(ws.CorrelationId);
                    }
                }
                break;

            case WriteFailure wf:
                if (writesInProgress.Contains(wf.CorrelationId) && wf.InstanceId == InstanceId)
                {
                    writeReplyHandling = true;
                    try
                    {
                        foreach (var e in wf.Events)
                        {
                            ReceiveEventInternal(e, wf.Cause);
                            writeHandlers.First.Value(Try.Failure <object>(wf.Cause));
                            writeHandlers.RemoveFirst();
                        }

                        if (StateSync)
                        {
                            writing = false;
                            messageStash.Unstash();
                        }
                    }
                    finally
                    {
                        writeReplyHandling = false;
                        writesInProgress   = writesInProgress.Remove(wf.CorrelationId);
                    }
                }
                break;

            case PersistOnEventRequest poer:
                if (poer.InstanceId == InstanceId)
                {
                    WriteOrDelay(() =>
                    {
                        writeHandlers.Clear();
                        writeRequests.Clear();
                        foreach (var invocation in poer.Invocations)
                        {
                            writeHandlers.AddLast(PersistOnEventActor.DefaultHandler);
                            writeRequests.Add(this.DurableEvent(invocation.Event, invocation.CustomDestinationAggregateIds, null, poer.PersistOnEventSequenceNr, poer.PersistOnEventId));
                        }
                    });
                }
                break;

            default:
                WriteOrDelay(() => base.UnhandledMessage(message));
                break;
            }
        }