So I am using ActiveMQ as a MQTT broker like this:
TransportConnector mqtt = new TransportConnector();
mqtt.setName(mqttBrokerConfig.getBrokerName());
URI uri = new URI("mqtt://some ip");
mqtt.setUri(uri);
final BrokerService broker = new BrokerService();
broker.setUseJmx(false); // Disable JMX for secure purpose
broker.setPersistent(mqttBrokerConfig.getPersistence());
broker.setAdvisorySupport(mqttBrokerConfig.getAdvisorySupport());
if(mqttBrokerConfig.getEnableLogin()) {
SimpleAuthenticationPlugin authenticationPlugin = loadLogins();
broker.setPlugins(new BrokerPlugin[]{authenticationPlugin});
}
broker.setUseShutdownHook(true);
broker.addConnector(mqtt);
I need to accept MQTT message from outside, read the message from the broker, and send it to Kafka. Right now I in the same JVM I created a MQTT client, and connect the broker through 127.0.0.1. Going through the internal network still has some overhead, and the connection could be lost sometimes.
Since the client is in the same JVM as the broker is there a way to read the MQTT messages directly without going through the network? If ActiveMQ does not support such feature is there another java MQTT broker that support it?