Skip to content

Commit 87293be

Browse files
committed
Update BackgroundMqService.cs
Add ability to traverse Background MQ messages
1 parent 6b3ce27 commit 87293be

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

ServiceStack/src/ServiceStack/Messaging/BackgroundMqService.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ public class BackgroundMqCollection<T> : IMqCollection
492492

493493
private long totalOutQMessagesAdded = 0;
494494
private long totalDlQMessagesAdded = 0;
495+
public string[] QueueNames { get; }
495496

496497
public BackgroundMqCollection(BackgroundMqClient mqClient, IMessageHandlerFactory handlerFactory, int threadCount, int outQMaxSize)
497498
{
@@ -506,6 +507,13 @@ public BackgroundMqCollection(BackgroundMqClient mqClient, IMessageHandlerFactor
506507
{ QueueNames<T>.Dlq, new BlockingCollection<IMessage>() },
507508
{ QueueNames<T>.Out, new BlockingCollection<IMessage>() },
508509
};
510+
QueueNames = new[]
511+
{
512+
QueueNames<T>.In,
513+
QueueNames<T>.Priority,
514+
QueueNames<T>.Dlq,
515+
QueueNames<T>.Out,
516+
};
509517
}
510518

511519
public void Add(string queueName, IMessage message)
@@ -640,7 +648,20 @@ public Dictionary<string, long> GetDescriptionMap()
640648

641649
return to;
642650
}
643-
651+
652+
public List<IMessage> GetQueueMessages(string queueName)
653+
{
654+
var to = new List<IMessage>();
655+
if (queueMap.TryGetValue(queueName, out var mq))
656+
{
657+
foreach (var msg in mq)
658+
{
659+
to.Add(msg);
660+
}
661+
}
662+
return to;
663+
}
664+
644665
//Called when AppHost is disposing
645666
public void Dispose()
646667
{

0 commit comments

Comments
 (0)