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;
        }
Esempio n. 2
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();
        }
Esempio n. 3
0
        static void SetupTopicAndQueue()
        {
            snsClient = new AmazonSimpleNotificationServiceClient(Amazon.RegionEndpoint.USEast1);
            sqsClient = new AmazonSQSClient(Amazon.RegionEndpoint.USEast1);

            long ticks = DateTime.Now.Ticks;

            topicArn = snsClient.CreateTopic(new CreateTopicRequest {
                Name = "GlacierDownload-" + ticks
            }).CreateTopicResult.TopicArn;
            queueUrl = sqsClient.CreateQueue(new CreateQueueRequest()
            {
                QueueName = "GlacierDownload-" + ticks
            }).CreateQueueResult.QueueUrl;
            queueArn = sqsClient.GetQueueAttributes(new GetQueueAttributesRequest()
            {
                QueueUrl = queueUrl, AttributeName = new List <string> {
                    "QueueArn"
                }
            }).GetQueueAttributesResult.QueueARN;

            snsClient.Subscribe(new SubscribeRequest()
            {
                Protocol = "sqs",
                Endpoint = queueArn,
                TopicArn = topicArn
            });

            // Add policy to the queue so SNS can send messages to the queue.
            var policy = SQS_POLICY.Replace("{QuernArn}", queueArn).Replace("{TopicArn}", topicArn);

            sqsClient.SetQueueAttributes(new SetQueueAttributesRequest()
            {
                QueueUrl  = queueUrl,
                Attribute = new List <Amazon.SQS.Model.Attribute>()
                {
                    new Amazon.SQS.Model.Attribute()
                    {
                        Name  = "Policy",
                        Value = policy
                    }
                }
            });
        }
Esempio n. 4
0
        /// <summary>
        /// Override of the append method.  This is where the message is sent to the SNS
        /// </summary>
        /// <param name="loggingEvent">Event to be sent</param>
        protected override void Append(LoggingEvent loggingEvent)
        {
            // Get the message
            var logMessage = RenderLoggingEvent(loggingEvent);

            // Get the reference to the Amazon SNS if we don't have one
            if (NotificationService == null)
            {
                NotificationService = new AmazonSimpleNotificationServiceClient(AWSAccessKey, AWSSecretKey);
            }

            // Push out the message
            var publishRequest = new PublishRequest()
                                 .WithTopicArn(Topic)
                                 .WithSubject(MessageSubject)
                                 .WithMessage(logMessage);

            this.NotificationService.Publish(publishRequest);
        }
Esempio n. 5
0
        public void Arrange()
        {
            tempQueueName = "Test_QUEUE_1";
            _config       = Configure.With()
                            .StructureMapBuilder()
                            .HandlersAreInAssemblyContainingType <TestEvent>()
                            .AmazonPublisher();

            _config
            .AwsAccessKeyId(awsKey)
            .AwsSecretKey(secret)
            .TopicArn(topicArn)
            .QueueName(tempQueueName)
            .EventsAreInAssemblyContainingType <TestEvent>();

            _publisher = new AmazonPublisher(_config);

            _amazonClient = AWSClientFactory.CreateAmazonSQSClient(awsKey, secret);
            _snsClient    = AWSClientFactory.CreateAmazonSNSClient(awsKey, secret);
        }
Esempio n. 6
0
        internal DownloadFileCommand(ArchiveTransferManager manager, string vaultName, string archiveId, string filePath, DownloadOptions options)
        {
            this.manager   = manager;
            this.vaultName = vaultName;
            this.archiveId = archiveId;
            this.filePath  = filePath;
            this.options   = options;

            var            credentials = ((AmazonGlacierClient)this.manager.GlacierClient).Credentials;
            var            regionName  = Util.AWSSDKUtils.DetermineRegion(((AmazonGlacierClient)this.manager.GlacierClient).ServiceURL);
            RegionEndpoint region      = RegionEndpoint.GetBySystemName(regionName);

            this.snsClient = new AmazonSimpleNotificationServiceClient(credentials, region);
            this.sqsClient = new AmazonSQSClient(credentials, region);

            if (this.options == null)
            {
                this.options = new DownloadOptions();
            }
        }
 public SNSHelper(AmazonSimpleNotificationService amazonSNSClient)
 {
     Client = amazonSNSClient;
 }
Esempio n. 8
0
 public SNSHelper(AmazonSimpleNotificationService amazonSNSClient)
 {
     Client = amazonSNSClient;
 }
        internal DownloadFileCommand(ArchiveTransferManager manager, string vaultName, string archiveId, string filePath, DownloadOptions options)
        {
            this.manager = manager;
            this.vaultName = vaultName;
            this.archiveId = archiveId;
            this.filePath = filePath;
            this.options = options;

            var credentials = ((AmazonGlacierClient)this.manager.GlacierClient).Credentials;
            var regionName = Util.AWSSDKUtils.DetermineRegion(((AmazonGlacierClient)this.manager.GlacierClient).ServiceURL);
            RegionEndpoint region = RegionEndpoint.GetBySystemName(regionName);

            this.snsClient = new AmazonSimpleNotificationServiceClient(credentials, region);
            this.sqsClient = new AmazonSQSClient(credentials, region);

            if (this.options == null)
                this.options = new DownloadOptions();
        }
Esempio n. 10
0
        //        public string GetInventory()
        //        {
        //            AmazonGlacier client;
        //            try
        //            {
        //                using (client = new AmazonGlacierClient(RegionEndpoint))
        //                {
        //                    // Setup SNS topic and SQS queue.
        //                    SetupTopicAndQueue();
        //                    GetInventory();
        //                }
        //                Console.WriteLine("Operations successful. To continue, press Enter");
        //            }
        //            catch (AmazonGlacierException e) { Console.WriteLine(e.Message); }
        //            catch (AmazonServiceException e) { Console.WriteLine(e.Message); }
        //            catch (Exception e) { Console.WriteLine(e.Message); }
        //            finally
        //            {
        //                // Delete SNS topic and SQS queue.
        //                _snsClient.DeleteTopic(new DeleteTopicRequest() { TopicArn = _topicArn });
        //                sqsClient.DeleteQueue(new DeleteQueueRequest() { QueueUrl = _queueUrl });
        //            }
        //        }
        static void SetupTopicAndQueue()
        {
            _snsClient = new AmazonSimpleNotificationServiceClient(Amazon.RegionEndpoint.USEast1);
            sqsClient = new AmazonSQSClient(Amazon.RegionEndpoint.USEast1);

            var ticks = DateTime.Now.Ticks;
            _topicArn = _snsClient.CreateTopic(new CreateTopicRequest { Name = "GlacierDownload-" + ticks }).CreateTopicResult.TopicArn;
            _queueUrl = sqsClient.CreateQueue(new CreateQueueRequest() { QueueName = "GlacierDownload-" + ticks }).CreateQueueResult.QueueUrl;
            _queueArn = sqsClient.GetQueueAttributes(new GetQueueAttributesRequest() { QueueUrl = _queueUrl, AttributeName = new List<string> { "QueueArn" } }).GetQueueAttributesResult.QueueARN;

            _snsClient.Subscribe(new SubscribeRequest()
            {
                Protocol = "sqs",
                Endpoint = _queueArn,
                TopicArn = _topicArn
            });

            // Add policy to the queue so SNS can send messages to the queue.
            var policy = SQS_POLICY.Replace("{QuernArn}", _queueArn).Replace("{TopicArn}", _topicArn);
            sqsClient.SetQueueAttributes(new SetQueueAttributesRequest()
            {
                QueueUrl = _queueUrl,
                Attribute = new List<Amazon.SQS.Model.Attribute>()
            {
               new Amazon.SQS.Model.Attribute()
               {
             Name = "Policy",
             Value = policy
               }
            }
            });
        }