YxAc commented on issue #246:
URL: https://github.com/apache/rocketmq-mqtt/issues/246#issuecomment-2119944009

   I will implement this for two parts, around the MQTT Broker.
   - Client -> Broker Publish process
   - Broker -> Client Publish process
   
   **Prerequisites**
   ChannelManager supports flow control interface
   For Broker sending and receiving messages, define the following functions
   - `boolean publishReceiveRefill()`
   - `boolean publishReceiveTryAcquire()`
   - `boolean publishSendRefill()`
   - `boolean publishSendTryAcquire()`
   
   Define `Map <String, AtomicInteger> pubReceiveQuotaMap` for the flow control 
from client publish to server, and count the sending quota for each client.
   Define `Map <String, AtomicInteger> pubSendQuotaMap` for the flow control 
from server publish to client, and count the receiving quota for each client.
   
   Clear the client's flow control quota during Channel cleanup.
   
   **Part I: Client -> Broker**
   
   - When a client initiates `CONN`, the Broker sets the maximum quota that can 
be received by the server when it returns `CONNACK`.
   - When Broker receives a `PUBLISH`, the client's send quota(i.e., Broker 
ReceiveQuota) decrements by 1, if Broker receives more than the maximum quota, 
it uses a `DISCONNECT` packet with Reason Code `0x93` to close the channel.
   - When Broker sends `PUBACK` or `PUBCOMP`, the sending quota of the client 
increments by 1.
   - When Broker sends `PUBREC` and the return code is greater than or equal to 
`0x80/128`, the sending quota of the client increments by 1.
   
   **Part II: Broker -> Client**
   
   - When a client initiates a `CONN`, the Broker gets the receive maximum the 
client can receive.
   - When Broker sends `PUBLISH`, the sending quota(i.e., Broker SendQuota) of 
the client decrements by 1.
   - When Broker receives `PUBACK` or `PUBCOMP`, the sending quota of the 
client increments by 1.
   - When Broker receives `PUBREC` and the return code is greater than or equal 
to `0x80/128`, the sending quota of the client increments by 1.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to