public class PubsubJsonClient extends PubsubClient
PubsubClient.OutgoingMessage, PubsubClient.ProjectPath, PubsubClient.PubsubClientFactory, PubsubClient.SubscriptionPath, PubsubClient.TopicPath
Modifier and Type | Field and Description |
---|---|
static PubsubClient.PubsubClientFactory |
FACTORY
Factory for creating Pubsub clients using Json 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() |
void |
createSubscription(PubsubClient.TopicPath topic,
PubsubClient.SubscriptionPath subscription,
int ackDeadlineSeconds)
Create
subscription to topic . |
void |
createTopic(PubsubClient.TopicPath topic)
Create
topic . |
void |
deleteSubscription(PubsubClient.SubscriptionPath subscription)
Delete
subscription . |
void |
deleteTopic(PubsubClient.TopicPath topic) |
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<org.apache.beam.sdk.io.gcp.pubsub.PubsubClient.IncomingMessage> |
pull(long requestTimeMsSinceEpoch,
PubsubClient.SubscriptionPath subscription,
int batchSize,
boolean returnImmediately)
Request the next batch of up to
batchSize messages from subscription . |
createRandomSubscription, extractTimestamp, projectPathFromId, projectPathFromPath, 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<org.apache.beam.sdk.io.gcp.pubsub.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 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