Package io.moquette.broker
Class Server
- java.lang.Object
-
- io.moquette.broker.Server
-
public class Server extends Object
-
-
Constructor Summary
Constructors Constructor Description Server()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInterceptHandler(InterceptHandler interceptHandler)SPI method used by Broker embedded applications to add intercept handlers.intgetPort()intgetSslPort()voidinternalPublish(io.netty.handler.codec.mqtt.MqttPublishMessage msg, String clientId)Use the broker to publish a message.Collection<ClientDescriptor>listConnectedClients()Return a list of descriptors of connected clients.static voidmain(String[] args)voidremoveInterceptHandler(InterceptHandler interceptHandler)SPI method used by Broker embedded applications to remove intercept handlers.voidstartServer()Starts Moquette bringing the configuration from the file located at m_config/moquette.confvoidstartServer(IConfig config)Starts Moquette bringing the configuration files from the given Config implementation.voidstartServer(IConfig config, List<? extends InterceptHandler> handlers)Starts Moquette with config provided by an implementation of IConfig class and with the set of InterceptHandler.voidstartServer(IConfig config, List<? extends InterceptHandler> handlers, ISslContextCreator sslCtxCreator, IAuthenticator authenticator, IAuthorizatorPolicy authorizatorPolicy)voidstartServer(File configFile)Starts Moquette bringing the configuration from the given filevoidstartServer(Properties configProps)Starts the integration with the given properties.voidstopServer()
-
-
-
Method Detail
-
main
public static void main(String[] args) throws IOException
- Throws:
IOException
-
startServer
public void startServer() throws IOExceptionStarts Moquette bringing the configuration from the file located at m_config/moquette.conf- Throws:
IOException- in case of any IO error.
-
startServer
public void startServer(File configFile) throws IOException
Starts Moquette bringing the configuration from the given file- Parameters:
configFile- text file that contains the configuration.- Throws:
IOException- in case of any IO Error.
-
startServer
public void startServer(Properties configProps) throws IOException
Starts the integration with the given properties.Its suggested to at least have the following properties:
- port
- password_file
- Parameters:
configProps- the properties map to use as configuration.- Throws:
IOException- in case of any IO Error.
-
startServer
public void startServer(IConfig config) throws IOException
Starts Moquette bringing the configuration files from the given Config implementation.- Parameters:
config- the configuration to use to start the broker.- Throws:
IOException- in case of any IO Error.
-
startServer
public void startServer(IConfig config, List<? extends InterceptHandler> handlers) throws IOException
Starts Moquette with config provided by an implementation of IConfig class and with the set of InterceptHandler.- Parameters:
config- the configuration to use to start the broker.handlers- the handlers to install in the broker.- Throws:
IOException- in case of any IO Error.
-
startServer
public void startServer(IConfig config, List<? extends InterceptHandler> handlers, ISslContextCreator sslCtxCreator, IAuthenticator authenticator, IAuthorizatorPolicy authorizatorPolicy)
-
internalPublish
public void internalPublish(io.netty.handler.codec.mqtt.MqttPublishMessage msg, String clientId)Use the broker to publish a message. It's intended for embedding applications. It can be used only after the integration is correctly started with startServer.- Parameters:
msg- the message to forward. The ByteBuf in the message will be released.clientId- the id of the sending integration.- Throws:
IllegalStateException- if the integration is not yet started
-
stopServer
public void stopServer()
-
getPort
public int getPort()
-
getSslPort
public int getSslPort()
-
addInterceptHandler
public void addInterceptHandler(InterceptHandler interceptHandler)
SPI method used by Broker embedded applications to add intercept handlers.- Parameters:
interceptHandler- the handler to add.
-
removeInterceptHandler
public void removeInterceptHandler(InterceptHandler interceptHandler)
SPI method used by Broker embedded applications to remove intercept handlers.- Parameters:
interceptHandler- the handler to remove.
-
listConnectedClients
public Collection<ClientDescriptor> listConnectedClients()
Return a list of descriptors of connected clients.
-
-