public class Topic extends TopicInfo
Topic adds a layer of service-related functionality over TopicInfo. Objects of
this class are immutable. To get a Topic object with the most recent information use
reload() or reloadAsync().| Modifier and Type | Class and Description |
|---|---|
static class |
Topic.Builder
A builder for
Topic objects. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
delete()
Deletes this topic.
|
Future<Boolean> |
deleteAsync()
Sends a request for deleting this topic.
|
boolean |
equals(Object obj) |
int |
hashCode() |
Page<SubscriptionId> |
listSubscriptions(PubSub.ListOption... options)
Lists the identities of the subscriptions for this topic.
|
Future<AsyncPage<SubscriptionId>> |
listSubscriptionsAsync(PubSub.ListOption... options)
Sends a request for listing the identities of subscriptions for this topic.
|
List<String> |
publish(Iterable<Message> messages)
Publishes a number of messages to this topic.
|
String |
publish(Message message)
Publishes a message to this topic.
|
List<String> |
publish(Message message,
Message... messages)
Publishes a number of messages to this topic.
|
Future<List<String>> |
publishAsync(Iterable<Message> messages)
Sends a request to publish a number of messages to this topic.
|
Future<String> |
publishAsync(Message message)
Sends a request for publishing a message to the this topic.
|
Future<List<String>> |
publishAsync(Message message,
Message... messages)
Sends a request to publish a number of messages to this topic.
|
PubSub |
pubSub()
Returns the topic's
PubSub object used to issue requests. |
Topic |
reload()
Fetches current topic's latest information.
|
Future<Topic> |
reloadAsync()
Sends a request to fetch current topic's latest information.
|
Topic.Builder |
toBuilder()
Returns a builder for the topic object.
|
public Topic.Builder toBuilder()
TopicInfopublic PubSub pubSub()
PubSub object used to issue requests.public boolean delete()
true if the topic was deleted, false if it was not foundPubSubException - upon failurepublic Future<Boolean> deleteAsync()
Future object to consume
the result. Future.get() returns true if the topic was deleted, false
if it was not found.PubSubException - upon failurepublic Topic reload()
null if the topic does not exist.Topic object with latest information or null if not foundPubSubException - upon failurepublic Future<Topic> reloadAsync()
Future object to consume the result. Future.get() returns a Topic
object with latest information or null if not found.PubSubException - upon failurepublic String publish(Message message)
message - the message to publishPubSubException - upon failure, if the topic does not exist or if the message has empty
payload and no attributespublic Future<String> publishAsync(Message message)
Future object to consume the result. Future.get() returns a service-generated
id for the published message. Service-generated ids are guaranteed to be unique within the
topic.message - the message to publishFuture for the unique service-generated id for the messagepublic List<String> publish(Message message, Message... messages)
message - the first message to publishmessages - other messages to publishPubSubException - upon failure, if the topic does not exist or if one of the messages has
empty payload and no attributespublic Future<List<String>> publishAsync(Message message, Message... messages)
Future object to consume the result. Future.get() returns a list of
service-generated ids for the published messages. Service-generated ids are guaranteed to be
unique within the topic.message - the first message to publishmessages - other messages to publishFuture for the unique, service-generated ids. Ids are in the same order as
the messages.public List<String> publish(Iterable<Message> messages)
messages - the messages to publishPubSubException - upon failure, if the topic does not exist or if one of the messages has
empty payload and no attributespublic Future<List<String>> publishAsync(Iterable<Message> messages)
Future object to consume the result. Future.get() returns a list of
service-generated ids for the published messages. Service-generated ids are guaranteed to be
unique within the topic.messages - the messages to publishFuture for the unique, service-generated ids. Ids are in the same order as
the messages.public Page<SubscriptionId> listSubscriptions(PubSub.ListOption... options)
Page
object that can be used to consume paginated results. Use PubSub.ListOption to specify the
page size or the page token from which to start listing subscriptions.PubSubException - upon failurepublic Future<AsyncPage<SubscriptionId>> listSubscriptionsAsync(PubSub.ListOption... options)
Future object to consume the result. Future.get() returns an
AsyncPage object that can be used to asynchronously handle paginated results. Use
PubSub.ListOption to specify the page size or the page token from which to start listing
subscriptions.Copyright © 2016 Google. All rights reserved.