Beispiel #1
0
        public async Task <Contracts.SagaState> Read(Guid correlationId)
        {
            var table = await _tableService.GetTable(EVENT_STORE_TABLE_NAME, false).ConfigureAwait(false);

            var query = new TableQuery <SagaState>()
                        .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, correlationId.ToString()));

            var results = new List <SagaState>();
            TableContinuationToken continuationToken = null;

            do
            {
                var result = await table.ExecuteQuerySegmentedAsync(query, continuationToken).ConfigureAwait(false);

                if (result.Results?.Count > 0)
                {
                    results.AddRange(result.Results);
                }
                continuationToken = result.ContinuationToken;
            } while (continuationToken != null);

            var sagaStateRow = results.FirstOrDefault();

            if (sagaStateRow == null)
            {
                return(null);
            }
            var stateType = GetTypeFromFullName(sagaStateRow.RowKey);

            return(new Contracts.SagaState
            {
                StateType = stateType,
                State = sagaStateRow.GetData().FromBson(stateType)
            });
        }
Beispiel #2
0
        public IEnumerable <DomainEvent> GetEvents(Guid aggregateRootId, int startSequence)
        {
            var table = _tableService.GetTable(_eventStoreTableName);

            var query = new TableQuery <AzureDomainEvent>()
                        .Where(TableQuery
                               .CombineFilters(
                                   TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, aggregateRootId.ToString()),
                                   TableOperators.And,
                                   TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.GreaterThan, startSequence.ToString(SEQUENCE_FORMAT_STRING))
                                   )
                               );

            var ret = ConvertToDomainEvent(table.ExecuteQuery(query));

            return(ret);
        }
        public async Task Insert(string sessionId, string messageId, long sequenceId, string type, DateTime submitDate, DateTime scheduleEnqueueDate)
        {
            var table = await _tableService.GetTable(EVENT_STORE_TABLE_NAME, false).ConfigureAwait(false);

            var entity          = new ScheduledMessage(sessionId, messageId, sequenceId, type, submitDate, scheduleEnqueueDate);
            var insertOperation = TableOperation.Insert(entity);
            await table.ExecuteAsync(insertOperation).ConfigureAwait(false);
        }