예제 #1
0
파일: Queue.cs 프로젝트: Wrath7/testrepo
        public static QueueResult DeleteQueue(string queueName)
        {
            AmazonSQSClient client = GetClient();

            Amazon.SQS.Model.DeleteQueueResponse response = null;
            Amazon.SQS.Model.DeleteQueue request = new Amazon.SQS.Model.DeleteQueue();
            QueueResult result = new QueueResult();

            try
            {
                request.QueueName = queueName;
                response = client.DeleteQueue(request);

                result.Success = true;
            }
            catch (Amazon.SQS.AmazonSQSException e)
            {
                result.isError = true;
                result.Exception = e;
                result.ErrorMessage = e.Message;
                result.ErrorType = QueueResult.GazaroASQSErrorType.Amazon;
            }
            catch (Exception e)
            {
                result.isError = true;
                result.Exception = e;
                result.ErrorMessage = e.Message;
                result.ErrorType = QueueResult.GazaroASQSErrorType.dotNet;
            }

            return result;
        }
예제 #2
0
파일: Queue.cs 프로젝트: Wrath7/testrepo
        public QueueResult Pop(bool deleteMessage)
        {
            Amazon.SQS.Model.ReceiveMessageResponse response = null;
            Amazon.SQS.Model.ReceiveMessage request = new Amazon.SQS.Model.ReceiveMessage();
            QueueResult result = new QueueResult();

            try
            {
                request.QueueName = _queueName;
                response = _client.ReceiveMessage(request);

                result.Success = true;

                if (response.ReceiveMessageResult.Message.Count > 0)
                {
                    result.ResponseData = response.ReceiveMessageResult.Message[0].Body;

                    if (deleteMessage)
                    {
                        Amazon.SQS.Model.DeleteMessage deleteRequest = new Amazon.SQS.Model.DeleteMessage();

                        deleteRequest.QueueName = _queueName;
                        deleteRequest.ReceiptHandle = response.ReceiveMessageResult.Message[0].ReceiptHandle;

                        _client.DeleteMessage(deleteRequest);
                    }
                }
            }
            catch (Amazon.SQS.AmazonSQSException e)
            {
                result.isError = true;
                result.Exception = e;
                result.ErrorMessage = e.Message;
                result.ErrorType = QueueResult.GazaroASQSErrorType.Amazon;
            }
            catch (Exception e)
            {
                result.isError = true;
                result.Exception = e;
                result.ErrorMessage = e.Message;
                result.ErrorType = QueueResult.GazaroASQSErrorType.dotNet;
            }

            return result;
        }
예제 #3
0
파일: Queue.cs 프로젝트: Wrath7/testrepo
        /// <summary>
        /// Open Queue Creates or Opens a Queue on Amazon SQS
        /// </summary>
        /// <param name="queueName">The name of the queue you want to create or open</param>
        /// <returns></returns>
        private QueueResult OpenQueue()
        {
            Amazon.SQS.Model.CreateQueueResponse response = null;
            Amazon.SQS.Model.CreateQueue request = new Amazon.SQS.Model.CreateQueue();
            QueueResult result = new QueueResult();

            try
            {
                request.QueueName = _queueName;
                response = _client.CreateQueue(request);

                result.Success = true;
                result.ResponseData = response.CreateQueueResult.QueueUrl;
            }
            catch (Amazon.SQS.AmazonSQSException e)
            {
                result.isError = true;
                result.Exception = e;
                result.ErrorMessage = e.Message;
                result.ErrorType = QueueResult.GazaroASQSErrorType.Amazon;
            }
            catch (Exception e)
            {
                result.isError = true;
                result.Exception = e;
                result.ErrorMessage = e.Message;
                result.ErrorType = QueueResult.GazaroASQSErrorType.dotNet;
            }

            return result;
        }
예제 #4
0
파일: Queue.cs 프로젝트: Wrath7/testrepo
        private QueueResult SetVisibilityAttribute(int visibilityTimeout)
        {
            Amazon.SQS.Model.SetQueueAttributes request = new Amazon.SQS.Model.SetQueueAttributes();
            Amazon.SQS.Model.SetQueueAttributesResponse response = null;
            QueueResult result = new QueueResult();

            try
            {
                request.QueueName = _queueName;

                Amazon.SQS.Model.Attribute visibilityAttribute = new Amazon.SQS.Model.Attribute();
                visibilityAttribute.Name = "VisibilityTimeout";
                visibilityAttribute.Value = visibilityTimeout.ToString();
                request.Attribute.Add(visibilityAttribute);

                response = _client.SetQueueAttributes(request);
                result.Success = true;
            }
            catch (Amazon.SQS.AmazonSQSException e)
            {
                result.isError = true;
                result.Exception = e;
                result.ErrorMessage = e.Message;
                result.ErrorType = QueueResult.GazaroASQSErrorType.Amazon;
            }
            catch (Exception e)
            {
                result.isError = true;
                result.Exception = e;
                result.ErrorMessage = e.Message;
                result.ErrorType = QueueResult.GazaroASQSErrorType.dotNet;
            }

            return result;
        }
예제 #5
0
파일: Queue.cs 프로젝트: Wrath7/testrepo
        public QueueResult Push(string message)
        {
            Amazon.SQS.Model.SendMessageResponse response = null;
            Amazon.SQS.Model.SendMessage request = new Amazon.SQS.Model.SendMessage();
            QueueResult result = new QueueResult();

            try
            {
                request.MessageBody = message;
                request.QueueName = _queueName;
                response = _client.SendMessage(request);

                result.Success = true;
                result.ResponseData = response.SendMessageResult.MessageId;
            }
            catch (Amazon.SQS.AmazonSQSException e)
            {
                result.isError = true;
                result.Exception = e;
                result.ErrorMessage = e.Message;
                result.ErrorType = QueueResult.GazaroASQSErrorType.Amazon;
            }
            catch (Exception e)
            {
                result.isError = true;
                result.Exception = e;
                result.ErrorMessage = e.Message;
                result.ErrorType = QueueResult.GazaroASQSErrorType.dotNet;
            }

            return result;
        }