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<ConsumerId,MQTTSubscription> |
subscriptionsByConsumerId |
Constructor and Description |
---|
AbstractMQTTSubscriptionStrategy() |
Modifier and Type | Method and Description |
---|---|
protected void |
deleteDurableSubs(List<SubscriptionInfo> subs) |
protected byte |
doSubscribe(ConsumerInfo consumerInfo,
String topicName,
org.fusesource.mqtt.client.QoS qoS) |
void |
doUnSubscribe(MQTTSubscription subscription) |
protected ConsumerId |
getNextConsumerId() |
MQTTProtocolConverter |
getProtocolConverter() |
MQTTSubscription |
getSubscription(ConsumerId consumerId)
Lookup an
MQTTSubscription instance based on known ConsumerId value. |
void |
initialize(MQTTProtocolConverter protocol)
Initialize the strategy before first use.
|
boolean |
isControlTopic(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<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(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.
|
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<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, wait
onConnect, onSubscribe, onUnSubscribe
protected MQTTProtocolConverter protocol
protected BrokerService brokerService
protected final ConcurrentMap<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
MQTTSubscriptionStrategy
initialize
in interface MQTTSubscriptionStrategy
protocol
- the MQTTProtocolConverter that is initializing the strategyMQTTProtocolException
- if an error occurs during initialization.public void setBrokerService(BrokerService brokerService)
setBrokerService
in interface BrokerServiceAware
public void setProtocolConverter(MQTTProtocolConverter parent)
MQTTSubscriptionStrategy
MQTTProtocolConverter
that is the parent of this strategy object.setProtocolConverter
in interface MQTTSubscriptionStrategy
parent
- the MQTTProtocolConverter
that owns this strategy.public MQTTProtocolConverter getProtocolConverter()
getProtocolConverter
in interface MQTTSubscriptionStrategy
MQTTProtocolConverter
that owns this strategy.public byte onSubscribe(org.fusesource.mqtt.client.Topic topic) throws MQTTProtocolException
MQTTSubscriptionStrategy
onSubscribe
in interface MQTTSubscriptionStrategy
topic
- the MQTT Topic instance being subscribed to.MQTTProtocolException
- if an error occurs while processing the subscribe actions.public void onReSubscribe(MQTTSubscription mqttSubscription) throws MQTTProtocolException
MQTTSubscriptionStrategy
onReSubscribe
in interface MQTTSubscriptionStrategy
mqttSubscription
- the MQTTSubscription that contains the subscription state.MQTTProtocolException
public ActiveMQDestination onSend(String topicName)
MQTTSubscriptionStrategy
onSend
in interface MQTTSubscriptionStrategy
topicName
- the targeted Topic that the client sent the message to.public String onSend(ActiveMQDestination destination)
MQTTSubscriptionStrategy
onSend
in interface MQTTSubscriptionStrategy
destination
- the destination that the message was dispatched frompublic boolean isControlTopic(ActiveMQDestination destination)
MQTTSubscriptionStrategy
isControlTopic
in interface MQTTSubscriptionStrategy
destination
- the destination to query.public MQTTSubscription getSubscription(ConsumerId consumerId)
MQTTSubscriptionStrategy
MQTTSubscription
instance based on known ConsumerId
value.getSubscription
in interface MQTTSubscriptionStrategy
consumerId
- the consumer ID to lookup.MQTTSubscription
for the consumer or null if no subscription exists.protected ConsumerId getNextConsumerId()
protected byte doSubscribe(ConsumerInfo consumerInfo, String topicName, org.fusesource.mqtt.client.QoS qoS) throws MQTTProtocolException
MQTTProtocolException
public void doUnSubscribe(MQTTSubscription subscription)
protected void deleteDurableSubs(List<SubscriptionInfo> subs)
protected void restoreDurableSubs(List<SubscriptionInfo> subs)
protected List<SubscriptionInfo> lookupSubscription(String clientId) throws MQTTProtocolException
MQTTProtocolException
Copyright © 2005–2019 The Apache Software Foundation. All rights reserved.