private void setupPubsubTopic(String topic) throws IOException { if (pubsubClient == null) { pubsubClient = Transport.newPubsubClient(options).build(); } if (executeNullIfNotFound(pubsubClient.projects().topics().get(topic)) == null) { pubsubClient.projects().topics().create(topic, new Topic().setName(topic)).execute(); } }
/** * Deletes the Google Cloud Pub/Sub topic. * * @throws IOException if there is a problem deleting the Pub/Sub topic */ private void deletePubsubTopic(String topic) throws IOException { if (pubsubClient == null) { pubsubClient = Transport.newPubsubClient(options).build(); } if (executeNullIfNotFound(pubsubClient.projects().topics().get(topic)) != null) { pubsubClient.projects().topics().delete(topic).execute(); } }