当前位置: 首页>>代码示例>>C#>>正文


C# Address.ToSqsQueueName方法代码示例

本文整理汇总了C#中Address.ToSqsQueueName方法的典型用法代码示例。如果您正苦于以下问题:C# Address.ToSqsQueueName方法的具体用法?C# Address.ToSqsQueueName怎么用?C# Address.ToSqsQueueName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Address的用法示例。


在下文中一共展示了Address.ToSqsQueueName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetQueueUrl

		public string GetQueueUrl(Address address)
		{
			string result;
			var addressKey = address.ToString();
			if (!_cache.TryGetValue(addressKey, out result))
			{
				var getQueueUrlResponse = SqsClient.GetQueueUrl(address.ToSqsQueueName(ConnectionConfiguration));
				result = getQueueUrlResponse.QueueUrl;
				_cache.AddOrUpdate(addressKey, result, (x, y) => result);
			}
			return result;
		}
开发者ID:GCMGrosvenor,项目名称:NServiceBus.AmazonSQS-1,代码行数:12,代码来源:SqsQueueUrlCache.cs

示例2: Init

        public void Init(Address address, TransactionSettings transactionSettings, Func<TransportMessage, bool> tryProcessMessage, Action<TransportMessage, Exception> endProcessMessage)
        {
            var getQueueUrlRequest = new GetQueueUrlRequest(address.ToSqsQueueName(ConnectionConfiguration));
            GetQueueUrlResponse getQueueUrlResponse;
            try
            {
                getQueueUrlResponse = SqsClient.GetQueueUrl(getQueueUrlRequest);
            }
            catch (Exception ex)
            {
                Logger.Error("Exception thrown from GetQueueUrl.", ex);
                throw;
            }
            _queueUrl = getQueueUrlResponse.QueueUrl;

			if (_purgeOnStartup)
            {
                // SQS only allows purging a queue once every 60 seconds or so. 
                // If you try to purge a queue twice in relatively quick succession,
                // PurgeQueueInProgressException will be thrown. 
                // This will happen if you are trying to start an endpoint twice or more
                // in that time. 
                try
                {
                    SqsClient.PurgeQueue(_queueUrl);
                }
                catch (PurgeQueueInProgressException ex)
                {
                    Logger.Warn("Multiple queue purges within 60 seconds are not permitted by SQS.", ex);
                }
                catch (Exception ex)
                {
                    Logger.Error("Exception thrown from PurgeQueue.", ex);
                    throw;
                }
            }

            _tryProcessMessage = tryProcessMessage;
            _endProcessMessage = endProcessMessage;

			if (transactionSettings != null)
				_isTransactional = transactionSettings.IsTransactional;
			else
				_isTransactional = true;
        }
开发者ID:GCMGrosvenor,项目名称:NServiceBus.AmazonSQS-1,代码行数:45,代码来源:SqsDequeueStrategy.cs

示例3: CreateQueueIfNecessary

        public void CreateQueueIfNecessary(Address address, string account)
        {
            try
            {
                var sqsRequest = new CreateQueueRequest
                {
                    QueueName = address.ToSqsQueueName(ConnectionConfiguration),
                };
                Logger.Info(String.Format("Creating SQS Queue with name \"{0}\" for address \"{1}\".", sqsRequest.QueueName, address));
                var createQueueResponse = SqsClient.CreateQueue(sqsRequest);

                // Set the queue attributes in a separate call. 
                // If you call CreateQueue with a queue name that already exists, and with a different
                // value for MessageRetentionPeriod, the service throws. This will happen if you 
                // change the MaxTTLDays configuration property. 
                var sqsAttributesRequest = new SetQueueAttributesRequest
                {
                    QueueUrl = createQueueResponse.QueueUrl
                };
                sqsAttributesRequest.Attributes.Add(QueueAttributeName.MessageRetentionPeriod,
                    ((int) (TimeSpan.FromDays(ConnectionConfiguration.MaxTTLDays).TotalSeconds)).ToString());

                SqsClient.SetQueueAttributes(sqsAttributesRequest);

                if (!string.IsNullOrEmpty(ConnectionConfiguration.S3BucketForLargeMessages))
                {
                    // determine if the configured bucket exists; create it if it doesn't
                    var listBucketsResponse = S3Client.ListBuckets(new ListBucketsRequest());
                    var bucketExists = listBucketsResponse.Buckets.Any(x => x.BucketName.ToLower() == ConnectionConfiguration.S3BucketForLargeMessages.ToLower());
                    if (!bucketExists)
                    {
                        S3Client.PutBucket(new PutBucketRequest
                        {
                            BucketName = ConnectionConfiguration.S3BucketForLargeMessages
                        });
                    }

                    S3Client.PutLifecycleConfiguration(new PutLifecycleConfigurationRequest
                    {
                        BucketName = ConnectionConfiguration.S3BucketForLargeMessages,
                        Configuration = new LifecycleConfiguration
                        {
                            Rules = new List<LifecycleRule>
                            {
                                new LifecycleRule
                                {
                                    Id = "NServiceBus.SQS.DeleteMessageBodies",
                                    Prefix = ConnectionConfiguration.S3KeyPrefix,
                                    Status = LifecycleRuleStatus.Enabled,
                                    Expiration = new LifecycleRuleExpiration
                                    {
                                        Days = ConnectionConfiguration.MaxTTLDays
                                    }
                                }
                            }
                        }
                    });
                }
            }
            catch (Exception e)
            {
                Logger.Error("Exception from CreateQueueIfNecessary.", e);
                throw;
            }
        }
开发者ID:GCMGrosvenor,项目名称:NServiceBus.AmazonSQS-1,代码行数:65,代码来源:SqsQueueCreator.cs


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