## Consumer ### Configuration This is basic configuration for consumer | Name | Description | Default Value | | -------- | -------- | -------- | |Threads|Determine how many the workers consume the new messages| num cpus| | IsEnableRetry | Enable retry and reproduce | false | | RetryMode | (Linear/Exponential) Determine how the delay time is set | Linear| | MaxRetries| How many retry times before the message is dropped (0 is not set) | 0 | |MaxReconnect| How many reconnect times | 10 | |ReconnectAfter| How long should reconnect after fail | 5s| |Timeout| How long is the connection timeout when trying to connect to RabbitMQ| 20s | | Qos | The number of message is prefetched (0 is not set) | 0 | |Delay| How many time the message is putted back to queue after reproduce| 100 ms| ### Flow #### Response OK - UML diagrams ```sequence Queue->Consumer: Consumer consume the message Consumer --> Queue: Ack ``` #### Response Retry - UML diagrams ```sequence Queue->Consumer: Consumer consume the message Note right of Consumer: If IsEnableRetry = false Consumer --> Queue: Ack Note right of Consumer: Else if message is redeliveried Consumer --> Queue: Drop Note right of Consumer: Else Consumer --> Queue: Requeue immediately and marked as redeliveried ``` #### Response Drop - UML diagrams ```sequence Queue->Consumer: Consumer consume the message? Consumer --> Queue: Drop ``` #### Response Reproduce - UML diagrams ```sequence Queue->Consumer: Consume Note right of Consumer: If If IsEnableRetry = false Consumer -> Publisher: Reproduce the message Publisher --> Queue: Put the message to back the queue Note right of Consumer: Else If the max retries is reached Consumer --> Queue: Drop Note right of Consumer: Else Consumer -> Publisher: Reproduce the message after Ts Publisher -> Wait queue: Publish message with an expiration of Ts Note right of Wait queue: Wait until the expiration Wait queue --> Queue: RabbitMQ move the message back to end of queue ```