acknowledge method

Future<void> acknowledge({
  1. required Iterable<String> ackIds,
  2. int retries = 5,
  3. required String subscription,
})

Acknowledges the messages associated with the ackIds. The Pub/Sub system can remove the relevant messages from the subscription. Acknowledging a message whose ack deadline has expired may succeed, but such a message may be redelivered later. Acknowledging a message more than once will not result in an error.

The subscription name can be just the simple name or it can be the fully quantified name in the format: projects/{project}/subscriptions/{subscription}.

Implementation

Future<void> acknowledge({
  required Iterable<String> ackIds,
  int retries = 5,
  required String subscription,
}) async {
  assert(_initialized);
  assert(ackIds.isNotEmpty);
  _logger.fine('[acknowledge]: start -- [$subscription]');

  await _execute(
    executor: () async => _pubsubApi.projects.subscriptions.acknowledge(
      AcknowledgeRequest(
        ackIds: ackIds.toList(),
      ),
      subscription.startsWith('projects/')
          ? subscription
          : 'projects/$_projectId/subscriptions/$subscription',
    ),
    retries: retries,
  );
  _logger.fine('[acknowledge]: complete -- [$subscription]');
}