use of com.google.cloud.spring.pubsub.core.PubSubException in project spring-cloud-gcp by GoogleCloudPlatform.
the class DefaultPublisherFactory method createPublisher.
/**
* Creates a {@link Publisher} for a given topic.
*
* <p></p>Configuration precedence:
* <ol>
* <li>modifications applied by the factory customizers
* <li>{@code spring.cloud.gcp.pubsub.publisher} configuration options
* <li>client library defaults
*</ol>
*
* @param topic destination topic
* @return fully configured publisher
*/
@Override
public Publisher createPublisher(String topic) {
try {
Publisher.Builder publisherBuilder = Publisher.newBuilder(PubSubTopicUtils.toTopicName(topic, this.projectId));
applyPublisherSettings(publisherBuilder);
applyCustomizers(publisherBuilder, topic);
return publisherBuilder.build();
} catch (IOException ioe) {
throw new PubSubException("An error creating the Google Cloud Pub/Sub publisher " + "occurred.", ioe);
}
}
Aggregations