deleteSubscription method

Future<void> deleteSubscription({
  1. int retries = 5,
  2. required String subscription,
})

Deletes an existing subscription. All messages retained in the subscription are immediately dropped. Calls to Pull after deletion will return NOT_FOUND. After a subscription is deleted, a new one may be created with the same name, but the new one has no association with the old subscription or its topic unless the same topic is specified.

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> deleteSubscription({
  int retries = 5,
  required String subscription,
}) async {
  assert(_initialized);
  _logger.fine('[deleteSubscription]: start -- [$subscription]');

  try {
    await _execute(
      executor: () async => await _pubsubApi.projects.subscriptions.delete(
        subscription.startsWith('projects/')
            ? subscription
            : 'projects/$_projectId/subscriptions/$subscription',
      ),
      retries: retries,
    );
  } finally {
    _logger.fine('[deleteSubscription]: complete -- [$subscription]');
  }
}