コード例 #1
0
        public ErrorTypes RemoveTask(object key)
        {
            ErrorTypes eResult = ErrorTypes.Unknown;

            try
            {
                SQSDataKey oSQSDataKey = (SQSDataKey)key;
                string     strUrlQueue = GetQueueUrl(oSQSDataKey.m_oPriority);

                using (Amazon.SQS.AmazonSQS oSQSClient = Amazon.AWSClientFactory.CreateAmazonSQSClient())
                {
                    Amazon.SQS.Model.DeleteMessageRequest oDeleteRequest = new Amazon.SQS.Model.DeleteMessageRequest();
                    oDeleteRequest.QueueUrl      = strUrlQueue;
                    oDeleteRequest.ReceiptHandle = (string)oSQSDataKey.m_strReceiptHandle;

                    oSQSClient.DeleteMessage(oDeleteRequest);
                    eResult = ErrorTypes.NoError;
                }
            }
            catch (Amazon.SQS.AmazonSQSException)
            {
            }
            catch
            {
            }

            return(eResult);
        }
コード例 #2
0
        public ErrorTypes AddTask(TaskQueueData oTask, Priority oPriority)
        {
            ErrorTypes eResult     = ErrorTypes.Unknown;
            string     strUrlQueue = GetQueueUrl(oPriority);

            try
            {
                string strData = TaskQueueData.SerializeToXml(oTask);

                using (Amazon.SQS.AmazonSQS oSQSClient = Amazon.AWSClientFactory.CreateAmazonSQSClient())
                {
                    Amazon.SQS.Model.SendMessageRequest oSendMessageRequest = new Amazon.SQS.Model.SendMessageRequest();
                    oSendMessageRequest.QueueUrl    = strUrlQueue;
                    oSendMessageRequest.MessageBody = strData;
                    oSQSClient.SendMessage(oSendMessageRequest);
                    eResult = ErrorTypes.NoError;
                }
            }
            catch (Amazon.SQS.AmazonSQSException)
            {
                eResult = ErrorTypes.TaskQueue;
            }
            catch
            {
                eResult = ErrorTypes.TaskQueue;
            }

            return(eResult);
        }
コード例 #3
0
        public EC2ScaleContract()
        {
            IAWSContext ctx;

            ctx    = AppUtility.GetContext();
            client = ctx.GetEC2Client();
            queue  = ctx.GetQueueClient();
        }
コード例 #4
0
        static SimpleMessageConnect()
        {
            IAWSContext awsCtx = Turbine.Consumer.AWS.AppUtility.GetContext();

            topicArn     = awsCtx.RequestTopicArn;
            notification = Amazon.AWSClientFactory
                           .CreateAmazonSNSClient(awsCtx.AccessKey, awsCtx.SecretKey,
                                                  new AmazonSimpleNotificationServiceConfig().WithServiceURL(awsCtx.SNSServiceURL));
            Debug.WriteLine("topicArn: " + topicArn);
            Debug.WriteLine("SQSServiceURL: " + awsCtx.SQSServiceURL);
            Debug.WriteLine("SNSServiceURL: " + awsCtx.SNSServiceURL);
            queue = Amazon.AWSClientFactory
                    .CreateAmazonSQSClient(
                awsCtx.AccessKey, awsCtx.SecretKey,
                new Amazon.SQS.AmazonSQSConfig().WithServiceURL(awsCtx.SQSServiceURL));
            responseQueuePrefix = awsCtx.ResponseQueuePrefix;
        }
コード例 #5
0
        public SimpleMessageListener()
        {
            IAWSOrchestratorContext awsCtx = Turbine.Orchestrator.AWS.AppUtility.GetContext();

            topicArn = awsCtx.RequestTopicArn;

            notification = Amazon.AWSClientFactory
                           .CreateAmazonSNSClient(awsCtx.AccessKey, awsCtx.SecretKey,
                                                  new AmazonSimpleNotificationServiceConfig().WithServiceURL(awsCtx.SNSServiceURL));
            queue = Amazon.AWSClientFactory
                    .CreateAmazonSQSClient(
                awsCtx.AccessKey, awsCtx.SecretKey,
                new Amazon.SQS.AmazonSQSConfig().WithServiceURL(awsCtx.SQSServiceURL));

            requestQueue = awsCtx.RequestQueue;// REQUIRED
            submitQueue  = awsCtx.SubmitQueue;
            queueId      = Guid.NewGuid();
        }
コード例 #6
0
        private TaskQueueData GetTask(Priority oPriority)
        {
            string strUrlQueue = GetQueueUrl(oPriority);

            TaskQueueData oData = null;

            try
            {
                using (Amazon.SQS.AmazonSQS oSQSClient = Amazon.AWSClientFactory.CreateAmazonSQSClient())
                {
                    Amazon.SQS.Model.ReceiveMessageRequest oReceiveMessageRequest = new Amazon.SQS.Model.ReceiveMessageRequest();
                    oReceiveMessageRequest.QueueUrl            = strUrlQueue;
                    oReceiveMessageRequest.MaxNumberOfMessages = 1;

                    Amazon.SQS.Model.ReceiveMessageResponse oReceiveMessageResponse = oSQSClient.ReceiveMessage(oReceiveMessageRequest);
                    if (oReceiveMessageResponse.IsSetReceiveMessageResult())
                    {
                        Amazon.SQS.Model.ReceiveMessageResult oReceiveMessageResult = oReceiveMessageResponse.ReceiveMessageResult;
                        foreach (Amazon.SQS.Model.Message oMessage in oReceiveMessageResult.Message)
                        {
                            oData = TaskQueueData.DeserializeFromXml(oMessage.Body);

                            SQSDataKey oSQSDataKey = new SQSDataKey();
                            oSQSDataKey.m_oPriority        = oPriority;
                            oSQSDataKey.m_strReceiptHandle = oMessage.ReceiptHandle;
                            oData.m_oDataKey = oSQSDataKey;
                            break;
                        }
                    }
                }
            }
            catch (Amazon.SQS.AmazonSQSException)
            {
            }
            catch
            {
            }

            return(oData);
        }