本文整理汇总了C#中Amazon.SQS.AmazonSQSClient.DeleteQueue方法的典型用法代码示例。如果您正苦于以下问题:C# AmazonSQSClient.DeleteQueue方法的具体用法?C# AmazonSQSClient.DeleteQueue怎么用?C# AmazonSQSClient.DeleteQueue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Amazon.SQS.AmazonSQSClient
的用法示例。
在下文中一共展示了AmazonSQSClient.DeleteQueue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
示例2: DeleteQueueByQueueUrl
public static void DeleteQueueByQueueUrl(string queueUrl)
{
using (var client = new AmazonSQSClient(Settings.AccessKey, Settings.Secret))
{
client.DeleteQueue(queueUrl);
}
}
示例3: DeleteQueue
public virtual void DeleteQueue(AmazonSQSClient sqsClient, string queueUrl)
{
var deleteQueueRequest = new DeleteQueueRequest
{
QueueUrl = queueUrl
};
// Delete the queue
sqsClient.DeleteQueue(deleteQueueRequest);
}
示例4: 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);
}
}
}
示例5: 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));
}
示例6: 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));
}
示例7: DeleteQueue
public void DeleteQueue()
{
using (var client = new AmazonSQSClient(_accessKeyId, _secretAccessKey, _regionEndpoint))
{
client.DeleteQueue(_queueUrl);
}
}
示例8: DeleteQueue
public void DeleteQueue()
{
using (var client = new AmazonSQSClient(_accessKeyId, _secretAccessKey, _amazonSqsConfig))
{
client.DeleteQueue(_queueUrl);
}
}
示例9: SetQueueConfigurationTests
public void SetQueueConfigurationTests()
{
var filterRule = new FilterRule("Prefix", "test/");
var s3Config = new AmazonS3Config();
using (var s3Client = new AmazonS3Client(s3Config))
using (var sqsClient = new AmazonSQSClient())
{
var createResponse = sqsClient.CreateQueue("events-test-" + DateTime.Now.Ticks);
var bucketName = S3TestUtils.CreateBucket(s3Client);
try
{
var queueArn = sqsClient.AuthorizeS3ToSendMessage(createResponse.QueueUrl, bucketName);
PutBucketNotificationRequest putRequest = new PutBucketNotificationRequest
{
BucketName = bucketName,
QueueConfigurations = new List<QueueConfiguration>
{
new QueueConfiguration
{
Id = "the-queue-test",
Queue = queueArn,
Events = {EventType.ObjectCreatedPut},
Filter = new Filter
{
S3KeyFilter = new S3KeyFilter
{
FilterRules = new List<FilterRule>
{
filterRule
}
}
}
}
}
};
s3Client.PutBucketNotification(putRequest);
var getResponse = s3Client.GetBucketNotification(bucketName);
Assert.AreEqual(1, getResponse.QueueConfigurations.Count);
Assert.AreEqual(1, getResponse.QueueConfigurations[0].Events.Count);
Assert.AreEqual(EventType.ObjectCreatedPut, getResponse.QueueConfigurations[0].Events[0]);
Assert.IsNotNull(getResponse.QueueConfigurations[0].Filter);
Assert.IsNotNull(getResponse.QueueConfigurations[0].Filter.S3KeyFilter);
Assert.IsNotNull(getResponse.QueueConfigurations[0].Filter.S3KeyFilter.FilterRules);
Assert.AreEqual(1, getResponse.QueueConfigurations[0].Filter.S3KeyFilter.FilterRules.Count);
Assert.AreEqual(filterRule.Name, getResponse.QueueConfigurations[0].Filter.S3KeyFilter.FilterRules[0].Name);
Assert.AreEqual(filterRule.Value, getResponse.QueueConfigurations[0].Filter.S3KeyFilter.FilterRules[0].Value);
Assert.AreEqual("the-queue-test", getResponse.QueueConfigurations[0].Id);
Assert.AreEqual(queueArn, getResponse.QueueConfigurations[0].Queue);
// Purge queue to remove test message sent configuration was setup.
sqsClient.PurgeQueue(createResponse.QueueUrl);
Thread.Sleep(TimeSpan.FromSeconds(1));
var putObjectRequest = new PutObjectRequest
{
BucketName = bucketName,
Key = "test/data.txt",
ContentBody = "Important Data"
};
s3Client.PutObject(putObjectRequest);
string messageBody = null;
for (int i = 0; i < 5 && messageBody == null; i++)
{
var receiveResponse = sqsClient.ReceiveMessage(new ReceiveMessageRequest { QueueUrl = createResponse.QueueUrl, WaitTimeSeconds = 20 });
if (receiveResponse.Messages.Count != 0)
{
messageBody = receiveResponse.Messages[0].Body;
}
}
var evnt = S3EventNotification.ParseJson(messageBody);
Assert.AreEqual(1, evnt.Records.Count);
Assert.AreEqual(putObjectRequest.BucketName, evnt.Records[0].S3.Bucket.Name);
Assert.AreEqual(putObjectRequest.Key, evnt.Records[0].S3.Object.Key);
Assert.AreEqual(putObjectRequest.ContentBody.Length, evnt.Records[0].S3.Object.Size);
}
finally
{
sqsClient.DeleteQueue(createResponse.QueueUrl);
AmazonS3Util.DeleteS3BucketWithObjects(s3Client, bucketName);
}
}
}
示例10: SQSDeleteQueue
public static void SQSDeleteQueue()
{
#region SQSDeleteQueue
var client = new AmazonSQSClient();
var request = new DeleteQueueRequest
{
QueueUrl = "https://sqs.us-east-1.amazonaws.com/80398EXAMPLE/MyTestQueue"
};
client.DeleteQueue(request);
#endregion
}