• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SQS.AmazonSQSClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Amazon.SQS.AmazonSQSClient的典型用法代码示例。如果您正苦于以下问题:C# AmazonSQSClient类的具体用法?C# AmazonSQSClient怎么用?C# AmazonSQSClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AmazonSQSClient类属于Amazon.SQS命名空间,在下文中一共展示了AmazonSQSClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AmazonConnection

        public AmazonConnection(TypeOfMsg requestMsgType)
        {
            pollingMsg = requestMsgType;

            objClient = new AmazonSQSClient(AccessKeyId, SecretAccessKey);

            CreateQueueResponse queueResponse = new CreateQueueResponse();

            //Request existing queues
            ListQueuesResult allQueues = requestListOfQueuesInSQS();

            bool eventSparkzQueueListExists = false;

            foreach (string queueURL in allQueues.QueueUrl)
            {
                if (queueURL.Equals(QueueURLString))
                {
                    eventSparkzQueueListExists = true;
                }
            }

            if (!eventSparkzQueueListExists)
            {
                queueResponse = objClient.CreateQueue(new CreateQueueRequest()
                {
                    QueueName
                        = EventSparkzQueueName
                });
            }
        }
开发者ID:expectomas,项目名称:EventSparkz,代码行数:30,代码来源:AmazonConnection.cs


示例2: SQSHandeler

 public SQSHandeler(BasicAWSCredentials amazonCredentials, AmazonSQSClient sqsClient)
 {
     if (amazonCredentials != null && sqsClient != null) {
         this.amazonCredentials = amazonCredentials;
         this.sqsClient = sqsClient;
     }
 }
开发者ID:tyh24647,项目名称:Assignment_8_v2,代码行数:7,代码来源:SQSHandeler.cs


示例3: DoWork

 public void DoWork()
 {
     var credentials = new BasicAWSCredentials(ConfigurationManager.AppSettings["AccessKey"], ConfigurationManager.AppSettings["SecretKey"]);
     _sqsClient = new AmazonSQSClient(credentials, RegionEndpoint.EUWest1);
     Console.WriteLine("Number of messages at once");
     int numberOfMessages;
     int.TryParse(Console.ReadLine(), out numberOfMessages);
     var running = true;
     while (running)
     {
         var messageList = GetMessageFromQueue(numberOfMessages);
         Console.WriteLine("Number of messages: " + messageList.Count);
         if (messageList.Count == 0)
         {
             Thread.Sleep(5000);
         }
         Console.WriteLine();
         foreach (var message in messageList)
         {
             Console.WriteLine("Message: " + message.Body);
             Console.WriteLine("Receipt Handle: " + message.ReceiptHandle);
             Console.WriteLine("Delete?");
             var readLine = Console.ReadLine();
             var delete = readLine != null ? readLine.ToLower() : "n";
             if (delete == "y")
             {
                 DeleteMessageFromQueue(message.ReceiptHandle);
             }
         }
     }
 }
开发者ID:pierskarsenbarg,项目名称:sqs-demo,代码行数:31,代码来源:QueueReceiverHelper.cs


示例4: GetMessage

        public async Task<Amazon.SQS.Model.Message> GetMessage(string queueName, int  timeoutInMilliseconds, int numberOfCacheableMessages)
        {
            Amazon.SQS.Model.Message message = null;
            if (_queue.ContainsKey(queueName) && _queue[queueName].TryDequeue(out message)) return message;
            
            var request = new ReceiveMessageRequest(queueName)
            {
                MaxNumberOfMessages = numberOfCacheableMessages,
                WaitTimeSeconds = (int)TimeSpan.FromMilliseconds(timeoutInMilliseconds).TotalSeconds
            };

            using (var client = new AmazonSQSClient(_credentials))
            {
                var response = await client.ReceiveMessageAsync(request);
                                
                if (response.HttpStatusCode != HttpStatusCode.OK) return message;

                if (response.ContentLength == 0) return message;

                if (!response.Messages.Any()) return message;

                AddToQueue(queueName, response.Messages);

                if(_queue.ContainsKey(queueName))
                    _queue[queueName].TryDequeue(out message);
            }

            return message;
        }
开发者ID:iancooper,项目名称:Paramore,代码行数:29,代码来源:SqsQueuedRetriever.cs


示例5: When_obtaining_details_on_a_message_queue

        public void When_obtaining_details_on_a_message_queue(string queueName, bool exists)
        {
            // Arrange
            var client = new AmazonSQSClient("access key", "secret key");

            if (exists)
            {
                client.CreateQueue(new CreateQueueRequest().WithQueueName(queueName));
            }
            else
            {
                var response = client.ListQueues(new ListQueuesRequest().WithQueueNamePrefix(queueName));
                if (response.ListQueuesResult.QueueUrl.Any())
                {
                    client.DeleteQueue(new DeleteQueueRequest().WithQueueUrl(response.ListQueuesResult.QueueUrl.First()));
                }
            }

            Thread.Sleep(2000); // Give the queues some time to spin up
          
            var factory = new AmazonSqsMessageQueueDetailFactory(client);


            // Act
            var result = factory.Build<TestMessage>(queueName);

            // Assert
            Assert.That(result.Uri, Is.StringContaining(queueName));
            Assert.That(result.Exists, Is.EqualTo(exists));
        }  
开发者ID:jrolstad,项目名称:Simple.Messaging,代码行数:30,代码来源:AmazonSqsMessageQueueDetailFactoryTests.cs


示例6: DeleteQueueByQueueUrl

 public static void DeleteQueueByQueueUrl(string queueUrl)
 {
     using (var client = new AmazonSQSClient(Settings.AccessKey, Settings.Secret))
     {
         client.DeleteQueue(queueUrl);
     }
 }
开发者ID:korz,项目名称:IntroductionToAmazonAws,代码行数:7,代码来源:Repository.cs


示例7: InitializeQueue

        private AmazonSQSClient InitializeQueue()
        {
            var client = new AmazonSQSClient(Utility.GetRegionEndpoint());
            
            ListQueuesRequest listQueuesRequest = new ListQueuesRequest
                                                      {
                                                          QueueNamePrefix = QueueName
                                                      };
            var listQueuesResponse = client.ListQueues(listQueuesRequest);
            bool found = listQueuesResponse.ListQueuesResult.QueueUrls.Any(s => s == QueueName);

            if (found == false)
            {
                var createQueueResponse = client.CreateQueue(new CreateQueueRequest
                                                                 {
                                                                     QueueName = QueueName
                                                                 });
                QueueUrl = createQueueResponse.CreateQueueResult.QueueUrl;
            }
            else
            {
                QueueUrl = client.GetQueueUrl(
                    new GetQueueUrlRequest
                        {
                            QueueName = _queueName
                        }
                    ).GetQueueUrlResult.QueueUrl;
            }
            return client;
        }
开发者ID:EdsonF,项目名称:log4net.aws,代码行数:30,代码来源:SQSAppender.cs


示例8: sendPosition

 public bool sendPosition(string latitude, string longitude)
 {
     AmazonSQSClient sqsClient = new AmazonSQSClient(Amazon.RegionEndpoint.USEast1);
     Amazon.SQS.Model.SendMessageRequest request = new Amazon.SQS.Model.SendMessageRequest();
     request.QueueUrl = SQS_URL_STRING;
     request.MessageBody = "lat: " + latitude + " lon: " + longitude;
     sqsClient.SendMessage(request);
     return true;
 }
开发者ID:trheming,项目名称:LocationReporter,代码行数:9,代码来源:AmazonSqsClient.cs


示例9: WriteToQueue

        static void WriteToQueue(AWSCredentials credentials)
        {
            AmazonSQSClient client = new AmazonSQSClient(credentials, RegionEndpoint.USEast1);

            string message = "my message";
            string queueUrl = "https://sqs.us-east-1.amazonaws.com/025631894481/aws-talk";

            SendMessageResponse sendMessageResponse = client.SendMessage(queueUrl, message);
        }
开发者ID:modulexcite,项目名称:2015-Slides-and-Demos,代码行数:9,代码来源:Program.cs


示例10: DeleteQueue

 public virtual void DeleteQueue(AmazonSQSClient sqsClient, string queueUrl)
 {
     var deleteQueueRequest = new DeleteQueueRequest
     {
         QueueUrl = queueUrl
     };
     // Delete the queue
     sqsClient.DeleteQueue(deleteQueueRequest);
 }
开发者ID:jfaerman,项目名称:devonaws-labs-csharp,代码行数:9,代码来源:SolutionCode.cs


示例11: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			CreateQueue.TouchUpInside += delegate(object sender, EventArgs e) {			
				var sqsClient = new Amazon.SQS.AmazonSQSClient (ACCESS_KEY, SECRET_KEY, Amazon.RegionEndpoint.EUWest1);
				var request = new Amazon.SQS.Model.CreateQueueRequest ();
				request.QueueName = "newQueue";
				var response = sqsClient.CreateQueue (request);
				CreateQueueResults.Text = String.Format("Queue created at {0}.", response.QueueUrl);
			};
		}
开发者ID:Clancey,项目名称:aws-sdk-net,代码行数:11,代码来源:SQS_SampleViewController.cs


示例12: CreateQueue

        public static string CreateQueue(string name)
        {
            using (var client = new AmazonSQSClient(Settings.AccessKey, Settings.Secret))
            {
                var request = new CreateQueueRequest
                {
                    QueueName = name
                };

                var response = client.CreateQueue(request);

                return response.QueueUrl;
            }
        }
开发者ID:korz,项目名称:IntroductionToAmazonAws,代码行数:14,代码来源:Repository.cs


示例13: CreateQueue

        public virtual string CreateQueue(AmazonSQSClient sqsClient, string queueName)
        {
            string queueUrl;

            // Create the request
            var createQueueRequest = new CreateQueueRequest {QueueName = queueName};

            // Submit the request
            CreateQueueResponse createQueueResponse = sqsClient.CreateQueue(createQueueRequest);

            // Return the URL for the newly created queue
            queueUrl = createQueueResponse.QueueUrl;
            return queueUrl;
        }
开发者ID:jfaerman,项目名称:devonaws-labs-csharp,代码行数:14,代码来源:SolutionCode.cs


示例14: DeleteAllQueues

        public static void DeleteAllQueues()
        {
            using (var client = new AmazonSQSClient(Settings.AccessKey, Settings.Secret))
            {
                var response = client.ListQueues(new ListQueuesRequest());

                foreach (var queueUrl in response.QueueUrls)
                {
                    PurgeQueueByQueueUrl(queueUrl);

                    client.DeleteQueue(queueUrl);
                }
            }
        }
开发者ID:korz,项目名称:IntroductionToAmazonAws,代码行数:14,代码来源:Repository.cs


示例15: Main

        static void Main(string[] args)
        {
            // AWS: Get instance public address
            string myId = "localhost";
            try
            {
                myId = Encoding.ASCII.GetString(new WebClient().DownloadData("http://169.254.169.254/latest/meta-data/public-hostname"));
            }
            catch
            {
            }

            // AWS SQS Client
            var sqsClient = new AmazonSQSClient();

            while (true)
            {
                // Get the next message
                ReceiveMessageRequest request = new ReceiveMessageRequest()
                    .WithQueueUrl("https://queue.amazonaws.com/*****/codeCampDemo")
                    .WithMaxNumberOfMessages(1);
                var response = sqsClient.ReceiveMessage(request);

                foreach (var retrievedMessage in response.ReceiveMessageResult.Message)
                {
                    var messageJson = JsonValue.Parse(retrievedMessage.Body);

                    var message = messageJson["message"].ReadAs<string>();

                    Console.WriteLine(message);

                    message = "Echo: " + message;

                    string address = string.Format("http://{0}", messageJson["sender"].ReadAs<string>());
                    var connection = new HubConnection(address);
                    connection.Start().Wait();

                    IHubProxy pongHub = connection.CreateProxy("MvcWebRole1.Hubs.EchoHub");
                    pongHub.Invoke("DoUpdateMessage", message, myId).Wait();

                    //Process the message and then delete the message
                    DeleteMessageRequest deleteRequest = new DeleteMessageRequest()
                        .WithQueueUrl("https://queue.amazonaws.com/******/codeCampDemo")
                        .WithReceiptHandle(retrievedMessage.ReceiptHandle);
                    sqsClient.DeleteMessage(deleteRequest);
                }

                Thread.Sleep(1000);
            }
        }
开发者ID:igormoochnick,项目名称:EndToEndDistributedAppAws,代码行数:50,代码来源:WorkerRole.cs


示例16: Messages_are_queued

        public void Messages_are_queued()
        {
            var client = new AmazonSQSClient(ConfigurationManager.AppSettings["AWSKey"], ConfigurationManager.AppSettings["AWSSecret"]);
            var queue = Guid.NewGuid().ToString();
            var consumer = new SimpleQueueConsumer<StringEvent>(client, queue);
            var block = new AutoResetEvent(false);
            
            var producer = new ObservingProducer<StringEvent>();
            producer.Attach(consumer);
            producer.Produces(GetPayload().ToObservable());
            producer.Start();

            block.WaitOne(TimeSpan.FromSeconds(5));
            client.DeleteQueue(new DeleteQueueRequest().WithQueueUrl(consumer.QueueUrl));
        }
开发者ID:modulexcite,项目名称:graveyard,代码行数:15,代码来源:SimpleQueueConsumerTests.cs


示例17: ReadFromQueue

        static void ReadFromQueue(AWSCredentials credentials)
        {
            AmazonSQSClient client = new AmazonSQSClient(credentials, RegionEndpoint.USEast1);

            string queueUrl = "https://sqs.us-east-1.amazonaws.com/025631894481/aws-talk";

            ReceiveMessageRequest request = new ReceiveMessageRequest(queueUrl);
            request.MaxNumberOfMessages = 1;
            ReceiveMessageResponse response = client.ReceiveMessage(request);

            foreach (var message in response.Messages)
            {
                // Do something with the message
            }
        }
开发者ID:modulexcite,项目名称:2015-Slides-and-Demos,代码行数:15,代码来源:Program.cs


示例18: Main

 // TODO: Get/set these values from namespace Common program.cs file instead
 public void Main(string[] args) {
     InitUserData();
     InitAmazonData();
     InitPeasantTasks();
     queueURL = sqsHandeler.QueueURL;
     amazonCredentials = new BasicAWSCredentials(userID, userKey);
     sqsClient = new AmazonSQSClient(amazonCredentials, RegionEndpoint.USEast1);
     Console.Write("Greetings, overlord!\n\n> How many tasks must"
         + " be given to these lowly peasants? ");
     var userMsg = Console.ReadLine();
     var numPeasantTasks = ParseUserMsg(userMsg);
     
     for (var i = 0; i < numPeasantTasks; i++) {
         var peasantTask = AssignTaskToPeasant();
         peasantTask.Wait();
     }
 }
开发者ID:tyh24647,项目名称:Assignment_8_v2,代码行数:18,代码来源:Program.cs


示例19: Messages_are_dequeued

        public void Messages_are_dequeued()
        {
            var block = new AutoResetEvent(false);
            var sent = 10;
            var received = 0;

            var serializer = new JsonSerializer();
            var key = ConfigurationManager.AppSettings["AWSKey"];
            var secret = ConfigurationManager.AppSettings["AWSSecret"];
            var queueName = Guid.NewGuid().ToString();

            var client = new AmazonSQSClient(key, secret);

            // Anything put into the queue will go to Amazon SQS
            var queue = new ConcurrentQueue<StringEvent>();
            var consumer = new SimpleQueueConsumer<StringEvent>(client, queueName);
            new CollectionProducer<StringEvent>(queue).Consumes(consumer).Start();

            // Anything taken from Amazon SQS goes to the console
            new SimpleQueueProducer<StringEvent>(client, queueName, serializer).Consumes(new DelegatingConsumer<StringEvent>(@event =>
            {
                Console.WriteLine(@event.Text);
                received++;
                if (received >= sent)
                {
                    block.Set();
                }
            })).Start();

            // Make some messages
            queue.Enqueue(new StringEvent("Test1"));
            queue.Enqueue(new StringEvent("Test2"));
            queue.Enqueue(new StringEvent("Test3"));
            queue.Enqueue(new StringEvent("Test4"));
            queue.Enqueue(new StringEvent("Test5"));
            queue.Enqueue(new StringEvent("Test6"));
            queue.Enqueue(new StringEvent("Test7"));
            queue.Enqueue(new StringEvent("Test8"));
            queue.Enqueue(new StringEvent("Test9"));
            queue.Enqueue(new StringEvent("Test10"));

            block.WaitOne();

            client.DeleteQueue(new DeleteQueueRequest().WithQueueUrl(consumer.QueueUrl));
        }
开发者ID:modulexcite,项目名称:graveyard,代码行数:45,代码来源:SimpleQueueProducerTests.cs


示例20: DataRouterReportQueue

		/// <summary>
		/// Constructor taking the landing zone
		/// </summary>
		public DataRouterReportQueue(string InQueueName, string InLandingZoneTempPath, int InDecimateWaitingCountStart, int InDecimateWaitingCountEnd)
			: base(InQueueName, InLandingZoneTempPath, InDecimateWaitingCountStart, InDecimateWaitingCountEnd)
		{
			AWSCredentials Credentials = new StoredProfileAWSCredentials(Config.Default.AWSProfileName, Config.Default.AWSCredentialsFilepath);

			AmazonSQSConfig SqsConfig = new AmazonSQSConfig
			{
				ServiceURL = Config.Default.AWSSQSServiceURL
			};

			SqsClient = new AmazonSQSClient(Credentials, SqsConfig);

			AmazonS3Config S3Config = new AmazonS3Config
			{
				ServiceURL = Config.Default.AWSS3ServiceURL
			};

			S3Client = new AmazonS3Client(Credentials, S3Config);
		}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:22,代码来源:DataRouterReportQueue.cs



注:本文中的Amazon.SQS.AmazonSQSClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SQS.AmazonSQSConfig类代码示例发布时间:2022-05-24
下一篇:
C# Transfer.TransferUtilityUploadRequest类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap