use of com.google.cloud.pubsublite.proto.Subscription in project beam by apache.
the class ReadWriteIT method createSubscription.
private SubscriptionPath createSubscription(TopicPath topic) throws Exception {
SubscriptionPath toReturn = SubscriptionPath.newBuilder().setProject(topic.project()).setLocation(ZONE).setName(SubscriptionName.of(randomName())).build();
Subscription.Builder subscription = Subscription.newBuilder().setName(toReturn.toString());
subscription.getDeliveryConfigBuilder().setDeliveryRequirement(DeliveryRequirement.DELIVER_IMMEDIATELY);
subscription.setTopic(topic.toString());
cleanupActions.addLast(() -> {
try (AdminClient client = newAdminClient()) {
client.deleteSubscription(toReturn).get();
} catch (Throwable t) {
LOG.error("Failed to clean up subscription.", t);
}
});
try (AdminClient client = newAdminClient()) {
client.createSubscription(subscription.build(), BacklogLocation.BEGINNING).get();
}
return toReturn;
}
Aggregations