示例#1
0
    /// <summary>
    /// Close and stop any active replay. Will remove the replay destination from the subscription.
    /// This operation Will NOT remove the live destination if it has been added so it can be used for live consumption.
    /// </summary>
    public void Dispose()
    {
        State state = this.state;

        if (State.CLOSED != state)
        {
            if (!archive.Ctx().AeronClient().IsClosed)
            {
                if (State.MERGED != state)
                {
                    subscription.AsyncRemoveDestination(replayDestination);
                }

                if (isReplayActive && archive.Proxy().Pub().IsConnected)
                {
                    StopReplay();
                }
            }

            SetState(State.CLOSED);
        }
    }
示例#2
0
        private int AwaitInitialRecordingPosition()
        {
            int workCount = 0;

            if (NULL_VALUE == activeCorrelationId)
            {
                long correlationId = archive.Ctx().AeronClient().NextCorrelationId();

                if (archive.Proxy().GetRecordingPosition(recordingId, correlationId, archive.ControlSessionId()))
                {
                    activeCorrelationId = correlationId;
                    workCount          += 1;
                }
            }
            else if (PollForResponse(archive, activeCorrelationId))
            {
                nextTargetPosition = PolledRelevantId(archive);
                if (AeronArchive.NULL_POSITION == nextTargetPosition)
                {
                    var correlationId = archive.Ctx().AeronClient().NextCorrelationId();

                    if (archive.Proxy().GetStopPosition(recordingId, correlationId, archive.ControlSessionId()))
                    {
                        activeCorrelationId = correlationId;
                        workCount          += 1;
                    }
                }
                else
                {
                    initialMaxPosition  = nextTargetPosition;
                    activeCorrelationId = NULL_VALUE;
                    SetState(State.AWAIT_REPLAY);
                }

                workCount += 1;
            }

            return(workCount);
        }