net.sf.xenqtt
Class SimpleBroker
java.lang.Object
net.sf.xenqtt.SimpleBroker
- Direct Known Subclasses:
- MockBroker, ProxyBroker
public class SimpleBroker
- extends Object
Simple broker implementation. Can be used as the base class for more advanced broker implementations. Handles accepting new connections and adding them to a
ChannelManager.
|
Constructor Summary |
SimpleBroker(long messageResendIntervalSeconds,
int port)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
manager
protected final ChannelManager manager
ChannelManager all new broker channels are added to.
SimpleBroker
public SimpleBroker(long messageResendIntervalSeconds,
int port)
- Parameters:
messageResendIntervalSeconds - Seconds between attempts to resend a message that is MqttMessage.isAckable(). 0 to disable message resends.port - The port for the server to listen on. 0 will choose an arbitrary available port which you can get from getPort() after calling
#init().
init
public final void init(MessageHandler messageHandler,
String serverThreadName)
- Starts the broker. Blocks until startup is complete.
- Parameters:
messageHandler - Called when events happenserverThreadName - Name to give the server thread
shutdown
public boolean shutdown(long millis)
- Shuts down the broker. Blocks until shutdown is complete.
- Parameters:
millis - Milliseconds to wait for shutdown to complete. 0 means to wait forever.
- Returns:
- true if shutdown is successful, otherwise false.
getURI
public final String getURI()
- Returns:
- The URI to this broker
getPort
public final int getPort()
- Returns:
- The port the broker is running on. Not valid until after
#init() is called.
Copyright © 2013. All Rights Reserved.