public interface Subscriber
Modifier and Type | Method and Description |
---|---|
void |
asyncCloseSubscription(com.google.protobuf.ByteString topic,
com.google.protobuf.ByteString subscriberId,
Callback<Void> callback,
Object context)
Closes all of the client side cached data for this subscription without
actually sending an unsubscribe request to the server.
|
void |
asyncSubscribe(com.google.protobuf.ByteString topic,
com.google.protobuf.ByteString subscriberId,
PubSubProtocol.SubscribeRequest.CreateOrAttach mode,
Callback<Void> callback,
Object context)
Subscribe to the given topic asynchronously for the inputted subscriberId
disregarding if the topic has been created yet or not.
|
void |
asyncSubscribe(com.google.protobuf.ByteString topic,
com.google.protobuf.ByteString subscriberId,
PubSubProtocol.SubscriptionOptions options,
Callback<Void> callback,
Object context)
Subscribe to the given topic asynchronously for the inputted subscriberId.
|
void |
asyncUnsubscribe(com.google.protobuf.ByteString topic,
com.google.protobuf.ByteString subscriberId,
Callback<Void> callback,
Object context)
Unsubscribe from a topic asynchronously that the subscriberId user has
previously subscribed to.
|
void |
closeSubscription(com.google.protobuf.ByteString topic,
com.google.protobuf.ByteString subscriberId)
Closes all of the client side cached data for this subscription without
actually sending an unsubscribe request to the server.
|
void |
consume(com.google.protobuf.ByteString topic,
com.google.protobuf.ByteString subscriberId,
PubSubProtocol.MessageSeqId messageSeqId)
Manually send a consume message to the server for the given inputs.
|
List<com.google.protobuf.ByteString> |
getSubscriptionList(com.google.protobuf.ByteString subscriberId)
Fills the input List with the subscriptions this subscriberId client is
subscribed to.
|
boolean |
hasSubscription(com.google.protobuf.ByteString topic,
com.google.protobuf.ByteString subscriberId)
Checks if the subscriberId client is currently subscribed to the given
topic.
|
void |
startDelivery(com.google.protobuf.ByteString topic,
com.google.protobuf.ByteString subscriberId,
MessageHandler messageHandler)
Begin delivery of messages from the server to us for this topic and
subscriberId.
|
void |
stopDelivery(com.google.protobuf.ByteString topic,
com.google.protobuf.ByteString subscriberId)
Stop delivery of messages for this topic and subscriberId.
|
void |
subscribe(com.google.protobuf.ByteString topic,
com.google.protobuf.ByteString subscriberId,
PubSubProtocol.SubscribeRequest.CreateOrAttach mode)
Subscribe to the given topic for the inputted subscriberId.
|
void |
subscribe(com.google.protobuf.ByteString topic,
com.google.protobuf.ByteString subscriberId,
PubSubProtocol.SubscriptionOptions options)
Subscribe to the given topic for the inputted subscriberId.
|
void |
unsubscribe(com.google.protobuf.ByteString topic,
com.google.protobuf.ByteString subscriberId)
Unsubscribe from a topic that the subscriberId user has previously
subscribed to.
|
void subscribe(com.google.protobuf.ByteString topic, com.google.protobuf.ByteString subscriberId, PubSubProtocol.SubscribeRequest.CreateOrAttach mode) throws PubSubException.CouldNotConnectException, PubSubException.ClientAlreadySubscribedException, PubSubException.ServiceDownException, org.apache.hedwig.client.exceptions.InvalidSubscriberIdException
topic
- Topic name of the subscriptionsubscriberId
- ID of the subscribermode
- Whether to prohibit, tolerate, or require an existing
subscription.PubSubException.CouldNotConnectException
- If we are not able to connect to the server hostPubSubException.ClientAlreadySubscribedException
- If client is already subscribed to the topicPubSubException.ServiceDownException
- If unable to subscribe to topicorg.apache.hedwig.client.exceptions.InvalidSubscriberIdException
- If the subscriberId is not valid. We may want to set aside
certain formats of subscriberId's for different purposes.
e.g. local vs. hub subscribervoid asyncSubscribe(com.google.protobuf.ByteString topic, com.google.protobuf.ByteString subscriberId, PubSubProtocol.SubscribeRequest.CreateOrAttach mode, Callback<Void> callback, Object context)
topic
- Topic name of the subscriptionsubscriberId
- ID of the subscribermode
- Whether to prohibit, tolerate, or require an existing
subscription.callback
- Callback to invoke when the subscribe request to the server
has actually gone through. This will have to deal with error
conditions on the async subscribe request.context
- Calling context that the Callback needs since this is done
asynchronously.void subscribe(com.google.protobuf.ByteString topic, com.google.protobuf.ByteString subscriberId, PubSubProtocol.SubscriptionOptions options) throws PubSubException.CouldNotConnectException, PubSubException.ClientAlreadySubscribedException, PubSubException.ServiceDownException, org.apache.hedwig.client.exceptions.InvalidSubscriberIdException
topic
- Topic name of the subscriptionsubscriberId
- ID of the subscriberoptions
- Options to pass to the subscription. See
asyncSubscribe
for details on how to set options.PubSubException.CouldNotConnectException
- If we are not able to connect to the server hostPubSubException.ClientAlreadySubscribedException
- If client is already subscribed to the topicPubSubException.ServiceDownException
- If unable to subscribe to topicorg.apache.hedwig.client.exceptions.InvalidSubscriberIdException
- If the subscriberId is not valid. We may want to set aside
certain formats of subscriberId's for different purposes.
e.g. local vs. hub subscribervoid asyncSubscribe(com.google.protobuf.ByteString topic, com.google.protobuf.ByteString subscriberId, PubSubProtocol.SubscriptionOptions options, Callback<Void> callback, Object context)
Subscribe to the given topic asynchronously for the inputted subscriberId.
SubscriptionOptions contains parameters for how the hub should make the subscription. The two options are the createorattach mode and message bound.
The createorattach mode defines whether the subscription should create a new subscription, or just attach to a preexisting subscription. If it tries to create the subscription, and the subscription already exists, then an error will occur.
The message bound defines the maximum number of undelivered messages which will be stored for the subscription. This can be used to ensure that unused subscriptions do not grow in an unbounded fashion. By default, the message bound is infinite, i.e. all undelivered messages will be stored for the subscription. Note that if one subscription on a topic has a infinite message bound, the message bound for all other subscriptions on that topic will effectively be infinite as the messages have to be stored for the first subscription in any case.
Usage is as follows:
// create a new subscription with a message bound of 5
SubscriptionOptions options = SubscriptionOptions.newBuilder()
.setCreateOrAttach(CreateOrAttach.CREATE).setMessageBound(5).build();
client.getSubscriber().asyncSubscribe(ByteString.copyFromUtf8("myTopic"),
ByteString.copyFromUtf8("mySubscription"),
options,
myCallback,
myContext);
topic
- Topic name of the subscriptionsubscriberId
- ID of the subscriberoptions
- Options to pass to the subscription.callback
- Callback to invoke when the subscribe request to the server
has actually gone through. This will have to deal with error
conditions on the async subscribe request.context
- Calling context that the Callback needs since this is done
asynchronously.void unsubscribe(com.google.protobuf.ByteString topic, com.google.protobuf.ByteString subscriberId) throws PubSubException.CouldNotConnectException, PubSubException.ClientNotSubscribedException, PubSubException.ServiceDownException, org.apache.hedwig.client.exceptions.InvalidSubscriberIdException
topic
- Topic name of the subscriptionsubscriberId
- ID of the subscriberPubSubException.CouldNotConnectException
- If we are not able to connect to the server hostPubSubException.ClientNotSubscribedException
- If the client is not currently subscribed to the topicPubSubException.ServiceDownException
- If the server was down and unable to complete the requestorg.apache.hedwig.client.exceptions.InvalidSubscriberIdException
- If the subscriberId is not valid. We may want to set aside
certain formats of subscriberId's for different purposes.
e.g. local vs. hub subscribervoid asyncUnsubscribe(com.google.protobuf.ByteString topic, com.google.protobuf.ByteString subscriberId, Callback<Void> callback, Object context)
topic
- Topic name of the subscriptionsubscriberId
- ID of the subscribercallback
- Callback to invoke when the unsubscribe request to the server
has actually gone through. This will have to deal with error
conditions on the async unsubscribe request.context
- Calling context that the Callback needs since this is done
asynchronously.void consume(com.google.protobuf.ByteString topic, com.google.protobuf.ByteString subscriberId, PubSubProtocol.MessageSeqId messageSeqId) throws PubSubException.ClientNotSubscribedException
topic
- Topic name of the subscriptionsubscriberId
- ID of the subscribermessageSeqId
- Message Sequence ID for the latest message that the client app
has successfully consumed. All messages up to that point will
also be considered as consumed.PubSubException.ClientNotSubscribedException
- If the client is not currently subscribed to the topic based
on the client's local state.boolean hasSubscription(com.google.protobuf.ByteString topic, com.google.protobuf.ByteString subscriberId) throws PubSubException.CouldNotConnectException, PubSubException.ServiceDownException
topic
- Topic name of the subscription.subscriberId
- ID of the subscriberPubSubException.CouldNotConnectException
- If we are not able to connect to the server hostPubSubException.ServiceDownException
- If there is an error checking the server if the client has a
subscriptionList<com.google.protobuf.ByteString> getSubscriptionList(com.google.protobuf.ByteString subscriberId) throws PubSubException.CouldNotConnectException, PubSubException.ServiceDownException
subscriberId
- ID of the subscriberPubSubException.CouldNotConnectException
- If we are not able to connect to the server hostPubSubException.ServiceDownException
- If there is an error retrieving the list of topicsvoid startDelivery(com.google.protobuf.ByteString topic, com.google.protobuf.ByteString subscriberId, MessageHandler messageHandler) throws PubSubException.ClientNotSubscribedException, org.apache.hedwig.client.exceptions.AlreadyStartDeliveryException
topic
- Topic name of the subscriptionsubscriberId
- ID of the subscribermessageHandler
- Message Handler that will consume the subscribed messagesPubSubException.ClientNotSubscribedException
- If the client is not currently subscribed to the topicorg.apache.hedwig.client.exceptions.AlreadyStartDeliveryException
- If someone started delivery a message handler before stopping existed one.void stopDelivery(com.google.protobuf.ByteString topic, com.google.protobuf.ByteString subscriberId) throws PubSubException.ClientNotSubscribedException
topic
- Topic name of the subscriptionsubscriberId
- ID of the subscriberPubSubException.ClientNotSubscribedException
- If the client is not currently subscribed to the topicvoid closeSubscription(com.google.protobuf.ByteString topic, com.google.protobuf.ByteString subscriberId) throws PubSubException.ServiceDownException
topic
- Topic name of the subscriptionsubscriberId
- ID of the subscriberPubSubException.ServiceDownException
- If the subscribe channel was not able to be closed
successfullyvoid asyncCloseSubscription(com.google.protobuf.ByteString topic, com.google.protobuf.ByteString subscriberId, Callback<Void> callback, Object context)
topic
- Topic name of the subscriptionsubscriberId
- ID of the subscribercallback
- Callback to invoke when the subscribe channel has been closed.context
- Calling context that the Callback needs since this is done
asynchronously.Copyright © 2014 The Apache Software Foundation. All Rights Reserved.