AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
Namespace: Amazon.SimpleNotificationService.Model
Assembly: AWSSDK.dll
Version: (assembly version)
public class CreateTopicResponse : CreateTopicResult
The CreateTopicResponse type exposes the following members
Name | Description | |
---|---|---|
CreateTopicResponse() |
Name | Type | Description | |
---|---|---|---|
ContentLength | System.Int64 | Inherited from Amazon.Runtime.AmazonWebServiceResponse. | |
CreateTopicResult | Amazon.SimpleNotificationService.Model.CreateTopicResult | Gets and sets the CreateTopicResult property. Represents the output of a CreateTopic operation. | |
HttpStatusCode | System.Net.HttpStatusCode | Inherited from Amazon.Runtime.AmazonWebServiceResponse. | |
ResponseMetadata | Amazon.Runtime.ResponseMetadata | Inherited from Amazon.Runtime.AmazonWebServiceResponse. | |
TopicArn | System.String |
Gets and sets the property TopicArn.
The Amazon Resource Name (ARN) assigned to the created topic. |
This example shows how to create, subscribe to, and publish a topic.
var snsClient = new AmazonSimpleNotificationServiceClient(); var topicRequest = new CreateTopicRequest { Name = "CodingTestResults" }; var topicResponse = snsClient.CreateTopic(topicRequest); var topicAttrRequest = new SetTopicAttributesRequest { TopicArn = topicResponse.TopicArn, AttributeName = "DisplayName", AttributeValue = "Coding Test Results" }; snsClient.SetTopicAttributes(topicAttrRequest); snsClient.Subscribe(new SubscribeRequest { Endpoint = "johndoe@example.com", Protocol = "email", TopicArn = topicResponse.TopicArn }); // Wait for up to 2 minutes for the user to confirm the subscription. DateTime latest = DateTime.Now + TimeSpan.FromMinutes(2); while (DateTime.Now < latest) { var subsRequest = new ListSubscriptionsByTopicRequest { TopicArn = topicResponse.TopicArn }; var subs = snsClient.ListSubscriptionsByTopic(subsRequest).Subscriptions; var sub = subs[0]; if (!string.Equals(sub.SubscriptionArn, "PendingConfirmation", StringComparison.Ordinal)) { break; } // Wait 15 seconds before trying again. System.Threading.Thread.Sleep(TimeSpan.FromSeconds(15)); } snsClient.Publish(new PublishRequest { Subject = "Coding Test Results for " + DateTime.Today.ToShortDateString(), Message = "All of today's coding tests passed.", TopicArn = topicResponse.TopicArn });
.NET Framework:
Supported in: 4.5, 4.0, 3.5
.NET for Windows Store apps:
Supported in: Windows 8.1, Windows 8
.NET for Windows Phone:
Supported in: Windows Phone 8.1, Windows Phone 8