Partilhar via


Container.GetChangeFeedIterator<T> Método

Definição

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

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

Parâmetros de tipo

T

Parâmetros

changeFeedStartFrom
ChangeFeedStartFrom

De onde iniciar o feed de alteração.

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 passar pelo Feed de Alterações.

Exemplos

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

FeedIterator<MyItem> feedIterator = this.Container.GetChangeFeedIterator<MyItem>(
    ChangeFeedStartFrom.Beginning(),
    ChangeFeedMode.Incremental,
    options);

    while (feedIterator.HasMoreResults)
    {
        FeedResponse<MyItem> response = await feedIterator.ReadNextAsync();

        if (response.StatusCode == NotModified) 
        {
            // No new changes
            // Capture response.ContinuationToken and break or sleep for some time
        }
        else 
        {
            foreach (var item in response)
            {
                Console.WriteLine(item);
            }
        }
    }

Aplica-se a

Confira também