-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathActiveMqQueueConfiguration.cs
More file actions
117 lines (101 loc) · 3.37 KB
/
ActiveMqQueueConfiguration.cs
File metadata and controls
117 lines (101 loc) · 3.37 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using ViennaNET.Messaging.Configuration;
namespace ViennaNET.Messaging.ActiveMQQueue
{
/// <summary>
/// Настройки очереди ActiveMQ
/// </summary>
public class ActiveMqQueueConfiguration : QueueConfigurationBase, IValidatableObject
{
/// <summary>
/// Пользователь (пусто - без авторизации)
/// </summary>
public string? User { get; set; }
/// <summary>
/// Пароль
/// </summary>
public string? Password { get; set; }
/// <summary>
/// Клиентский идентификатор
/// </summary>
public string? ClientId { get; set; }
/// <summary>
/// Сервер
/// </summary>
public string Server { get; set; }
/// <summary>
/// Порт
/// </summary>
public ushort? Port { get; set; }
/// <summary>
/// Признак использования строки подключения
/// </summary>
public bool UseQueueString { get; set; }
/// <summary>
/// Строка подключения
/// </summary>
public string? QueueString { get; set; }
/// <summary>
/// Имя очереди
/// </summary>
public string? QueueName { get; set; }
/// <summary>
/// Признак работы в транзакции
/// </summary>
public bool TransactionEnabled { get; set; }
/// <summary>
/// Селектор для вычитывания из очереди отфильтрованных сообщений
/// </summary>
public string? Selector { get; set; }
/// <summary>
/// Строка подключения к брокеру
/// </summary>
[RegularExpression("^(activemq|amqp|failover):.+",
ErrorMessage = "URI scheme must be either 'activemq' or 'amqp' or 'failover'")]
public Uri? ConnectionString { get; set; }
/// <summary>
/// Очередь для ответа
/// </summary>
public string? ReplyQueue { get; set; }
/// <summary>
/// Время жизни сообщения и время ожидания ответа
/// </summary>
public TimeSpan? Lifetime
{
get;
set;
}
/// <inheritdoc />
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (ConnectionString == null && string.IsNullOrWhiteSpace(Server))
{
yield return new ValidationResult("ConnectionString or Server should be set",
new[] { nameof(ConnectionString), nameof(Server) });
}
if (UseQueueString)
{
if (string.IsNullOrWhiteSpace(QueueString))
{
yield return new ValidationResult("If UseQueueString is true, QueueString should be set",
new[] { nameof(QueueString) });
}
}
else
{
if (string.IsNullOrWhiteSpace(QueueName))
{
yield return new ValidationResult("If UseQueueString is false, QueueName should be set",
new[] { nameof(QueueName) });
}
}
if (TransactionEnabled && ProcessingType != MessageProcessingType.ThreadStrategy)
{
yield return new ValidationResult("Only ThreadStrategy is supported with transactions enabled",
new[] { nameof(ProcessingType) });
}
}
}
}