forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueueNames.cs
More file actions
83 lines (68 loc) · 1.96 KB
/
QueueNames.cs
File metadata and controls
83 lines (68 loc) · 1.96 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Text;
namespace ServiceStack.Messaging
{
/// <summary>
/// Util static generic class to create unique queue names for types
/// </summary>
/// <typeparam name="T"></typeparam>
public static class QueueNames<T>
{
static QueueNames()
{
var utf8 = new UTF8Encoding(false);
Priority = "mq:" + typeof(T).Name + ".priorityq";
PriorityBytes = utf8.GetBytes(Priority);
In = "mq:" + typeof(T).Name + ".inq";
InBytes = utf8.GetBytes(In);
Out = "mq:" + typeof(T).Name + ".outq";
OutBytes = utf8.GetBytes(Out);
Dlq = "mq:" + typeof(T).Name + ".dlq";
DlqBytes = utf8.GetBytes(Dlq);
}
public static string Priority { get; private set; }
public static byte[] PriorityBytes { get; private set; }
public static string In { get; private set; }
public static byte[] InBytes { get; private set; }
public static string Out { get; private set; }
public static byte[] OutBytes { get; private set; }
public static string Dlq { get; private set; }
public static byte[] DlqBytes { get; private set; }
}
/// <summary>
/// Util class to create unique queue names for runtime types
/// </summary>
public class QueueNames
{
public static string TopicIn = "mq:topic:in";
public static string TopicOut = "mq:topic:out";
public static string QueuePrefix = "";
public static void SetQueuePrefix(string prefix)
{
TopicIn = prefix + "mq:topic:in";
TopicOut = prefix + "mq:topic:out";
QueuePrefix = prefix;
}
private readonly Type messageType;
public QueueNames(Type messageType)
{
this.messageType = messageType;
}
public string Priority
{
get { return QueuePrefix + "mq:" + messageType.Name + ".priorityq"; }
}
public string In
{
get { return QueuePrefix + "mq:" + messageType.Name + ".inq"; }
}
public string Out
{
get { return QueuePrefix + "mq:" + messageType.Name + ".outq"; }
}
public string Dlq
{
get { return QueuePrefix + "mq:" + messageType.Name + ".dlq"; }
}
}
}