/// <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) { Argument.AssertNotClosed(IsDisposed, nameof(ServiceBusSessionReceiver)); cancellationToken.ThrowIfCancellationRequested <TaskCanceledException>(); ServiceBusEventSource.Log.RenewSessionLockStart(Identifier, SessionId); try { await InnerReceiver.RenewSessionLockAsync(cancellationToken).ConfigureAwait(false); } catch (Exception exception) { ServiceBusEventSource.Log.RenewSessionLockException(Identifier, exception); throw; } cancellationToken.ThrowIfCancellationRequested <TaskCanceledException>(); ServiceBusEventSource.Log.RenewSessionLockComplete(Identifier); }
/// <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) { Argument.AssertNotDisposed(IsClosed, nameof(ServiceBusSessionReceiver)); cancellationToken.ThrowIfCancellationRequested <TaskCanceledException>(); Logger.RenewSessionLockStart(Identifier, SessionId); using DiagnosticScope scope = ScopeFactory.CreateScope( DiagnosticProperty.RenewSessionLockActivityName, sessionId: SessionId); scope.Start(); try { await InnerReceiver.RenewSessionLockAsync(cancellationToken).ConfigureAwait(false); } catch (Exception exception) { Logger.RenewSessionLockException(Identifier, exception.ToString()); scope.Failed(exception); throw; } Logger.RenewSessionLockComplete(Identifier); }