Skip to content

Buffered endpoints restart the listener immediately after back pressure is tripped regardless of the restart parameter #1736

@IWillDonut

Description

@IWillDonut

Describe the bug

Apologies if I'm misunderstanding the buffering semantics. The following is based on how I've interpreted the documentation and related blog posts.

After tripping BufferingLimits::Maximum, the BackPressureAgent appears to restart the listener on the next invocation of BackPressureAgent::CheckNowAsync regardless of BufferingLimits::Restart. Note, this is not a bug in the BackPressureAgent itself.

Given the comment in the code, I suspect there is a very good reason that ListeningAgent::_receiver is disposed of and nulled out here. However, this has a side effect of driving _agent.QueueCount to 0 regardless of the state of the BufferedReciever.

To Reproduce
I haven't had time to attempt to write a test that might cover this, but I can try to work on that in the next few days.

Steps to reproduce the behavior:

  1. Create a minimal project with a single buffered endpoint with low BufferingLimits (I tested with RabbitMQ)
  2. Add a single handler for a test message that delays for X seconds
  3. Flood the queue with enough messages to trip the back pressure limits
  4. Observe the listener is restarted on the next tick of the BackPressureAgent::CheckNowAsync regardless of the receiver state

Expected behavior
A buffered endpoint should only restart the listener once the the receiver's queue drops below the BufferingLimits::Restart threshold.

Desktop:

  • OS: Windows 11
  • Version 4.12.2

Additional context
This might have some additional unintended consequences where multiple receivers are active for a listening agent. The disposed receiver appears to continue processing its internal queue in parallel with the receiver that's created on listener restart.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions