Partilhar via


Container.GetChangeFeedStreamIterator Método

Definição

Esse método cria um iterador para consumir um Feed de Alterações.

public abstract Microsoft.Azure.Cosmos.FeedIterator GetChangeFeedStreamIterator (Microsoft.Azure.Cosmos.ChangeFeedStartFrom changeFeedStartFrom, Microsoft.Azure.Cosmos.ChangeFeedMode changeFeedMode, Microsoft.Azure.Cosmos.ChangeFeedRequestOptions changeFeedRequestOptions = default);
abstract member GetChangeFeedStreamIterator : Microsoft.Azure.Cosmos.ChangeFeedStartFrom * Microsoft.Azure.Cosmos.ChangeFeedMode * Microsoft.Azure.Cosmos.ChangeFeedRequestOptions -> Microsoft.Azure.Cosmos.FeedIterator
Public MustOverride Function GetChangeFeedStreamIterator (changeFeedStartFrom As ChangeFeedStartFrom, changeFeedMode As ChangeFeedMode, Optional changeFeedRequestOptions As ChangeFeedRequestOptions = Nothing) As FeedIterator

Parâmetros

changeFeedStartFrom
ChangeFeedStartFrom

De onde iniciar o changefeed.

changeFeedMode
ChangeFeedMode

Define o modo no qual consumir o feed de alterações.

changeFeedRequestOptions
ChangeFeedRequestOptions

(Opcional) As opções para o consumo do Feed de Alterações.

Retornos

Um iterador para percorrer o Feed de Alterações.

Exemplos

ChangeFeedRequestOptions options = new ChangeFeedRequestOptions()
{
    PageSizeHint = 10,
}

FeedIterator feedIterator = this.Container.GetChangeFeedStreamIterator(
    ChangeFeedStartFrom.Beginning(),
    ChangeFeedMode.Incremental,
    options);

while (feedIterator.HasMoreResults)
{
    using (ResponseMessage response = await feedIterator.ReadNextAsync())
    {
        if (response.StatusCode == NotModified) 
        {
            // No new changes
            // Capture response.ContinuationToken and break or sleep for some time
        }
        else 
        {
            using (StreamReader sr = new StreamReader(response.Content))
            using (JsonTextReader jtr = new JsonTextReader(sr))
            {
                JObject result = JObject.Load(jtr);
            }
        }
    }
}

Aplica-se a

Confira também