예제 #1
0
        public async Task <string> GetContractRaw()
        {
            Action throwAction = () =>
            {
                _slackNotifier.ErrorAsync("Chronobank integration! User contract pool is empty!");
                throw new BackendException("User contract pool is empty!", ErrorCode.ContractPoolEmpty);
            };
            var message = await _queue.GetRawMessageAsync();

            if (message == null)
            {
                throwAction();
            }

            await _queue.FinishRawMessageAsync(message);

            var contract = message.AsString;

            if (string.IsNullOrWhiteSpace(contract))
            {
                throwAction();
            }

            return(contract);
        }
예제 #2
0
        public async Task <IQueueMessage> GetMessageAsync()
        {
            var msg = await _queue.GetRawMessageAsync(_visibilityTimeoutSeconds);

            if (msg != null)
            {
                return(new AzureMessage(msg));
            }
            return(null);
        }
예제 #3
0
        public async Task <Coin> DequeueCoin()
        {
            var msg = await _queue.GetRawMessageAsync();

            if (msg == null)
            {
                throw new BackendException($"Pregenerated pool '{_queueName}' is empty!", ErrorCode.PregeneratedPoolIsEmpty);
            }

            await _queue.FinishRawMessageAsync(msg);

            return(msg.AsString.DeserializeJson <SerializableCoin>().ToCoin());
        }
예제 #4
0
        public async Task Start()
        {
            int?cnt = 0;
            int i   = 0;

            while ((cnt = await _fromQueue.Count()) > 0)
            {
                var msg = await _fromQueue.GetRawMessageAsync();

                await _toQueue.PutRawMessageAsync(msg.AsString);

                await _fromQueue.FinishRawMessageAsync(msg);

                Console.WriteLine($"Processed {++i} from {cnt}");
            }
        }
예제 #5
0
        public async Task <string> GetContractAddress()
        {
            var message = await _queue.GetRawMessageAsync();

            if (message != null)
            {
                await _queue.FinishRawMessageAsync(message);

                return(message.AsString);
            }
            else
            {
                await _slackNotifier.ErrorAsync("Ethereum Core Service! Erc20 deposit contract pool is empty!");

                throw new ClientSideException(ExceptionType.ContractPoolEmpty, "Erc20 deposit contract pool is empty!");
            }
        }
        public async Task RemoveFromPendingOperationQueue(string opId)
        {
            var count = await _queue.Count();

            for (int i = 0; i < count; i++)
            {
                var message = await _queue.GetRawMessageAsync();

                OperationHashMatchMessage newMessage = JsonConvert.DeserializeObject <OperationHashMatchMessage>(message.AsString);

                await _queue.FinishRawMessageAsync(message);

                if (newMessage.OperationId?.ToLower() != opId?.ToLower())
                {
                    await _queue.PutRawMessageAsync(message.AsString);
                }
            }
        }
        public async Task <T> TryGetAsync(
            TimeSpan visibilityTimeout)
        {
            var queueMessage = await _queue.GetRawMessageAsync((int)visibilityTimeout.TotalSeconds);

            if (queueMessage != null)
            {
                var task = JsonConvert.DeserializeObject <T>(queueMessage.AsString);

                return(task.WithMessageIdAndPopReceipt
                       (
                           messageId: queueMessage.Id,
                           popReceipt: queueMessage.PopReceipt
                       ));
            }
            else
            {
                return(null);
            }
        }
        public async Task <string> GetContractRaw()
        {
            //TODO: think about locking code below
            var message = await _queue.GetRawMessageAsync();

            if (message == null)
            {
                NotifyAboutError();
            }

            await _queue.FinishRawMessageAsync(message);

            var contract = message.AsString;

            if (string.IsNullOrWhiteSpace(contract))
            {
                NotifyAboutError();
            }

            return(contract);
        }
예제 #9
0
        private async Task FinishMessage()
        {
            var msg = await _incomeQueue.GetRawMessageAsync();

            await _incomeQueue.FinishRawMessageAsync(msg);
        }
예제 #10
0
 public Task <CloudQueueMessage> GetRawMessageAsync(int visibilityTimeoutSeconds = 30)
 => WrapAsync(() => _impl.GetRawMessageAsync(visibilityTimeoutSeconds), Name);