forked from ayende/rhino-queues
-
Notifications
You must be signed in to change notification settings - Fork 20
/
linqpad-query.linq
31 lines (29 loc) · 1.12 KB
/
linqpad-query.linq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<Query Kind="Statements">
<Reference>C:\Projects\temp\Rhino.Queues.dll</Reference>
<Namespace>Rhino.Queues.Storage</Namespace>
<Namespace>Rhino.Queues.Model</Namespace>
</Query>
//ATTN: you must right click in this query window and choose Query Properties then add a reference to Rhino.Queues.dll
//PersistentMessage contains the following properties Id, Queue, SentAt, Headers, Data, SubQueue, Bookmark, Status
string pathToQueue = @"Path to folder.esent";
var messages = new List<object>();
Action<IEnumerable<PersistentMessage>> messageSelectAction = msgs =>
messages.AddRange(msgs.Select(m => new {m.Queue, m.SubQueue, m.SentAt, Data = System.Text.Encoding.UTF8.GetString(m.Data) }).ToArray());
using(var qf = new QueueStorage(pathToQueue))
{
qf.Initialize();
qf.Global(actions =>
{
var queueNames = actions.GetAllQueuesNames();
foreach(var name in queueNames)
{
var queue = actions.GetQueue(name);
messageSelectAction(queue.GetAllMessages(null));
foreach(var subQueue in queue.Subqueues)
{
messageSelectAction(queue.GetAllMessages(subQueue));
}
}
});
}
messages.Dump();