Skip to main content



      Home
Home » Eclipse Projects » Paho » MaxInflight not adhered in RabbitMQ(Java paho mqtt client max inflight count is not acknowledged by the rabbitMQ mqtt broker)
MaxInflight not adhered in RabbitMQ [message #1871769] Wed, 09 October 2024 06:33 Go to next message
Eclipse UserFriend
Hi,

I am using the org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5 java mqtt client towards RabbitMQ 3.12.10 with the mqtt plugin enabled.
Everything works as expected except that now I have switched to manual acknowledgement and receives only 10 messages (want to recieve 100) by the client until the client acknowledged the recieved messages.

I have tried to configure the client with a higher and lower MaxInflight value without any effect. When I look in the admin console of the RabbitMQ the "mqtt"-consumer always have Prefetch count of 10.

When I configure max inflight to 3, then I would have expected to receive 3 messages and then I would not recieve more until the client had
acknowledged those 3 messages, but I receive 10 messages?

I have configured the client as follows:
    mqttClient = new MqttClient(mqttConfig.serverUri, mqttConfig.clientId)
    mqttClient.setManualAcks(true) // allows later acknowledge
    val connectionOptions: MqttConnectOptions = new MqttConnectOptions()
    connectionOptions.setCleanSession(false)
    connectionOptions.setAutomaticReconnect(true)
    connectionOptions.setUserName("bridge")
    connectionOptions.setPassword(mqttConfig.password.toCharArray)
    connectionOptions.setMaxInflight(3)
    mqttClient.setCallback(new MyCompanyMqttCallback("mytopic"))
    mqttClient.connect(connectionOptions) // The callback subscribes when connected (mqttClient.subscribe("mytopic"))
    mqttClient.getDebug.dumpClientState()


And the debug client state is
2024-10-09 08:03:42,784 FINE  [org.ecl.pah.cli.mqt.int.ClientComms] (I/O dispatcher 1) bridge:
============== bridge : ClientState ==============
quiescing                   :  false
In use msgids               :  {}
lastInboundActivity         :  630529889692000
inFlightPubRels             :  0
pendingFlows                :  []
outboundQoS2                :  {}
pingoutstanding             :  0
outboundQoS1                :  {}
outboundQoS0                :  {}
lastOutboundActivity        :  630529696067600
nextMsgID                   :  1
maxInflight                 :  3
inboundQoS2                 :  {}
pendingMessages             :  []
tokens                      :
actualInFlight              :  0
==========================================


Any ideas about how I can get further information about why the max inflight settings has no effect in my scenario?

Thanks in advance for any input.

Best regards Trym
Re: MaxInflight not adhered in RabbitMQ [message #1871775 is a reply to message #1871769] Thu, 10 October 2024 01:40 Go to previous messageGo to next message
Eclipse UserFriend
Thinking about it, I guess that the RabbitMQ mqtt broker must "take care" of it self, so its configured prefetch count is perhaps some kind of maximum ensuring it has enough memory to keep the messages in memory until acknowledged (if running in some kind of optimized memory mode). But I would have believed that a smaller maxInFlight value should limit how many messages that the client should keep in memory?
Re: MaxInflight not adhered in RabbitMQ [message #1871796 is a reply to message #1871775] Fri, 11 October 2024 03:40 Go to previous message
Eclipse UserFriend
I have tried to read the code implementing the paho mqtt client and stumpled upon the org.eclipse.paho.client.mqttv3.internal.CommsCallback specifically the
private static final int INBOUND_QUEUE_SIZE = 10;

https://github.com/eclipse/paho.mqtt.java/blob/master/org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/internal/CommsCallback.java#L56
which seems to make a hardcoded limit for how many messages a client can receive unacknowledged.

Now when I am rereading the java doc of the getMaxInflight method of the org.eclipse.paho.client.mqttv3.MqttConnectOptions class
        /**
	 * Returns the "max inflight". The max inflight limits to how many messages we
	 * can send without receiving acknowledgments.
         */

It seems that the maxInflight method only concerns limiting the sending of messages and not receiving messages.

So I guess that this is a feature request?

It also seems that this forum is kind of slowing down. Has the vertx-mqtt client taken over?

[Updated on: Fri, 11 October 2024 03:42] by Moderator

Previous Topic:paho mqtt + certs
Next Topic:how to use scram authentication
Goto Forum:
  


Current Time: Tue Jun 17 06:51:46 EDT 2025

Powered by FUDForum. Page generated in 0.03800 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top