I'm currently working with Apache Camel and its MQTT component. I have a route consuming messages from the broker (Apache ActiveMQ artemis) and one other sending messages to it. The problem is that there are no exception thrown when the message broker is not available. Moreover all the messages that are not sent are kept in memory waiting for an eventual restart of the server, causing memory overflows. I don't know if this related to the MQTT protocol itself or to the configuration of the endpoint.
Here is my configuration :
MQTTEndpoint mqttEndpoint = null;
mqttEndpoint = (MQTTEndpoint) mqttComponent.createEndpoint(MQTT_BROKER);
mqttEndpoint.getConfiguration().setHost(properties.getBrokerAddress());
mqttEndpoint.getConfiguration().setPublishTopicName(publishTopicName);
//mqttEndpoint.getConfiguration().setSubscribeTopicNames(subscribreTopicNames);
mqttEndpoint.getConfiguration().setUserName(properties.getBrokerUsername());
mqttEndpoint.getConfiguration().setPassword(properties.getBrokerPassword());
mqttEndpoint.getConfiguration().setSslContext(createSSLContext());
mqttEndpoint.getConfiguration().setByDefaultRetain(false);
mqttEndpoint.getConfiguration().setQualityOfService(QoS.AT_MOST_ONCE.toString());
mqttEndpoint.getConfiguration().setConnectAttemptsMax(1);
mqttEndpoint.getConfiguration().setConnectWaitInSeconds(5);
mqttEndpoint.getConfiguration().setReconnectBackOffMultiplier(1);
mqttEndpoint.getConfiguration().setDisconnectWaitInSeconds(3);
mqttEndpoint.setCamelContext(camelCtx);