software.amazon.awssdk.services.sns.model.CreateTopicResponse Java Examples

The following examples show how to use software.amazon.awssdk.services.sns.model.CreateTopicResponse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SnsConnector.java    From smallrye-reactive-messaging with Apache License 2.0 6 votes vote down vote up
/**
 * Send message to the SNS Topic.
 *
 * @param message Message to be sent, must not be {@code null}
 * @return the CompletionStage of sending message.
 */
private CompletionStage<Message<?>> send(Message<?> message, String topic, String snsUrl, boolean mock) {
    SnsClientConfig clientConfig = new SnsClientConfig(snsUrl, mock);
    SnsAsyncClient client = SnsClientManager.get().getAsyncClient(clientConfig);

    CreateTopicRequest topicCreationRequest = CreateTopicRequest.builder().name(topic).build();
    return client.createTopic(topicCreationRequest)
            .thenApply(CreateTopicResponse::topicArn)
            .thenCompose(arn -> client.publish(PublishRequest
                    .builder()
                    .topicArn(arn)
                    .message((String) message.getPayload())
                    .build()))
            .thenApply(resp -> {
                log.successfullySend(resp.messageId());
                return message;
            });
}
 
Example #2
Source File: CreateTopic.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static String createSNSTopic(SnsClient snsClient, String topicName ) {

        CreateTopicResponse result = null;
        try {
            CreateTopicRequest request = CreateTopicRequest.builder()
                    .name(topicName)
                    .build();

            result = snsClient.createTopic(request);
            return result.topicArn();
        } catch (SnsException e) {

            System.err.println(e.awsErrorDetails().errorMessage());
            System.exit(1);
        }
        return "";
        //snippet-end:[sns.java2.CreateTopic.main]
    }
 
Example #3
Source File: SnsManager.java    From quarkus with Apache License 2.0 4 votes vote down vote up
public void createTopic(String topicName) {
    CreateTopicResponse topic = sync.createTopic(t -> t.name(topicName));
    topics.put(topicName, topic.topicArn());
}