kev_rm
1
Is there a way to get queue stats (looking for length, published vs ack’d) from this implementation in a DTO of some kind?
I see the use case for redis and I see the MessageHandler class but I don’t see a way to get the message handler back after registering?
mythz
2
Did you see the MQ Status section in the Background MQ docs?
It shows an example BackgroundAdminServices
you can add to get info and stats about each queue.
kev_rm
3
yes but its not a DTO its text.
mythz
4
I’ve added some additional APIs to expose more structured Background MQ stats in this commit.
So you can get info on the Queue Collection for a specific DTO Type with:
var bgService = (BackgroundMqService)container.Resolve<IMessageService>();
var mqCollection = bgService.GetCollection(typeof(Poco));
Dictionary<string, long> statsMap = mqCollection.GetDescriptionMap();
This returns the text info that mqCollection.GetDescription()
returns in a structured Dictionary of stats with the keys:
- ThreadCount
- TotalMessagesAdded
- TotalMessagesTaken
- TotalOutQMessagesAdded
- TotalDlQMessagesAdded
The dictionary also includes each the snapshot counts in each queue in the MQ Collection, e.g:
- mq:Poco.inq
- mq:Poco.priorityq
- mq:Poco.outq
- mq:Poco.dlq
You can also now get Stats of each MQ Worker, there can be multiple workers for each MQ which you can get with:
IMqWorker[] workers = bgService.GetWorkers(QueueNames<Type>.In);
List<IMessageHandlerStats> stats = workers.Map(x => x.GetStats());
And combine them with:
IMessageHandlerStats combinedStats = stats.CombineStats();
This change is available from v5.4.1 that’s now available on MyGet.
1 Like
kev_rm
5
Fantastic, that is amazing, thank you!