Beispiel #1
0
        public async Task RunOnceAsync()
        {
            try
            {
                var xConnectClient = await _xConnectProvider.CreateXConnectClient();

                var lastCheckpointDate = await _checkpointTracker.GetLastCheckpoint(_kinesisProducer.DeliveryStreamName);

                var newCheckpointDate = DateTime.UtcNow;

                var queryBatchEnumerator = await CreateXConnectQuery(xConnectClient,
                                                                     lastCheckpointDate ?? QueryInitialTimestamp,
                                                                     newCheckpointDate,
                                                                     XConnectQueryBatchSize);

                _logger.LogInfo($"xConnnet query returned {queryBatchEnumerator.TotalCount} record(s).");

                while (await queryBatchEnumerator.MoveNext())
                {
                    var recordBatch        = queryBatchEnumerator.Current;
                    var transformedRecords = await CreateRecordsProjection(recordBatch);

                    await _kinesisProducer.PutRecordsAsJson(transformedRecords);
                }

                await _checkpointTracker.CreateNewCheckpoint(_kinesisProducer.DeliveryStreamName, newCheckpointDate);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex);
            }
        }