public abstract class AbstractSubscribeResponseHandler extends SubscribeResponseHandler
| Modifier and Type | Field and Description |
|---|---|
protected AbstractHChannelManager |
aChannelManager |
protected ReentrantReadWriteLock |
disconnectLock |
protected ConcurrentMap<TopicSubscriber,ActiveSubscriber> |
subscriptions |
cfg, channelManager| Modifier | Constructor and Description |
|---|---|
protected |
AbstractSubscribeResponseHandler(ClientConfiguration cfg,
HChannelManager channelManager) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
asyncMessageDeliver(TopicSubscriber topicSubscriber,
PubSubProtocol.Message message)
Method called when a message arrives for a subscribe Channel and we want
to deliver it asynchronously via the registered MessageHandler (should
not be null when called here).
|
void |
consume(TopicSubscriber topicSubscriber,
PubSubProtocol.MessageSeqId messageSeqId)
Consume a given message for given topic subscriber thru this handler.
|
protected ActiveSubscriber |
createActiveSubscriber(ClientConfiguration cfg,
AbstractHChannelManager channelManager,
TopicSubscriber ts,
PubSubData op,
PubSubProtocol.SubscriptionPreferences preferences,
org.jboss.netty.channel.Channel channel,
HChannel hChannel) |
protected ActiveSubscriber |
getActiveSubscriber(TopicSubscriber ts) |
protected ClientConfiguration |
getConfiguration() |
protected HChannelManager |
getHChannelManager() |
void |
handleResponse(PubSubProtocol.PubSubResponse response,
PubSubData pubSubData,
org.jboss.netty.channel.Channel channel)
Logic to handle received response.
|
void |
handleSubscribeMessage(PubSubProtocol.PubSubResponse response)
Handle Message delivered by the server.
|
void |
handleSubscriptionEvent(com.google.protobuf.ByteString topic,
com.google.protobuf.ByteString subscriberId,
PubSubProtocol.SubscriptionEvent event)
Handle a subscription event delivered by the server.
|
protected abstract Either<PubSubProtocol.StatusCode,HChannel> |
handleSuccessResponse(TopicSubscriber ts,
PubSubData pubSubData,
org.jboss.netty.channel.Channel channel)
Handle success response for a specific TopicSubscriber
ts. |
boolean |
hasSubscription(TopicSubscriber topicSubscriber)
Whether the given topic subscriber subscribed thru this handler.
|
protected void |
messageConsumed(TopicSubscriber topicSubscriber,
PubSubProtocol.Message message)
Method called when the client app's MessageHandler has asynchronously
completed consuming a subscribed message sent from the server.
|
void |
onChannelDisconnected(InetSocketAddress host,
org.jboss.netty.channel.Channel channel)
This method is called when the underlying channel is disconnected due to server failure.
|
protected void |
postHandleSuccessResponse(TopicSubscriber ts,
ActiveSubscriber ss) |
protected void |
processSubscriptionEvent(ActiveSubscriber as,
PubSubProtocol.SubscriptionEvent event) |
protected boolean |
removeSubscription(TopicSubscriber ts,
ActiveSubscriber ss) |
protected void |
resubscribeIfNecessary(ActiveSubscriber ss,
PubSubProtocol.SubscriptionEvent event) |
void |
startDelivery(TopicSubscriber topicSubscriber,
MessageHandler messageHandler)
Start delivering messages for a given topic subscriber.
|
void |
stopDelivery(TopicSubscriber topicSubscriber)
Stop delivering messages for a given topic subscriber.
|
asyncCloseSubscriptionhandleRedirectResponseprotected final ReentrantReadWriteLock disconnectLock
protected final ConcurrentMap<TopicSubscriber,ActiveSubscriber> subscriptions
protected final AbstractHChannelManager aChannelManager
protected AbstractSubscribeResponseHandler(ClientConfiguration cfg, HChannelManager channelManager)
protected HChannelManager getHChannelManager()
protected ClientConfiguration getConfiguration()
protected ActiveSubscriber getActiveSubscriber(TopicSubscriber ts)
protected ActiveSubscriber createActiveSubscriber(ClientConfiguration cfg, AbstractHChannelManager channelManager, TopicSubscriber ts, PubSubData op, PubSubProtocol.SubscriptionPreferences preferences, org.jboss.netty.channel.Channel channel, HChannel hChannel)
public void handleResponse(PubSubProtocol.PubSubResponse response, PubSubData pubSubData, org.jboss.netty.channel.Channel channel) throws Exception
AbstractResponseHandlerhandleResponse in class AbstractResponseHandlerresponse - PubSubResponse received from hub server.pubSubData - PubSubData for the pub/sub request.channel - Channel we used to make the request.Exceptionprotected abstract Either<PubSubProtocol.StatusCode,HChannel> handleSuccessResponse(TopicSubscriber ts, PubSubData pubSubData, org.jboss.netty.channel.Channel channel)
ts. The method
is triggered after subscribed successfully.ts - Topic Subscriber.pubSubData - Pub/Sub Request data for this subscribe request.channel - Subscription Channel.protected void postHandleSuccessResponse(TopicSubscriber ts, ActiveSubscriber ss)
public void handleSubscribeMessage(PubSubProtocol.PubSubResponse response)
SubscribeResponseHandlerhandleSubscribeMessage in class SubscribeResponseHandlerresponse - Message received from the server.protected void asyncMessageDeliver(TopicSubscriber topicSubscriber, PubSubProtocol.Message message)
SubscribeResponseHandlerasyncMessageDeliver in class SubscribeResponseHandlermessage - Message from Subscribe Channel we want to consume.protected void messageConsumed(TopicSubscriber topicSubscriber, PubSubProtocol.Message message)
SubscribeResponseHandlermessageConsumed in class SubscribeResponseHandlertopicSubscriber - Topic Subscribermessage - Message sent from server for topic subscription that has been
consumed by the client.public void handleSubscriptionEvent(com.google.protobuf.ByteString topic,
com.google.protobuf.ByteString subscriberId,
PubSubProtocol.SubscriptionEvent event)
SubscribeResponseHandlerhandleSubscriptionEvent in class SubscribeResponseHandlertopic - Topic NamesubscriberId - Subscriber Idevent - Subscription Event describes its statusprotected void processSubscriptionEvent(ActiveSubscriber as, PubSubProtocol.SubscriptionEvent event)
public void startDelivery(TopicSubscriber topicSubscriber, MessageHandler messageHandler) throws PubSubException.ClientNotSubscribedException, AlreadyStartDeliveryException
SubscribeResponseHandlerstartDelivery in class SubscribeResponseHandlertopicSubscriber - Topic SubscribermessageHandler - MessageHandler to register for this ResponseHandler instance.PubSubException.ClientNotSubscribedException - If the client is not currently subscribed to the topicAlreadyStartDeliveryException - If someone started delivery a message handler before stopping existed one.public void stopDelivery(TopicSubscriber topicSubscriber) throws PubSubException.ClientNotSubscribedException
SubscribeResponseHandlerstopDelivery in class SubscribeResponseHandlertopicSubscriber - Topic SubscriberPubSubException.ClientNotSubscribedException - If the client is not currently subscribed to the topicpublic boolean hasSubscription(TopicSubscriber topicSubscriber)
SubscribeResponseHandlerhasSubscription in class SubscribeResponseHandlertopicSubscriber - Topic Subscriberpublic void consume(TopicSubscriber topicSubscriber, PubSubProtocol.MessageSeqId messageSeqId)
SubscribeResponseHandlerconsume in class SubscribeResponseHandlertopicSubscriber - Topic Subscriberpublic void onChannelDisconnected(InetSocketAddress host, org.jboss.netty.channel.Channel channel)
SubscribeResponseHandleronChannelDisconnected in class SubscribeResponseHandlerhost - Host that channel connected to has disconnected.channel - Channel connected to.protected boolean removeSubscription(TopicSubscriber ts, ActiveSubscriber ss)
protected void resubscribeIfNecessary(ActiveSubscriber ss, PubSubProtocol.SubscriptionEvent event)
Copyright © 2011–2021 The Apache Software Foundation. All rights reserved.