public class PubsubGrpcClient extends PubsubClient
PubsubClient.IncomingMessage, PubsubClient.OutgoingMessage, PubsubClient.ProjectPath, PubsubClient.PubsubClientFactory, PubsubClient.SchemaPath, PubsubClient.SubscriptionPath, PubsubClient.TopicPath
Modifier and Type | Field and Description |
---|---|
static PubsubClient.PubsubClientFactory |
FACTORY
Factory for creating Pubsub clients using gRPC transport.
|
Modifier and Type | Method and Description |
---|---|
int |
ackDeadlineSeconds(PubsubClient.SubscriptionPath subscription)
Return the ack deadline, in seconds, for
subscription . |
void |
acknowledge(PubsubClient.SubscriptionPath subscription,
java.util.List<java.lang.String> ackIds)
Acknowldege messages from
subscription with ackIds . |
void |
close()
Gracefully close the underlying netty channel.
|
void |
createSchema(PubsubClient.SchemaPath schemaPath,
java.lang.String schemaContent,
com.google.pubsub.v1.Schema.Type type)
Create
Schema from Schema definition content. |
void |
createSubscription(PubsubClient.TopicPath topic,
PubsubClient.SubscriptionPath subscription,
int ackDeadlineSeconds)
Create
subscription to topic . |
void |
createTopic(PubsubClient.TopicPath topic)
Create
topic . |
void |
createTopic(PubsubClient.TopicPath topic,
PubsubClient.SchemaPath schema)
Create {link TopicPath} with
PubsubClient.SchemaPath . |
void |
deleteSchema(PubsubClient.SchemaPath schemaPath)
Delete
SchemaPath . |
void |
deleteSubscription(PubsubClient.SubscriptionPath subscription)
Delete
subscription . |
void |
deleteTopic(PubsubClient.TopicPath topic) |
Schema |
getSchema(PubsubClient.SchemaPath schemaPath)
Return a Beam
Schema from the Pub/Sub schema resource, if exists. |
PubsubClient.SchemaPath |
getSchemaPath(PubsubClient.TopicPath topicPath)
Return
SchemaPath from TopicPath if exists. |
boolean |
isEOF()
Return true if
PubsubClient.pull(long, org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath, int, boolean) will always return empty list. |
java.util.List<PubsubClient.SubscriptionPath> |
listSubscriptions(PubsubClient.ProjectPath project,
PubsubClient.TopicPath topic)
Return a list of subscriptions for
topic in project . |
java.util.List<PubsubClient.TopicPath> |
listTopics(PubsubClient.ProjectPath project)
Return a list of topics for
project . |
void |
modifyAckDeadline(PubsubClient.SubscriptionPath subscription,
java.util.List<java.lang.String> ackIds,
int deadlineSeconds)
Modify the ack deadline for messages from
subscription with ackIds to be deadlineSeconds from now. |
int |
publish(PubsubClient.TopicPath topic,
java.util.List<PubsubClient.OutgoingMessage> outgoingMessages)
Publish
outgoingMessages to Pubsub topic . |
java.util.List<PubsubClient.IncomingMessage> |
pull(long requestTimeMsSinceEpoch,
PubsubClient.SubscriptionPath subscription,
int batchSize,
boolean returnImmediately)
Request the next batch of up to
batchSize messages from subscription . |
createRandomSubscription, extractTimestampAttribute, parseTimestampAsMsSinceEpoch, projectPathFromId, projectPathFromPath, schemaPathFromId, schemaPathFromPath, subscriptionPathFromName, subscriptionPathFromPath, topicPathFromName, topicPathFromPath
public static final PubsubClient.PubsubClientFactory FACTORY
public void close()
public int publish(PubsubClient.TopicPath topic, java.util.List<PubsubClient.OutgoingMessage> outgoingMessages) throws java.io.IOException
PubsubClient
outgoingMessages
to Pubsub topic
. Return number of messages published.publish
in class PubsubClient
java.io.IOException
public java.util.List<PubsubClient.IncomingMessage> pull(long requestTimeMsSinceEpoch, PubsubClient.SubscriptionPath subscription, int batchSize, boolean returnImmediately) throws java.io.IOException
PubsubClient
batchSize
messages from subscription
. Return
the received messages, or empty collection if none were available. Does not wait for messages
to arrive if returnImmediately
is true. Returned messages will record their
request time as requestTimeMsSinceEpoch
.pull
in class PubsubClient
java.io.IOException
public void acknowledge(PubsubClient.SubscriptionPath subscription, java.util.List<java.lang.String> ackIds) throws java.io.IOException
PubsubClient
subscription
with ackIds
.acknowledge
in class PubsubClient
java.io.IOException
public void modifyAckDeadline(PubsubClient.SubscriptionPath subscription, java.util.List<java.lang.String> ackIds, int deadlineSeconds) throws java.io.IOException
PubsubClient
subscription
with ackIds
to be deadlineSeconds
from now.modifyAckDeadline
in class PubsubClient
java.io.IOException
public void createTopic(PubsubClient.TopicPath topic) throws java.io.IOException
PubsubClient
topic
.createTopic
in class PubsubClient
java.io.IOException
public void createTopic(PubsubClient.TopicPath topic, PubsubClient.SchemaPath schema) throws java.io.IOException
PubsubClient
PubsubClient.SchemaPath
.createTopic
in class PubsubClient
java.io.IOException
public void deleteTopic(PubsubClient.TopicPath topic) throws java.io.IOException
deleteTopic
in class PubsubClient
java.io.IOException
public java.util.List<PubsubClient.TopicPath> listTopics(PubsubClient.ProjectPath project) throws java.io.IOException
PubsubClient
project
.listTopics
in class PubsubClient
java.io.IOException
public void createSubscription(PubsubClient.TopicPath topic, PubsubClient.SubscriptionPath subscription, int ackDeadlineSeconds) throws java.io.IOException
PubsubClient
subscription
to topic
.createSubscription
in class PubsubClient
java.io.IOException
public void deleteSubscription(PubsubClient.SubscriptionPath subscription) throws java.io.IOException
PubsubClient
subscription
.deleteSubscription
in class PubsubClient
java.io.IOException
public java.util.List<PubsubClient.SubscriptionPath> listSubscriptions(PubsubClient.ProjectPath project, PubsubClient.TopicPath topic) throws java.io.IOException
PubsubClient
topic
in project
.listSubscriptions
in class PubsubClient
java.io.IOException
public int ackDeadlineSeconds(PubsubClient.SubscriptionPath subscription) throws java.io.IOException
PubsubClient
subscription
.ackDeadlineSeconds
in class PubsubClient
java.io.IOException
public boolean isEOF()
PubsubClient
PubsubClient.pull(long, org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.SubscriptionPath, int, boolean)
will always return empty list. Actual clients will
return false. Test clients may return true to signal that all expected
messages have been pulled and the test may complete.isEOF
in class PubsubClient
public void createSchema(PubsubClient.SchemaPath schemaPath, java.lang.String schemaContent, com.google.pubsub.v1.Schema.Type type) throws java.io.IOException
Schema
from Schema definition content.createSchema
in class PubsubClient
java.io.IOException
public void deleteSchema(PubsubClient.SchemaPath schemaPath) throws java.io.IOException
SchemaPath
.deleteSchema
in class PubsubClient
java.io.IOException
public PubsubClient.SchemaPath getSchemaPath(PubsubClient.TopicPath topicPath) throws java.io.IOException
SchemaPath
from TopicPath
if exists.getSchemaPath
in class PubsubClient
java.io.IOException
public Schema getSchema(PubsubClient.SchemaPath schemaPath) throws java.io.IOException
Schema
from the Pub/Sub schema resource, if exists.getSchema
in class PubsubClient
java.io.IOException