|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ChannelManager
Specifies a type that manages zero or more channels
that communicate via the MQTT protocol.
All of the methods in this specification are thread-safe. Implementations may be blocking or non-blocking
Method Summary | ||
---|---|---|
void |
cancelBlockingCommands(MqttChannelRef channel)
Cancels all blocking commands for the specified channel. |
|
void |
close(MqttChannelRef channel)
Closes the specified channel. |
|
void |
close(MqttChannelRef channel,
Throwable cause)
Closes the specified channel and sends cause to the MessageHandler.channelClosed(MqttChannel, Throwable) callback. |
|
List<MqttMessage> |
getUnsentMessages(MqttChannelRef channel)
|
|
void |
init()
Starts this channel manager. |
|
boolean |
isRunning()
|
|
MqttChannelRef |
newBrokerChannel(SocketChannel socketChannel,
MessageHandler messageHandler)
Create a new broker side MqttChannelRef for use in exchanging data using the MQTT protocol. |
|
MqttChannelRef |
newClientChannel(String host,
int port,
MessageHandler messageHandler)
Create a new client side MqttChannelRef for use in exchanging data using the MQTT protocol. |
|
MqttChannelRef |
newClientChannel(String brokerUri,
MessageHandler messageHandler)
Create a new client side MqttChannelRef for use in exchanging data using the MQTT protocol. |
|
MqttChannelRef |
newClientChannel(URI brokerUri,
MessageHandler messageHandler)
Create a new client side MqttChannelRef for use in exchanging data using the MQTT protocol. |
|
|
send(MqttChannelRef channel,
MqttMessage message)
Send a message over a specified channel . |
|
void |
shutdown()
Stops this channel manager. |
|
void |
transfer(MqttChannelRef oldChannel,
MqttChannelRef newChannel)
Transfers unsent messages from oldChannel to newChannel and changes oldChannel such that any messages sent to it will actually go to newChannel. |
Method Detail |
---|
MqttChannelRef newClientChannel(String brokerUri, MessageHandler messageHandler) throws MqttCommandCancelledException, MqttTimeoutException, MqttInterruptedException
MqttChannelRef
for use in exchanging data using the MQTT protocol. This is the client end of the connection. The broker
will have the remote end of the connection. This method only blocks long enough for the channel to be created, not for the TCP connection to happen.
brokerUri
- URI of the broker to connect to. For example, tcp://q.m2m.io:1883.messageHandler
- The message handler
to use for all received messages
MessageHandler
callback methods.
MqttCommandCancelledException
- The channel manager uses a command pattern to process this request on the IO thread. If the command is cancelled for some reason, like the
channel closes, this exception is thrown.
MqttTimeoutException
- Thrown when using a synchronous implementation and the timeout specified for a blocked method expires
MqttInterruptedException
- Thrown when the calling thread is interruptedMqttChannelRef newClientChannel(URI brokerUri, MessageHandler messageHandler) throws MqttCommandCancelledException, MqttTimeoutException, MqttInterruptedException
MqttChannelRef
for use in exchanging data using the MQTT protocol. This is the client end of the connection. The broker
will have the remote end of the connection. This method only blocks long enough for the channel to be created, not for the TCP connection to happen. This
will throw a RuntimeException
wrapping any exception thrown while initializing the connection like UnresolvedAddressException
brokerUri
- URI of the broker to connect to. For example, tcp://q.m2m.io:1883.messageHandler
- The message handler
to use for all received messages
MessageHandler
callback methods.
MqttCommandCancelledException
- The channel manager uses a command pattern to process this request on the IO thread. If the command is cancelled for some reason, like the
channel closes, this exception is thrown.
MqttTimeoutException
- Thrown when using a synchronous implementation and the timeout specified for a blocked method expires
MqttInterruptedException
- Thrown when the calling thread is interruptedMqttChannelRef newClientChannel(String host, int port, MessageHandler messageHandler) throws MqttCommandCancelledException, MqttTimeoutException, MqttInterruptedException
MqttChannelRef
for use in exchanging data using the MQTT protocol. This is the client end of the connection. The broker
will have the remote end of the connection. This method only blocks long enough for the channel to be created, not for the TCP connection to happen. This
will throw a RuntimeException
wrapping any exception thrown while initializing the connection like UnresolvedAddressException
host
- The host name to connect toport
- The port to connect tomessageHandler
- The message handler
to use for all received messages
MessageHandler
callback methods.
MqttCommandCancelledException
- The channel manager uses a command pattern to process this request on the IO thread. If the command is cancelled for some reason, like the
channel closes, this exception is thrown.
MqttTimeoutException
- Thrown when using a synchronous implementation and the timeout specified for a blocked method expires
MqttInterruptedException
- Thrown when the calling thread is interruptedMqttChannelRef newBrokerChannel(SocketChannel socketChannel, MessageHandler messageHandler) throws MqttCommandCancelledException, MqttTimeoutException, MqttInterruptedException
MqttChannelRef
for use in exchanging data using the MQTT protocol. This is the broker end of the connection. The client
will have the remove end of the connection. If an exception is thrown the socketChannel will be closed. This method only blocks long enough for the
channel to be created.
socketChannel
- The channel
to communicate overmessageHandler
- The message handler
to use for all received messages
MessageHandler
callback methods.
MqttCommandCancelledException
- The channel manager uses a command pattern to process this request on the IO thread. If the command is cancelled for some reason, like the
channel closes, this exception is thrown.
MqttTimeoutException
- Thrown when using a synchronous implementation and the timeout specified for a blocked method expires
MqttInterruptedException
- Thrown when the calling thread is interrupted<T extends MqttMessage> T send(MqttChannelRef channel, MqttMessage message) throws MqttCommandCancelledException, MqttTimeoutException, MqttInterruptedException
message
over a specified channel
. This method only blocks until the message is queued to send to the channel.
channel
- The channel
to send the message over. This channel should have been previously created via the
#newChannel(String, int, MessageHandler)
or #newChannel(SocketChannel, MessageHandler)
methodsmessage
- The message
to send. This can be any type of MQTT message
ConnectMessage
or has a
QoS
> 0.
MqttCommandCancelledException
- The channel manager uses a command pattern to process this request on the IO thread. If the command is cancelled for some reason, like the
channel closes, this exception is thrown.
MqttTimeoutException
- Thrown when using a synchronous implementation and the timeout specified for a blocked method expires
MqttInterruptedException
- Thrown when the calling thread is interruptedvoid close(MqttChannelRef channel) throws MqttCommandCancelledException, MqttTimeoutException, MqttInterruptedException
MqttCommandCancelledException
- The channel manager uses a command pattern to process this request on the IO thread. If the command is cancelled for some reason, like the
channel closes, this exception is thrown.
MqttTimeoutException
- Thrown when using a synchronous implementation and the timeout specified for a blocked method expires
MqttInterruptedException
- Thrown when the calling thread is interruptedvoid close(MqttChannelRef channel, Throwable cause) throws MqttCommandCancelledException, MqttTimeoutException, MqttInterruptedException
MessageHandler.channelClosed(MqttChannel, Throwable)
callback. This method blocks until the
channel is closed.
MqttCommandCancelledException
- The channel manager uses a command pattern to process this request on the IO thread. If the command is cancelled for some reason, like the
channel closes, this exception is thrown.
MqttTimeoutException
- Thrown when using a synchronous implementation and the timeout specified for a blocked method expires
MqttInterruptedException
- Thrown when the calling thread is interruptedvoid cancelBlockingCommands(MqttChannelRef channel)
Cancels
all blocking commands for the specified channel. This is not done when the channel is closed because we may want
to reconnect instead of releasing the commands.
List<MqttMessage> getUnsentMessages(MqttChannelRef channel)
void transfer(MqttChannelRef oldChannel, MqttChannelRef newChannel)
void init()
void shutdown()
boolean isRunning()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |