Class MQTTTransportFilter
- java.lang.Object
-
- org.apache.activemq.transport.TransportFilter
-
- org.apache.activemq.transport.mqtt.MQTTTransportFilter
-
- All Implemented Interfaces:
Service,MQTTTransport,Transport,TransportListener
public class MQTTTransportFilter extends TransportFilter implements MQTTTransport
The MQTTTransportFilter normally sits on top of a TcpTransport that has been configured with the StompWireFormat and is used to convert MQTT commands to ActiveMQ commands. All of the conversion work is done by delegating to the MQTTProtocolConverter
-
-
Field Summary
-
Fields inherited from class org.apache.activemq.transport.TransportFilter
next, transportListener
-
-
Constructor Summary
Constructors Constructor Description MQTTTransportFilter(Transport next, WireFormat wireFormat, BrokerService brokerService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetActiveMQSubscriptionPrefetch()longgetConnectAttemptTimeout()longgetDefaultKeepAlive()MQTTInactivityMonitorgetInactivityMonitor()intgetMaxFrameSize()X509Certificate[]getPeerCertificates()booleangetPublishDollarTopics()StringgetSubscriptionStrategy()MQTTWireFormatgetWireFormat()Retrieves the WireFormat instance associated with this Transport instance.booleanisTrace()voidonCommand(Object command)called to process a commandvoidoneway(Object o)A one way asynchronous sendvoidonException(IOException error)An unrecoverable exception has occured on the transportvoidsendToActiveMQ(Command command)voidsendToMQTT(org.fusesource.mqtt.codec.MQTTFrame command)voidsetActiveMQSubscriptionPrefetch(int activeMQSubscriptionPrefetch)set the default prefetch size when mapping the MQTT subscription to an ActiveMQ one The default = 1voidsetConnectAttemptTimeout(long connectTimeout)Sets the timeout value used to fail a connection if no CONNECT frame is read in the given interval.voidsetDefaultKeepAlive(long defaultHeartBeat)voidsetInactivityMonitor(MQTTInactivityMonitor monitor)voidsetMaxFrameSize(int maxFrameSize)Sets the maximum frame size for an incoming MQTT frame.voidsetPeerCertificates(X509Certificate[] certificates)Sets the certificates provided by the connected peer.voidsetPublishDollarTopics(boolean publishDollarTopics)voidsetSubscriptionStrategy(String name)voidsetTrace(boolean trace)voidstart()voidstop()-
Methods inherited from class org.apache.activemq.transport.TransportFilter
asyncRequest, getNext, getReceiveCounter, getRemoteAddress, getTransportListener, isConnected, isDisposed, isFaultTolerant, isReconnectSupported, isUpdateURIsSupported, narrow, reconnect, request, request, setTransportListener, toString, transportInterupted, transportResumed, updateURIs
-
-
-
-
Constructor Detail
-
MQTTTransportFilter
public MQTTTransportFilter(Transport next, WireFormat wireFormat, BrokerService brokerService)
-
-
Method Detail
-
oneway
public void oneway(Object o) throws IOException
Description copied from interface:TransportA one way asynchronous send- Specified by:
onewayin interfaceTransport- Overrides:
onewayin classTransportFilter- Throws:
IOException
-
onCommand
public void onCommand(Object command)
Description copied from interface:TransportListenercalled to process a command- Specified by:
onCommandin interfaceTransportListener- Overrides:
onCommandin classTransportFilter
-
sendToActiveMQ
public void sendToActiveMQ(Command command)
- Specified by:
sendToActiveMQin interfaceMQTTTransport
-
sendToMQTT
public void sendToMQTT(org.fusesource.mqtt.codec.MQTTFrame command) throws IOException- Specified by:
sendToMQTTin interfaceMQTTTransport- Throws:
IOException
-
start
public void start() throws Exception- Specified by:
startin interfaceService- Overrides:
startin classTransportFilter- Throws:
Exception- See Also:
Service.start()
-
stop
public void stop() throws Exception- Specified by:
stopin interfaceMQTTTransport- Specified by:
stopin interfaceService- Overrides:
stopin classTransportFilter- Throws:
Exception- See Also:
Service.stop()
-
getPeerCertificates
public X509Certificate[] getPeerCertificates()
- Specified by:
getPeerCertificatesin interfaceMQTTTransport- Specified by:
getPeerCertificatesin interfaceTransport- Overrides:
getPeerCertificatesin classTransportFilter- Returns:
- the Certificates provided by the peer, or null if not a secure channel.
-
isTrace
public boolean isTrace()
-
setTrace
public void setTrace(boolean trace)
-
getInactivityMonitor
public MQTTInactivityMonitor getInactivityMonitor()
- Specified by:
getInactivityMonitorin interfaceMQTTTransport
-
setInactivityMonitor
public void setInactivityMonitor(MQTTInactivityMonitor monitor)
-
getWireFormat
public MQTTWireFormat getWireFormat()
Description copied from interface:TransportRetrieves the WireFormat instance associated with this Transport instance.- Specified by:
getWireFormatin interfaceMQTTTransport- Specified by:
getWireFormatin interfaceTransport- Overrides:
getWireFormatin classTransportFilter- Returns:
- the WireFormat in use.
-
onException
public void onException(IOException error)
Description copied from interface:TransportListenerAn unrecoverable exception has occured on the transport- Specified by:
onExceptionin interfaceMQTTTransport- Specified by:
onExceptionin interfaceTransportListener- Overrides:
onExceptionin classTransportFilter
-
getDefaultKeepAlive
public long getDefaultKeepAlive()
-
setDefaultKeepAlive
public void setDefaultKeepAlive(long defaultHeartBeat)
-
getConnectAttemptTimeout
public long getConnectAttemptTimeout()
- Returns:
- the timeout value used to fail a connection if no CONNECT frame read.
-
setConnectAttemptTimeout
public void setConnectAttemptTimeout(long connectTimeout)
Sets the timeout value used to fail a connection if no CONNECT frame is read in the given interval.- Parameters:
connectTimeout- the connection frame received timeout value.
-
getPublishDollarTopics
public boolean getPublishDollarTopics()
-
setPublishDollarTopics
public void setPublishDollarTopics(boolean publishDollarTopics)
-
getSubscriptionStrategy
public String getSubscriptionStrategy()
-
setSubscriptionStrategy
public void setSubscriptionStrategy(String name)
-
getActiveMQSubscriptionPrefetch
public int getActiveMQSubscriptionPrefetch()
-
setActiveMQSubscriptionPrefetch
public void setActiveMQSubscriptionPrefetch(int activeMQSubscriptionPrefetch)
set the default prefetch size when mapping the MQTT subscription to an ActiveMQ one The default = 1- Parameters:
activeMQSubscriptionPrefetch- set the prefetch for the corresponding ActiveMQ subscription
-
getMaxFrameSize
public int getMaxFrameSize()
- Returns:
- the maximum number of bytes a single MQTT message frame is allowed to be.
-
setMaxFrameSize
public void setMaxFrameSize(int maxFrameSize)
Sets the maximum frame size for an incoming MQTT frame. The protocl limit is 256 megabytes and this value cannot be set higher.- Parameters:
maxFrameSize- the maximum allowed frame size for a single MQTT frame.
-
setPeerCertificates
public void setPeerCertificates(X509Certificate[] certificates)
Description copied from interface:TransportSets the certificates provided by the connected peer.- Specified by:
setPeerCertificatesin interfaceMQTTTransport- Specified by:
setPeerCertificatesin interfaceTransport- Overrides:
setPeerCertificatesin classTransportFilter- Parameters:
certificates- the Certificates provided by the peer.
-
-