@java.lang.Override public com.google.pubsub.v1.PublishResponse publish(com.google.pubsub.v1.PublishRequest request) { return blockingUnaryCall( getChannel().newCall(METHOD_PUBLISH, getCallOptions()), request); }
@Override public List<TopicPath> listTopics(ProjectPath project) throws IOException { ListTopicsRequest.Builder request = ListTopicsRequest.newBuilder().setProject(project.getPath()).setPageSize(LIST_BATCH_SIZE); ListTopicsResponse response = publisherStub().listTopics(request.build()); if (response.getTopicsCount() == 0) { return ImmutableList.of(); } List<TopicPath> topics = new ArrayList<>(response.getTopicsCount()); while (true) { for (Topic topic : response.getTopicsList()) { topics.add(topicPathFromPath(topic.getName())); } if (response.getNextPageToken().isEmpty()) { break; } request.setPageToken(response.getNextPageToken()); response = publisherStub().listTopics(request.build()); } return topics; }
@Override public int publish(TopicPath topic, List<OutgoingMessage> outgoingMessages) throws IOException { PublishRequest.Builder request = PublishRequest.newBuilder().setTopic(topic.getPath()); for (OutgoingMessage outgoingMessage : outgoingMessages) { PubsubMessage.Builder message = PubsubMessage.newBuilder().setData(ByteString.copyFrom(outgoingMessage.elementBytes)); if (outgoingMessage.attributes != null) { message.putAllAttributes(outgoingMessage.attributes); } if (timestampAttribute != null) { message .getMutableAttributes() .put(timestampAttribute, String.valueOf(outgoingMessage.timestampMsSinceEpoch)); } if (idAttribute != null && !Strings.isNullOrEmpty(outgoingMessage.recordId)) { message.getMutableAttributes().put(idAttribute, outgoingMessage.recordId); } request.addMessages(message); } PublishResponse response = publisherStub().publish(request.build()); return response.getMessageIdsCount(); }
/** * * * <pre> * Lists the names of the snapshots on this topic. Snapshots are used in * <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a> * operations, which allow * you to manage message acknowledgments in bulk. That is, you can set the * acknowledgment state of messages in an existing subscription to the state * captured by a snapshot.<br><br> * <b>BETA:</b> This feature is part of a beta release. This API might be * changed in backward-incompatible ways and is not recommended for production * use. It is not subject to any SLA or deprecation policy. * </pre> */ public com.google.pubsub.v1.ListTopicSnapshotsResponse listTopicSnapshots( com.google.pubsub.v1.ListTopicSnapshotsRequest request) { return blockingUnaryCall( getChannel(), getListTopicSnapshotsMethodHelper(), getCallOptions(), request); }
/** * * * <pre> * Deletes the topic with the given name. Returns `NOT_FOUND` if the topic * does not exist. After a topic is deleted, a new topic may be created with * the same name; this is an entirely new topic with none of the old * configuration or subscriptions. Existing subscriptions to this topic are * not deleted, but their `topic` field is set to `_deleted-topic_`. * </pre> */ public com.google.protobuf.Empty deleteTopic(com.google.pubsub.v1.DeleteTopicRequest request) { return blockingUnaryCall( getChannel(), getDeleteTopicMethodHelper(), getCallOptions(), request); } }
/** * <pre> * Deletes the topic with the given name. Returns `NOT_FOUND` if the topic * does not exist. After a topic is deleted, a new topic may be created with * the same name; this is an entirely new topic with none of the old * configuration or subscriptions. Existing subscriptions to this topic are * not deleted, but their `topic` field is set to `_deleted-topic_`. * </pre> */ public com.google.protobuf.Empty deleteTopic(com.google.pubsub.v1.DeleteTopicRequest request) { return blockingUnaryCall( getChannel(), METHOD_DELETE_TOPIC, getCallOptions(), request); } }
public static PublisherBlockingStub newBlockingStub( io.grpc.Channel channel) { return new PublisherBlockingStub(channel); }
/** * * * <pre> * Creates the given topic with the given name. See the * <a href="https://cloud.google.com/pubsub/docs/admin#resource_names"> * resource name rules</a>. * </pre> */ public com.google.pubsub.v1.Topic createTopic(com.google.pubsub.v1.Topic request) { return blockingUnaryCall( getChannel(), getCreateTopicMethodHelper(), getCallOptions(), request); }
/** * Creates a new blocking-style stub that supports unary and streaming output calls on the service */ public static PublisherBlockingStub newBlockingStub(io.grpc.Channel channel) { return new PublisherBlockingStub(channel); }
/** * Creates a new blocking-style stub that supports unary and streaming output calls on the service */ public static PublisherBlockingStub newBlockingStub( io.grpc.Channel channel) { return new PublisherBlockingStub(channel); }
@Override public void createTopic(TopicPath topic) throws IOException { Topic request = Topic.newBuilder().setName(topic.getPath()).build(); publisherStub().createTopic(request); // ignore Topic result. }
/** Return a stub for making a publish request with a timeout. */ private PublisherBlockingStub publisherStub() throws IOException { if (cachedPublisherStub == null) { cachedPublisherStub = PublisherGrpc.newBlockingStub(newChannel()); } return cachedPublisherStub.withDeadlineAfter(timeoutSec, TimeUnit.SECONDS); }
@java.lang.Override protected PublisherBlockingStub build( io.grpc.Channel channel, io.grpc.CallOptions callOptions) { return new PublisherBlockingStub(channel, callOptions); }
@java.lang.Override protected PublisherBlockingStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { return new PublisherBlockingStub(channel, callOptions); }
/** * * * <pre> * Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic * does not exist. * </pre> */ public com.google.pubsub.v1.PublishResponse publish( com.google.pubsub.v1.PublishRequest request) { return blockingUnaryCall(getChannel(), getPublishMethodHelper(), getCallOptions(), request); }
/** * <pre> * Gets the configuration of a topic. * </pre> */ public com.google.pubsub.v1.Topic getTopic(com.google.pubsub.v1.GetTopicRequest request) { return blockingUnaryCall( getChannel(), METHOD_GET_TOPIC, getCallOptions(), request); }
/** * * * <pre> * Lists matching topics. * </pre> */ public com.google.pubsub.v1.ListTopicsResponse listTopics( com.google.pubsub.v1.ListTopicsRequest request) { return blockingUnaryCall( getChannel(), getListTopicsMethodHelper(), getCallOptions(), request); }
/** * * * <pre> * Updates an existing topic. Note that certain properties of a * topic are not modifiable. * </pre> */ public com.google.pubsub.v1.Topic updateTopic(com.google.pubsub.v1.UpdateTopicRequest request) { return blockingUnaryCall( getChannel(), getUpdateTopicMethodHelper(), getCallOptions(), request); }
/** * <pre> * Lists the name of the subscriptions for this topic. * </pre> */ public com.google.pubsub.v1.ListTopicSubscriptionsResponse listTopicSubscriptions(com.google.pubsub.v1.ListTopicSubscriptionsRequest request) { return blockingUnaryCall( getChannel(), METHOD_LIST_TOPIC_SUBSCRIPTIONS, getCallOptions(), request); }
/** * <pre> * Lists matching topics. * </pre> */ public com.google.pubsub.v1.ListTopicsResponse listTopics(com.google.pubsub.v1.ListTopicsRequest request) { return blockingUnaryCall( getChannel(), METHOD_LIST_TOPICS, getCallOptions(), request); }