示例#1
0
 internal OutboxLockedJob(OutboxEnvelope envelope, Guid lockId, CancellationTokenSource?cts)
 {
     Envelope           = envelope;
     _cancellationToken = cts?.Token ?? CancellationToken.None;
     _cts   = cts;
     LockId = lockId;
 }
示例#2
0
        public override async Task <OutboxEnvelope> Add(OutboxEnvelope outboxEnvelope, CancellationToken cancellationToken)
        {
            await _graphClient.Cypher
            .Create($"(outbox:{nameof(Outbox)})")
            .Set("outbox = {outbox}").WithParam("outbox", outboxEnvelope)
            .ExecuteWithoutResultsAsync();

            return(outboxEnvelope);
        }
示例#3
0
        public override Task <OutboxEnvelope> Add(OutboxEnvelope outboxEnvelope, CancellationToken cancellationToken)
        {
            if (outboxEnvelope == null)
            {
                throw new ArgumentNullException(nameof(outboxEnvelope));
            }

            var entityEntry = _dbContext.Set <OutboxEnvelope>().Add(outboxEnvelope);

            return(Task.FromResult(entityEntry.Entity));
        }
示例#4
0
        public async Task <Guid> EnqueueAsync <T>(Guid correlationId, T message, CancellationToken cancellationToken) where T : IOutboxMessage
        {
            var assemblyQualifiedName = message.GetType().AssemblyQualifiedName;

            if (assemblyQualifiedName == null)
            {
                throw new InvalidOperationException("Can't resolve assemblyQualifiedName");
            }

            var outbox = new OutboxEnvelope(correlationId, assemblyQualifiedName, OutboxMessageStatus.New, _serializer.Serialize(message));
            await _outboxDataProvider.Add(outbox, cancellationToken).ConfigureAwait(false);

            return(correlationId);
        }
 public abstract Task <OutboxEnvelope> Add(OutboxEnvelope outboxEnvelope, CancellationToken cancellationToken);