/// <summary> /// Renews the lock on the session specified by the <see cref="SessionId"/>. The lock will be renewed based on the setting specified on the entity. /// </summary> /// /// <param name="cancellationToken">An optional <see cref="CancellationToken"/> instance to signal the request to cancel the operation.</param> /// /// <remarks> /// <para> /// When you get session receiver, the session is locked for this receiver by the service for a duration as specified during the Queue/Subscription creation. /// If processing of the session requires longer than this duration, the session-lock needs to be renewed. /// For each renewal, it resets the time the session is locked by the LockDuration set on the Entity. /// </para> /// <para> /// Renewal of session renews all the messages in the session as well. Each individual message need not be renewed. /// </para> /// </remarks> public virtual async Task RenewSessionLockAsync(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested <TaskCanceledException>(); ServiceBusEventSource.Log.RenewSessionLockStart(_identifier, SessionId); try { await _receiver.RenewSessionLockAsync(cancellationToken).ConfigureAwait(false); } catch (Exception exception) { ServiceBusEventSource.Log.RenewSessionLockException(_identifier, exception); throw; } cancellationToken.ThrowIfCancellationRequested <TaskCanceledException>(); ServiceBusEventSource.Log.RenewSessionLockComplete(_identifier); }
/// <summary> /// /// </summary> public virtual async Task RenewSessionLockAsync(CancellationToken cancellationToken = default) => LockedUntilUtc = await _receiver.RenewSessionLockAsync(cancellationToken).ConfigureAwait(false);