use of com.google.cloud.pubsublite.proto.Topic in project beam by apache.
the class ReadWriteIT method createTopic.
private TopicPath createTopic(ProjectId id) throws Exception {
TopicPath toReturn = TopicPath.newBuilder().setProject(id).setLocation(ZONE).setName(TopicName.of(randomName())).build();
Topic.Builder topic = Topic.newBuilder().setName(toReturn.toString());
topic.getPartitionConfigBuilder().setCount(2).setCapacity(Capacity.newBuilder().setPublishMibPerSec(4).setSubscribeMibPerSec(4));
topic.getRetentionConfigBuilder().setPerPartitionBytes(30 * (1L << 30));
cleanupActions.addLast(() -> {
try (AdminClient client = newAdminClient()) {
client.deleteTopic(toReturn).get();
} catch (Throwable t) {
LOG.error("Failed to clean up topic.", t);
}
});
try (AdminClient client = newAdminClient()) {
client.createTopic(topic.build()).get();
}
return toReturn;
}
Aggregations