Package org.apache.activemq.transport.ws
Class AbstractMQTTSocket
- java.lang.Object
-
- org.apache.activemq.util.ServiceSupport
-
- org.apache.activemq.transport.TransportSupport
-
- org.apache.activemq.transport.ws.AbstractMQTTSocket
-
- All Implemented Interfaces:
BrokerServiceAware
,Service
,MQTTTransport
,Transport
- Direct Known Subclasses:
MQTTSocket
public abstract class AbstractMQTTSocket extends TransportSupport implements MQTTTransport, BrokerServiceAware
-
-
Field Summary
Fields Modifier and Type Field Description protected BrokerService
brokerService
protected MQTTInactivityMonitor
mqttInactivityMonitor
protected X509Certificate[]
peerCertificates
protected MQTTProtocolConverter
protocolConverter
protected ReentrantLock
protocolLock
protected int
receiveCounter
protected String
remoteAddress
protected CountDownLatch
socketTransportStarted
protected MQTTWireFormat
wireFormat
-
Constructor Summary
Constructors Constructor Description AbstractMQTTSocket(String remoteAddress)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
doStart()
protected void
doStop(ServiceStopper stopper)
MQTTInactivityMonitor
getInactivityMonitor()
X509Certificate[]
getPeerCertificates()
protected MQTTProtocolConverter
getProtocolConverter()
int
getReceiveCounter()
Returns a counter which gets incremented as data is read from the transport.String
getRemoteAddress()
MQTTWireFormat
getWireFormat()
Retrieves the WireFormat instance associated with this Transport instance.abstract void
handleStopped()
Called when the transport is stopping to allow the dervied classes a chance to close WebSocket resources.void
oneway(Object command)
A one way asynchronous sendvoid
sendToActiveMQ(Command command)
abstract void
sendToMQTT(org.fusesource.mqtt.codec.MQTTFrame command)
void
setBrokerService(BrokerService brokerService)
void
setPeerCertificates(X509Certificate[] certificates)
Sets the certificates provided by the connected peer.void
setTransportOptions(Map<String,Object> transportOptions)
protected boolean
transportStartedAtLeastOnce()
-
Methods inherited from class org.apache.activemq.transport.TransportSupport
asyncRequest, checkStarted, doConsume, getTransportListener, isConnected, isDisposed, isFaultTolerant, isReconnectSupported, isUpdateURIsSupported, narrow, onException, reconnect, request, request, setTransportListener, updateURIs
-
Methods inherited from class org.apache.activemq.util.ServiceSupport
addServiceListener, dispose, isStarted, isStopped, isStopping, postStop, preStart, removeServiceListener, start, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.activemq.transport.mqtt.MQTTTransport
onException, stop
-
-
-
-
Field Detail
-
protocolLock
protected ReentrantLock protocolLock
-
protocolConverter
protected volatile MQTTProtocolConverter protocolConverter
-
wireFormat
protected MQTTWireFormat wireFormat
-
mqttInactivityMonitor
protected final MQTTInactivityMonitor mqttInactivityMonitor
-
socketTransportStarted
protected final CountDownLatch socketTransportStarted
-
brokerService
protected BrokerService brokerService
-
receiveCounter
protected volatile int receiveCounter
-
remoteAddress
protected final String remoteAddress
-
peerCertificates
protected X509Certificate[] peerCertificates
-
-
Constructor Detail
-
AbstractMQTTSocket
public AbstractMQTTSocket(String remoteAddress)
-
-
Method Detail
-
oneway
public void oneway(Object command) throws IOException
Description copied from interface:Transport
A one way asynchronous send- Specified by:
oneway
in interfaceTransport
- Throws:
IOException
-
sendToActiveMQ
public void sendToActiveMQ(Command command)
- Specified by:
sendToActiveMQ
in interfaceMQTTTransport
-
doStop
protected void doStop(ServiceStopper stopper) throws Exception
- Specified by:
doStop
in classServiceSupport
- Throws:
Exception
-
doStart
protected void doStart() throws Exception
- Specified by:
doStart
in classServiceSupport
- Throws:
Exception
-
sendToMQTT
public abstract void sendToMQTT(org.fusesource.mqtt.codec.MQTTFrame command) throws IOException
- Specified by:
sendToMQTT
in interfaceMQTTTransport
- Throws:
IOException
-
handleStopped
public abstract void handleStopped() throws IOException
Called when the transport is stopping to allow the dervied classes a chance to close WebSocket resources.- Throws:
IOException
- if an error occurs during the stop.
-
getInactivityMonitor
public MQTTInactivityMonitor getInactivityMonitor()
- Specified by:
getInactivityMonitor
in interfaceMQTTTransport
-
getWireFormat
public MQTTWireFormat getWireFormat()
Description copied from interface:Transport
Retrieves the WireFormat instance associated with this Transport instance.- Specified by:
getWireFormat
in interfaceMQTTTransport
- Specified by:
getWireFormat
in interfaceTransport
- Returns:
- the WireFormat in use.
-
getRemoteAddress
public String getRemoteAddress()
- Specified by:
getRemoteAddress
in interfaceTransport
- Returns:
- the remote address for this connection
-
getReceiveCounter
public int getReceiveCounter()
Description copied from interface:Transport
Returns a counter which gets incremented as data is read from the transport. It should only be used to determine if there is progress being made in reading the next command from the transport. The value may wrap into the negative numbers.- Specified by:
getReceiveCounter
in interfaceTransport
- Returns:
- a counter which gets incremented as data is read from the transport.
-
getPeerCertificates
public X509Certificate[] getPeerCertificates()
- Specified by:
getPeerCertificates
in interfaceMQTTTransport
- Specified by:
getPeerCertificates
in interfaceTransport
- Returns:
- the Certificates provided by the peer, or null if not a secure channel.
-
setPeerCertificates
public void setPeerCertificates(X509Certificate[] certificates)
Description copied from interface:Transport
Sets the certificates provided by the connected peer.- Specified by:
setPeerCertificates
in interfaceMQTTTransport
- Specified by:
setPeerCertificates
in interfaceTransport
- Parameters:
certificates
- the Certificates provided by the peer.
-
setBrokerService
public void setBrokerService(BrokerService brokerService)
- Specified by:
setBrokerService
in interfaceBrokerServiceAware
-
getProtocolConverter
protected MQTTProtocolConverter getProtocolConverter()
-
transportStartedAtLeastOnce
protected boolean transportStartedAtLeastOnce()
-
-