public Task ReleaseLease(DedupeClaim instance)
    {
        var previous = (DedupeClaimImp)instance;
        var claim    = previous;

        claim.Revision++;
        claim.LeaseExpiration = DateTime.MinValue;
        if (!Items.TryUpdate(claim.MessageId, claim, previous))
        {
            throw new Exception($"Lease for {claim.MessageId} taken by other incoming message, possible more than once execution of message.");
        }

        return(Task.FromResult(0));
    }
    public Task CompleteLease(DedupeClaim instance)
    {
        var previous = (DedupeClaimImp)instance;
        var claim    = (DedupeClaimImp)instance;

        claim.IsProcessed = true;
        claim.Revision++;
        claim.Timestamp = DateTime.UtcNow;
        if (!Items.TryUpdate(claim.MessageId, claim, previous))
        {
            throw new Exception("Lease taken by other incoming message. Possible cause is processing duration exceeds lease duration. Possibly more than once execution of message id.");
        }
        return(Task.FromResult(0));
    }
Esempio n. 3
0
    public async Task ReleaseLease(DedupeClaim instance)
    {
        var entity = (DedupeEntity)instance;

        entity.LeaseExpiration = DateTime.MinValue;

        var update = TableOperation.Replace(entity);

        try
        {
            await Table.ExecuteAsync(update); // Don't need to do anything with the result, message processed again
        }
        catch (StorageException ex)
        {
            if (ex.RequestInformation.ExtendedErrorInformation.ErrorCode == TableErrorCodeStrings.UpdateConditionNotSatisfied)
            {
                throw new Exception($"Lease for {entity.PartitionKey} taken by other incoming message, possible more than once execution of message.");
            }
        }
    }
Esempio n. 4
0
    public async Task CompleteLease(DedupeClaim instance)
    {
        var entity = (DedupeEntity)instance;

        entity.IsProcessed = true;

        var update = TableOperation.Replace(entity);

        try
        {
            await Table.ExecuteAsync(update); // Don't need to do anything with the result, message processed again
        }
        catch (StorageException ex)
        {
            if (ex.RequestInformation.HttpStatusMessage == TableErrorCodeStrings.UpdateConditionNotSatisfied)
            {
                throw new Exception("Lease taken by other incoming message. Possible cause is processing duration exceeds lease duration. Possibly more than once execution of message id.");
            }
        }
    }