public async Task <OutboxMessage> Get(string messageId, ContextBag options) { OutboxRecord result; using (var session = GetSession(options)) { // We use Load operation and not queries to avoid stale results var outboxDocId = GetOutboxRecordId(messageId); result = await session.LoadAsync <OutboxRecord>(outboxDocId).ConfigureAwait(false); } if (result == null) { return(default(OutboxMessage)); } if (result.Dispatched || result.TransportOperations.Length == 0) { return(new OutboxMessage(result.MessageId, emptyTransportOperations)); } var transportOperations = new TransportOperation[result.TransportOperations.Length]; var index = 0; foreach (var op in result.TransportOperations) { transportOperations[index] = new TransportOperation(op.MessageId, op.Options, op.Message, op.Headers); index++; } return(new OutboxMessage(result.MessageId, transportOperations)); }
public async Task<OutboxMessage> Get(string messageId, ContextBag options) { OutboxRecord result; using (var session = documentStore.OpenAsyncSession()) { session.Advanced.AllowNonAuthoritativeInformation = false; // We use Load operation and not queries to avoid stale results var possibleIds = GetPossibleOutboxDocumentIds(messageId); var docs = await session.LoadAsync<OutboxRecord>(possibleIds).ConfigureAwait(false); result = docs.FirstOrDefault(o => o != null); } if (result == null) { return default(OutboxMessage); } if (result.Dispatched || result.TransportOperations.Length == 0) { return new OutboxMessage(result.MessageId, emptyTransportOperations); } var transportOperations = new TransportOperation[result.TransportOperations.Length]; var index = 0; foreach (var op in result.TransportOperations) { transportOperations[index] = new TransportOperation(op.MessageId, op.Options, op.Message, op.Headers); index++; } return new OutboxMessage(result.MessageId, transportOperations); }
public async Task <OutboxMessage> Get(string messageId, ContextBag options) { OutboxRecord result; using (var session = GetSession(options)) { session.Advanced.AllowNonAuthoritativeInformation = false; // We use Load operation and not queries to avoid stale results var possibleIds = GetPossibleOutboxDocumentIds(messageId); var docs = await session.LoadAsync <OutboxRecord>(possibleIds).ConfigureAwait(false); result = docs.FirstOrDefault(o => o != null); } if (result == null) { return(default(OutboxMessage)); } if (result.Dispatched || result.TransportOperations.Length == 0) { return(new OutboxMessage(result.MessageId, emptyTransportOperations)); } var transportOperations = new TransportOperation[result.TransportOperations.Length]; var index = 0; foreach (var op in result.TransportOperations) { transportOperations[index] = new TransportOperation(op.MessageId, op.Options, op.Message, op.Headers); index++; } return(new OutboxMessage(result.MessageId, transportOperations)); }