Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient.PublishAsync C# (CSharp) Метод

PublishAsync() публичный Метод

Initiates the asynchronous execution of the Publish operation.
public PublishAsync ( PublishRequest request, System cancellationToken = default(CancellationToken) ) : Task
request PublishRequest Container for the necessary parameters to execute the Publish operation.
cancellationToken System /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. ///
Результат Task
        public Task<PublishResponse> PublishAsync(PublishRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new PublishRequestMarshaller();
            var unmarshaller = PublishResponseUnmarshaller.Instance;

            return InvokeAsync<PublishRequest,PublishResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }

Same methods

AmazonSimpleNotificationServiceClient::PublishAsync ( string topicArn, string message, System cancellationToken = default(CancellationToken) ) : Task
AmazonSimpleNotificationServiceClient::PublishAsync ( string topicArn, string message, string subject, System cancellationToken = default(CancellationToken) ) : Task
AmazonSimpleNotificationServiceClient::PublishAsync ( PublishRequest request, PublishResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void
AmazonSimpleNotificationServiceClient::PublishAsync ( string topicArn, string message, PublishResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void
AmazonSimpleNotificationServiceClient::PublishAsync ( string topicArn, string message, string subject, PublishResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void

Usage Example

Пример #1
0
 /// <summary>
 /// returns nothing on error
 /// </summary>
 public string PublishRawMessage(string topicArn, string rawMessage)
 {
     try {
         using (var client = new AmazonSimpleNotificationServiceClient(this.AwsCredentials, this.AwsRegion)) {
             var pr = new PublishRequest();
             pr.TopicArn = topicArn;
             pr.Message  = rawMessage;
             var t = client.PublishAsync(pr);
             t.Wait();
             if (t.IsCompleted && t.Result is object)
             {
                 Trace.TraceInformation($"Outgoing SNS-Message for Topic '{topicArn}' Msg-ID: {t.Result.MessageId}");
                 return(t.Result.MessageId);
             }
             else
             {
                 Trace.TraceError($"Publish SNS-Message for Topic '{topicArn}' FAILED: AWS responded non-success");
                 return(null);
             }
         }
     }
     catch (Exception ex) {
         Trace.TraceError($"Publish SNS-Message for Topic '{topicArn}' EXCEPTION: {ex.Message}");
         return(null);
     }
 }
All Usage Examples Of Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient::PublishAsync
AmazonSimpleNotificationServiceClient