0

In MassTransit, I'd like to make an ASP .NET Core healthcheck that considers my app in "degraded health" state, when the "prefetch buffer" is full, and the amount of consumes per second is low enough.

In other words, if there are still messages on the queue, and the consumer is slow. I'll then use this to configure AWS to autoscale my consumers based on the health.

Is there a way to access the amount of messages that have been prefetched, from the outside? Or is this entirely encapsulated within MassTransit?

I'm using ActiveMQ as the underlying transport.

Mathias Lykkegaard Lorenzen
  • 15,031
  • 23
  • 100
  • 187

1 Answers1

2

The message counts are not exposed by MassTransit. You may be able to find something by monitoring ActiveMQ and looking at pending message counts for queues – I don't have any real experience monitoring ActiveMQ because I haven't used it in production.

If you are using metrics with MassTransit, for instance, using Prometheus, you can observe the number of active consumers per queue per instance and use those thresholds to determine if additional instances are needed to handle the load and scale up. That's the approach I would take, since you also get the ability to setup Grafana dashboards to observe system metrics in real time.

Chris Patterson
  • 28,659
  • 3
  • 47
  • 59