public abstract class AbstractMQTTSubscriptionStrategy extends Object implements MQTTSubscriptionStrategy, BrokerServiceAware
MQTTSubscriptionStrategy interface providing
the base functionality that is common to most implementations.| Modifier and Type | Field and Description |
|---|---|
protected BrokerService |
brokerService |
protected LongSequenceGenerator |
consumerIdGenerator |
protected ConcurrentMap<String,MQTTSubscription> |
mqttSubscriptionByTopic |
protected MQTTProtocolConverter |
protocol |
protected Set<String> |
restoredDurableSubs |
protected ConcurrentMap<org.apache.activemq.command.ConsumerId,MQTTSubscription> |
subscriptionsByConsumerId |
| Constructor and Description |
|---|
AbstractMQTTSubscriptionStrategy() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
deleteDurableSubs(List<org.apache.activemq.command.SubscriptionInfo> subs) |
protected byte |
doSubscribe(org.apache.activemq.command.ConsumerInfo consumerInfo,
String topicName,
org.fusesource.mqtt.client.QoS qoS) |
void |
doUnSubscribe(MQTTSubscription subscription) |
protected org.apache.activemq.command.ConsumerId |
getNextConsumerId() |
MQTTProtocolConverter |
getProtocolConverter() |
MQTTSubscription |
getSubscription(org.apache.activemq.command.ConsumerId consumerId)
Lookup an
MQTTSubscription instance based on known ConsumerId value. |
void |
initialize(MQTTProtocolConverter protocol)
Initialize the strategy before first use.
|
boolean |
isControlTopic(org.apache.activemq.command.ActiveMQDestination destination)
Allows the protocol handler to interrogate an destination name to determine if it
is equivalent to the MQTT control topic (starts with $).
|
protected List<org.apache.activemq.command.SubscriptionInfo> |
lookupSubscription(String clientId) |
void |
onReSubscribe(MQTTSubscription mqttSubscription)
Called when a client sends a duplicate subscribe request which should
force any retained messages on that topic to be replayed again as though
the client had just subscribed for the first time.
|
String |
onSend(org.apache.activemq.command.ActiveMQDestination destination)
Intercepts send operations from the broker and allows the strategy to map the
target topic name so that the client sees a valid Topic name.
|
org.apache.activemq.command.ActiveMQDestination |
onSend(String topicName)
Intercepts PUBLISH operations from the client and allows the strategy to map the
target destination so that the send operation will land in the destinations that
this strategy has mapped the incoming subscribe requests to.
|
byte |
onSubscribe(org.fusesource.mqtt.client.Topic topic)
Called for each Topic that a client requests to subscribe to.
|
protected void |
restoreDurableSubs(List<org.apache.activemq.command.SubscriptionInfo> subs) |
void |
setBrokerService(BrokerService brokerService) |
void |
setProtocolConverter(MQTTProtocolConverter parent)
Sets the
MQTTProtocolConverter that is the parent of this strategy object. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitonConnect, onSubscribe, onUnSubscribeprotected MQTTProtocolConverter protocol
protected BrokerService brokerService
protected final ConcurrentMap<org.apache.activemq.command.ConsumerId,MQTTSubscription> subscriptionsByConsumerId
protected final ConcurrentMap<String,MQTTSubscription> mqttSubscriptionByTopic
protected final Set<String> restoredDurableSubs
protected final LongSequenceGenerator consumerIdGenerator
public AbstractMQTTSubscriptionStrategy()
public void initialize(MQTTProtocolConverter protocol) throws MQTTProtocolException
MQTTSubscriptionStrategyinitialize in interface MQTTSubscriptionStrategyprotocol - the MQTTProtocolConverter that is initializing the strategyMQTTProtocolException - if an error occurs during initialization.public void setBrokerService(BrokerService brokerService)
setBrokerService in interface BrokerServiceAwarepublic void setProtocolConverter(MQTTProtocolConverter parent)
MQTTSubscriptionStrategyMQTTProtocolConverter that is the parent of this strategy object.setProtocolConverter in interface MQTTSubscriptionStrategyparent - the MQTTProtocolConverter that owns this strategy.public MQTTProtocolConverter getProtocolConverter()
getProtocolConverter in interface MQTTSubscriptionStrategyMQTTProtocolConverter that owns this strategy.public byte onSubscribe(org.fusesource.mqtt.client.Topic topic) throws MQTTProtocolException
MQTTSubscriptionStrategyonSubscribe in interface MQTTSubscriptionStrategytopic - the MQTT Topic instance being subscribed to.MQTTProtocolException - if an error occurs while processing the subscribe actions.public void onReSubscribe(MQTTSubscription mqttSubscription) throws MQTTProtocolException
MQTTSubscriptionStrategyonReSubscribe in interface MQTTSubscriptionStrategymqttSubscription - the MQTTSubscription that contains the subscription state.MQTTProtocolExceptionpublic org.apache.activemq.command.ActiveMQDestination onSend(String topicName)
MQTTSubscriptionStrategyonSend in interface MQTTSubscriptionStrategytopicName - the targeted Topic that the client sent the message to.public String onSend(org.apache.activemq.command.ActiveMQDestination destination)
MQTTSubscriptionStrategyonSend in interface MQTTSubscriptionStrategydestination - the destination that the message was dispatched frompublic boolean isControlTopic(org.apache.activemq.command.ActiveMQDestination destination)
MQTTSubscriptionStrategyisControlTopic in interface MQTTSubscriptionStrategydestination - the destination to query.public MQTTSubscription getSubscription(org.apache.activemq.command.ConsumerId consumerId)
MQTTSubscriptionStrategyMQTTSubscription instance based on known ConsumerId value.getSubscription in interface MQTTSubscriptionStrategyconsumerId - the consumer ID to lookup.MQTTSubscription for the consumer or null if no subscription exists.protected org.apache.activemq.command.ConsumerId getNextConsumerId()
protected byte doSubscribe(org.apache.activemq.command.ConsumerInfo consumerInfo, String topicName, org.fusesource.mqtt.client.QoS qoS) throws MQTTProtocolException
MQTTProtocolExceptionpublic void doUnSubscribe(MQTTSubscription subscription)
protected void deleteDurableSubs(List<org.apache.activemq.command.SubscriptionInfo> subs)
protected void restoreDurableSubs(List<org.apache.activemq.command.SubscriptionInfo> subs)
protected List<org.apache.activemq.command.SubscriptionInfo> lookupSubscription(String clientId) throws MQTTProtocolException
MQTTProtocolExceptionCopyright © 2005–2017 The Apache Software Foundation. All rights reserved.