@@ -125,8 +125,7 @@ public class ClientState implements MqttState {
125125 private long keepAlive ;
126126 private boolean cleanSession ;
127127 private MqttClientPersistence persistence ;
128-
129- private int maxInflight = 0 ;
128+
130129 private int actualInFlight = 0 ;
131130 private int inFlightPubRels = 0 ;
132131
@@ -185,11 +184,6 @@ protected ClientState(MqttClientPersistence persistence, CommsTokenStore tokenSt
185184 restoreState ();
186185 }
187186
188- protected void setMaxInflight (int maxInflight ) {
189- this .maxInflight = maxInflight ;
190- pendingMessages = new Vector <MqttWireMessage >(this .maxInflight );
191- }
192-
193187 protected void setKeepAliveSecs (long keepAliveSecs ) {
194188 this .keepAlive = keepAliveSecs * 1000 ;
195189 }
@@ -469,7 +463,7 @@ protected void restoreState() throws MqttException {
469463
470464 private void restoreInflightMessages () {
471465 final String methodName = "restoreInflightMessages" ;
472- pendingMessages = new Vector <MqttWireMessage >(this .maxInflight );
466+ pendingMessages = new Vector <MqttWireMessage >(this .mqttSession . getReceiveMaximum () );
473467 pendingFlows = new Vector <MqttWireMessage >();
474468
475469 Enumeration <Integer > keys = outboundQoS2 .keys ();
@@ -560,7 +554,7 @@ public void send(MqttWireMessage message, MqttToken token) throws MqttException
560554
561555 if (message instanceof MqttPublish ) {
562556 synchronized (queueLock ) {
563- if (actualInFlight >= this .maxInflight ) {
557+ if (actualInFlight >= this .mqttSession . getReceiveMaximum () ) {
564558 // @TRACE 613= sending {0} msgs at max inflight window
565559 log .fine (CLASS_NAME , methodName , "613" , new Object [] { Integer .valueOf (actualInFlight ) });
566560
@@ -846,7 +840,7 @@ protected MqttWireMessage get() throws MqttException {
846840 // freed.
847841 // In both cases queueLock will be notified.
848842 if ((pendingMessages .isEmpty () && pendingFlows .isEmpty ())
849- || (pendingFlows .isEmpty () && actualInFlight >= this .maxInflight )) {
843+ || (pendingFlows .isEmpty () && actualInFlight >= this .mqttSession . getReceiveMaximum () )) {
850844 try {
851845 // @TRACE 644=wait for new work or for space in the inflight window
852846 log .fine (CLASS_NAME , methodName , "644" );
@@ -892,7 +886,7 @@ protected MqttWireMessage get() throws MqttException {
892886
893887 // If the inflight window is full then messages are not
894888 // processed until the inflight window has space.
895- if (actualInFlight < this .maxInflight ) {
889+ if (actualInFlight < this .mqttSession . getReceiveMaximum () ) {
896890 // The in flight window is not full so process the
897891 // first message in the queue
898892 result = (MqttWireMessage ) pendingMessages .elementAt (0 );
@@ -1526,16 +1520,6 @@ public int getActualInFlight() {
15261520 return actualInFlight ;
15271521 }
15281522
1529- /*
1530- * (non-Javadoc)
1531- *
1532- * @see org.eclipse.paho.mqttv5.client.internal.MqttState#getMaxInFlight()
1533- */
1534- @ Override
1535- public int getMaxInFlight () {
1536- return maxInflight ;
1537- }
1538-
15391523 /**
15401524 * Tidy up - ensure that tokens are released as they are maintained over a
15411525 * disconnect / connect cycle.
@@ -1576,7 +1560,7 @@ public Properties getDebug() {
15761560 props .put ("In use msgids" , inUseMsgIds );
15771561 props .put ("pendingMessages" , pendingMessages );
15781562 props .put ("pendingFlows" , pendingFlows );
1579- props .put ("maxInflight " , Integer .valueOf (maxInflight ));
1563+ props .put ("serverReceiveMaximum " , Integer .valueOf (this . mqttSession . getReceiveMaximum () ));
15801564 props .put ("nextMsgID" , Integer .valueOf (nextMsgId ));
15811565 props .put ("actualInFlight" , Integer .valueOf (actualInFlight ));
15821566 props .put ("inFlightPubRels" , Integer .valueOf (inFlightPubRels ));
0 commit comments