Partilhar via


EventGridClient.AcknowledgeCloudEvents Method

Definition

Overloads

AcknowledgeCloudEvents(String, String, RequestContent, RequestContext)

[Protocol Method] Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully acknowledged lockTokens, along with other failed lockTokens with their corresponding error information. Successfully acknowledged events will no longer be available to any consumer.

AcknowledgeCloudEvents(String, String, AcknowledgeOptions, CancellationToken)

Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully acknowledged lockTokens, along with other failed lockTokens with their corresponding error information. Successfully acknowledged events will no longer be available to any consumer.

AcknowledgeCloudEvents(String, String, RequestContent, RequestContext)

Source:
EventGridClient.cs

[Protocol Method] Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully acknowledged lockTokens, along with other failed lockTokens with their corresponding error information. Successfully acknowledged events will no longer be available to any consumer.

public virtual Azure.Response AcknowledgeCloudEvents (string topicName, string eventSubscriptionName, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member AcknowledgeCloudEvents : string * string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.AcknowledgeCloudEvents : string * string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function AcknowledgeCloudEvents (topicName As String, eventSubscriptionName As String, content As RequestContent, Optional context As RequestContext = Nothing) As Response

Parameters

topicName
String

Topic Name.

eventSubscriptionName
String

Event Subscription Name.

content
RequestContent

The content to send as the body of the request.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service.

Exceptions

topicName, eventSubscriptionName or content is null.

topicName or eventSubscriptionName is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

This sample shows how to call AcknowledgeCloudEvents and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
EventGridClient client = new EventGridClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    lockTokens = new object[]
    {
        "<lockTokens>"
    },
});
Response response = client.AcknowledgeCloudEvents("<topicName>", "<eventSubscriptionName>", content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());

This sample shows how to call AcknowledgeCloudEvents with all parameters and request content and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
EventGridClient client = new EventGridClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    lockTokens = new object[]
    {
        "<lockTokens>"
    },
});
Response response = client.AcknowledgeCloudEvents("<topicName>", "<eventSubscriptionName>", content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("lockToken").ToString());
Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("message").ToString());
Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("target").ToString());
Console.WriteLine(result.GetProperty("failedLockTokens")[0].GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("succeededLockTokens")[0].ToString());

Applies to

AcknowledgeCloudEvents(String, String, AcknowledgeOptions, CancellationToken)

Source:
EventGridClient.cs

Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if the request is successfully accepted. The response body will include the set of successfully acknowledged lockTokens, along with other failed lockTokens with their corresponding error information. Successfully acknowledged events will no longer be available to any consumer.

public virtual Azure.Response<Azure.Messaging.EventGrid.Namespaces.AcknowledgeResult> AcknowledgeCloudEvents (string topicName, string eventSubscriptionName, Azure.Messaging.EventGrid.Namespaces.AcknowledgeOptions acknowledgeOptions, System.Threading.CancellationToken cancellationToken = default);
abstract member AcknowledgeCloudEvents : string * string * Azure.Messaging.EventGrid.Namespaces.AcknowledgeOptions * System.Threading.CancellationToken -> Azure.Response<Azure.Messaging.EventGrid.Namespaces.AcknowledgeResult>
override this.AcknowledgeCloudEvents : string * string * Azure.Messaging.EventGrid.Namespaces.AcknowledgeOptions * System.Threading.CancellationToken -> Azure.Response<Azure.Messaging.EventGrid.Namespaces.AcknowledgeResult>
Public Overridable Function AcknowledgeCloudEvents (topicName As String, eventSubscriptionName As String, acknowledgeOptions As AcknowledgeOptions, Optional cancellationToken As CancellationToken = Nothing) As Response(Of AcknowledgeResult)

Parameters

topicName
String

Topic Name.

eventSubscriptionName
String

Event Subscription Name.

acknowledgeOptions
AcknowledgeOptions

AcknowledgeOptions.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

topicName, eventSubscriptionName or acknowledgeOptions is null.

topicName or eventSubscriptionName is an empty string, and was expected to be non-empty.

Examples

This sample shows how to call AcknowledgeCloudEvents.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
EventGridClient client = new EventGridClient(endpoint, credential);

AcknowledgeOptions acknowledgeOptions = new AcknowledgeOptions(new string[] { "<lockTokens>" });
Response<AcknowledgeResult> response = client.AcknowledgeCloudEvents("<topicName>", "<eventSubscriptionName>", acknowledgeOptions);

This sample shows how to call AcknowledgeCloudEvents with all parameters.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
EventGridClient client = new EventGridClient(endpoint, credential);

AcknowledgeOptions acknowledgeOptions = new AcknowledgeOptions(new string[] { "<lockTokens>" });
Response<AcknowledgeResult> response = client.AcknowledgeCloudEvents("<topicName>", "<eventSubscriptionName>", acknowledgeOptions);

Applies to