protected override async Task ActAsync()
        {
            var messageProp     = _messageProp2.GetNextItem();
            var opNumber        = ConfigurationManager.AppSettings["OpNumber"];
            int operationNumber = string.IsNullOrEmpty(opNumber) ? _operationNumbers.GetNextItem() : Convert.ToInt16(opNumber);
            int count;

            await Task.Run(() =>
            {
                switch (operationNumber)
                {
                case 1:
                    Logger.LogInfo($"calling Read {messageProp.TransOrigin}-{messageProp.GetPrimarySortKeyPrefix<Int64>()}");
                    var results1 = _dynamoDbReadActor.Read <TransLog, IMessageProp, Int64>(messageProp.TransOrigin, messageProp, out count);
                    Logger.LogInfo($"Read {messageProp.TransOrigin}-{messageProp.GetPrimarySortKeyPrefix<Int64>()} result count {count}");
                    break;

                case 2:
                    var results2 = _dynamoDbReadActor.ReadGsi <TransLog>(messageProp.AppId, messageProp.MessageOrigin, out count);
                    Logger.LogInfo($"Read GSI {messageProp.AppId}-{messageProp.MessageOrigin} result count {count}");
                    break;

                case 3:
                    var results3 = _dynamoDbReadActor.ReadLsi <TransLog>(messageProp.TransOrigin, messageProp.MessageType, out count);
                    Logger.LogInfo($"Read LSI {messageProp.TransOrigin}-{messageProp.MessageType} result count {count}");
                    break;

                case 4:
                    var results4 = _dynamoDbReadActor.ReadLsi2 <TransLog>(messageProp.TransOrigin, messageProp.MessageDestination, out count);
                    Logger.LogInfo($"Read LSI2 {messageProp.TransOrigin}-{messageProp.MessageDestination} result count {count}");
                    break;
                }
            }).ConfigureAwait(false);
        }
Esempio n. 2
0
        protected override async Task ActAsync()
        {
            int operationNumber;
            var useAsyncWrite = ConfigurationManager.AppSettings["UseAsyncWrite"];

            if (string.IsNullOrEmpty(useAsyncWrite) || useAsyncWrite.Equals("false"))
            {
                operationNumber = 1;
            }
            else
            {
                operationNumber = _randomOps.Next(1, 2);
            }

            var messageProp = _messageProps.GetNextItem();

            switch (operationNumber)
            {
            case 1:
                await Task.Run(() =>
                {
                    _dynamoDbWriteActor.Write <TransLog>(FillTransLog(messageProp));
                    Logger.LogDebug("write done");
                }).ConfigureAwait(false);

                break;

            case 2:
                await _dynamoDbWriteActor.WriteAsync <TransLog>(FillTransLog(messageProp));

                Logger.Log("WriteAsync done");
                break;
            }
        }