Example #1
0
        /// <summary>
        /// Get the number of items in an SQS queue
        /// </summary>
        /// <param name="QueueUrl">The SQS queue URL</param>
        /// <returns>Number of messages in the queue. Returns zero in the event of an error.</returns>
        public int GetSQSQueueCount(string QueueUrl)
        {
            if (!IsSQSValid)
            {
                return(0);
            }

            GetQueueAttributesRequest AttribRequest = new GetQueueAttributesRequest
            {
                QueueUrl       = QueueUrl,
                AttributeNames = new List <string>
                {
                    "ApproximateNumberOfMessages"
                }
            };

            GetQueueAttributesResponse AttribResponse = SqsClient.GetQueueAttributes(AttribRequest);

            return(AttribResponse.ApproximateNumberOfMessages);
        }
Example #2
0
        /// <summary>
        /// Returns the count of items in the SQS
        /// </summary>
        private int GetSQSCount()
        {
            try
            {
                var AttribRequest = new GetQueueAttributesRequest
                {
                    QueueUrl       = Config.Default.AWSSQSQueueUrl,
                    AttributeNames = new List <string>
                    {
                        "ApproximateNumberOfMessages"
                    }
                };

                var AttribResponse = SqsClient.GetQueueAttributes(AttribRequest);
                return(AttribResponse.ApproximateNumberOfMessages);
            }
            catch (Exception Ex)
            {
                CrashReporterProcessServicer.WriteException("GetSQSCount: " + Ex.ToString());
            }
            return(0);
        }