-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMessagingClientFactory.cs
More file actions
594 lines (558 loc) · 28 KB
/
MessagingClientFactory.cs
File metadata and controls
594 lines (558 loc) · 28 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
// =================================================================================================================================
// Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
// =================================================================================================================================
using RapidField.SolidInstruments.Core;
using RapidField.SolidInstruments.Core.ArgumentValidation;
using RapidField.SolidInstruments.Core.Extensions;
using RapidField.SolidInstruments.TextEncoding;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
namespace RapidField.SolidInstruments.Messaging
{
/// <summary>
/// Represents an appliance that manages implementation-specific messaging clients.
/// </summary>
/// <typeparam name="TSender">
/// The type of the implementation-specific send client.
/// </typeparam>
/// <typeparam name="TReceiver">
/// The type of the implementation-specific receive client.
/// </typeparam>
/// <typeparam name="TAdaptedMessage">
/// The type of implementation-specific adapted messages.
/// </typeparam>
/// <typeparam name="TConnection">
/// The type of the connection.
/// </typeparam>
/// <remarks>
/// <see cref="MessagingClientFactory{TSender, TReceiver, TAdaptedMessage, TConnection}" /> is the default implementation of
/// <see cref="IMessagingClientFactory{TSender, TReceiver, TAdaptedMessage}" />.
/// </remarks>
public abstract class MessagingClientFactory<TSender, TReceiver, TAdaptedMessage, TConnection> : Instrument, IMessagingClientFactory<TSender, TReceiver, TAdaptedMessage>
where TAdaptedMessage : class
where TConnection : class
{
/// <summary>
/// Initializes a new instance of the
/// <see cref="MessagingClientFactory{TSender, TReceiver, TConnection, TWrappedMessage}" /> class.
/// </summary>
/// <param name="connection">
/// A connection that governs interaction with messaging entities.
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="connection" /> is <see langword="null" />.
/// </exception>
protected MessagingClientFactory(TConnection connection)
{
Connection = connection.RejectIf().IsNull(nameof(connection));
}
/// <summary>
/// Returns a queue entity path for the specified message type.
/// </summary>
/// <typeparam name="TMessage">
/// The type of the message.
/// </typeparam>
/// <param name="pathLabels">
/// An ordered collection of as many as three non-null, non-empty alphanumeric textual labels to append to the path, or
/// <see langword="null" /> to omit path labels. The default value is <see langword="null" />.
/// </param>
/// <returns>
/// A queue entity path for the specified message type.
/// </returns>
/// <exception cref="ArgumentException">
/// <paramref name="pathLabels" /> contains one or more null or empty labels and/or labels with non-alphanumeric characters,
/// or contains more than three elements.
/// </exception>
public IMessagingEntityPath GetQueuePath<TMessage>(IEnumerable<String> pathLabels)
where TMessage : class => GetEntityPath(EntityPathQueuePrefix, typeof(TMessage), pathLabels);
/// <summary>
/// Gets a shared, managed, implementation-specific message receiver for a type-defined queue.
/// </summary>
/// <typeparam name="TMessage">
/// The type of the message that the client handles.
/// </typeparam>
/// <returns>
/// The managed, implementation-specific message receiver.
/// </returns>
/// <exception cref="MessageListeningException">
/// An exception was raised while creating the client.
/// </exception>
/// <exception cref="ObjectDisposedException">
/// The object is disposed.
/// </exception>
public TReceiver GetQueueReceiver<TMessage>()
where TMessage : class => GetQueueReceiver<TMessage>(pathLabels: null);
/// <summary>
/// Gets a shared, managed, implementation-specific message receiver for a type-defined queue.
/// </summary>
/// <typeparam name="TMessage">
/// The type of the message that the client handles.
/// </typeparam>
/// <param name="pathLabels">
/// An ordered collection of as many as three non-null, non-empty alphanumeric textual labels to append to the path, or
/// <see langword="null" /> to omit path labels. The default value is <see langword="null" />.
/// </param>
/// <returns>
/// The managed, implementation-specific message receiver.
/// </returns>
/// <exception cref="ArgumentException">
/// <paramref name="pathLabels" /> contains one or more null or empty labels and/or labels with non-alphanumeric characters,
/// or contains more than three elements.
/// </exception>
/// <exception cref="MessageListeningException">
/// An exception was raised while creating the client.
/// </exception>
/// <exception cref="ObjectDisposedException">
/// The object is disposed.
/// </exception>
public TReceiver GetQueueReceiver<TMessage>(IEnumerable<String> pathLabels)
where TMessage : class => GetMessageReceiver<TMessage>(MessagingEntityType.Queue, null, pathLabels);
/// <summary>
/// Gets a shared, managed, implementation-specific message sender for a type-defined queue.
/// </summary>
/// <typeparam name="TMessage">
/// The type of the message that the client handles.
/// </typeparam>
/// <returns>
/// The managed, implementation-specific message sender.
/// </returns>
/// <exception cref="MessageTransmissionException">
/// An exception was raised while creating the client.
/// </exception>
/// <exception cref="ObjectDisposedException">
/// The object is disposed.
/// </exception>
public TSender GetQueueSender<TMessage>()
where TMessage : class => GetQueueSender<TMessage>(pathLabels: null);
/// <summary>
/// Gets a shared, managed, implementation-specific message sender for a type-defined queue.
/// </summary>
/// <typeparam name="TMessage">
/// The type of the message that the client handles.
/// </typeparam>
/// <param name="pathLabels">
/// An ordered collection of as many as three non-null, non-empty alphanumeric textual labels to append to the path, or
/// <see langword="null" /> to omit path labels. The default value is <see langword="null" />.
/// </param>
/// <returns>
/// The managed, implementation-specific message sender.
/// </returns>
/// <exception cref="ArgumentException">
/// <paramref name="pathLabels" /> contains one or more null or empty labels and/or labels with non-alphanumeric characters,
/// or contains more than three elements.
/// </exception>
/// <exception cref="MessageTransmissionException">
/// An exception was raised while creating the client.
/// </exception>
/// <exception cref="ObjectDisposedException">
/// The object is disposed.
/// </exception>
public TSender GetQueueSender<TMessage>(IEnumerable<String> pathLabels)
where TMessage : class => GetMessageSender<TMessage>(MessagingEntityType.Queue, pathLabels);
/// <summary>
/// Returns a subscription name for the specified message type.
/// </summary>
/// <typeparam name="TMessage">
/// The type of the message.
/// </typeparam>
/// <param name="receiverIdentifier">
/// A unique textual identifier for the message receiver, or <see langword="null" /> if the receiver is unspecified.
/// </param>
/// <param name="entityPath">
/// The unique path for the entity.
/// </param>
/// <returns>
/// A subscription name for the specified message type.
/// </returns>
/// <exception cref="ArgumentEmptyException">
/// <paramref name="receiverIdentifier" /> is empty.
/// </exception>
/// <exception cref="ArgumentNullException">
/// <paramref name="receiverIdentifier" /> is <see langword="null" /> -or- <paramref name="entityPath" /> is
/// <see langword="null" />.
/// </exception>
public String GetSubscriptionName<TMessage>(String receiverIdentifier, IMessagingEntityPath entityPath)
where TMessage : class
{
var prefix = SubscriptionNamePrefix.IsNullOrEmpty() ? String.Empty : $"{SubscriptionNamePrefix}{MessagingEntityPath.DelimitingCharacterForPrefix}";
var suffix = $"{MessagingEntityPath.DelimitingCharacterForLabelToken}{new ZBase32Encoding().GetString(entityPath.RejectIf().IsNull(nameof(entityPath)).TargetArgument.GetHashCode().ToByteArray())}";
return $"{prefix}{receiverIdentifier.RejectIf().IsNullOrEmpty(nameof(receiverIdentifier)).TargetArgument}{suffix}";
}
/// <summary>
/// Returns a topic entity path for the specified message type.
/// </summary>
/// <typeparam name="TMessage">
/// The type of the message.
/// </typeparam>
/// <param name="pathLabels">
/// An ordered collection of as many as three non-null, non-empty alphanumeric textual labels to append to the path, or
/// <see langword="null" /> to omit path labels. The default value is <see langword="null" />.
/// </param>
/// <returns>
/// A topic entity path for the specified message type.
/// </returns>
/// <exception cref="ArgumentException">
/// <paramref name="pathLabels" /> contains one or more null or empty labels and/or labels with non-alphanumeric characters,
/// or contains more than three elements.
/// </exception>
public IMessagingEntityPath GetTopicPath<TMessage>(IEnumerable<String> pathLabels)
where TMessage : class => GetEntityPath(EntityPathTopicPrefix, typeof(TMessage), pathLabels);
/// <summary>
/// Gets a shared, managed, implementation-specific message receiver for a type-defined topic.
/// </summary>
/// <typeparam name="TMessage">
/// The type of the message that the client handles.
/// </typeparam>
/// <param name="receiverIdentifier">
/// A unique textual identifier for the message receiver, which is appended to the path.
/// </param>
/// <returns>
/// The managed, implementation-specific message receiver.
/// </returns>
/// <exception cref="ArgumentEmptyException">
/// <paramref name="receiverIdentifier" /> is empty.
/// </exception>
/// <exception cref="ArgumentNullException">
/// <paramref name="receiverIdentifier" /> is <see langword="null" />.
/// </exception>
/// <exception cref="MessageListeningException">
/// An exception was raised while creating the client.
/// </exception>
/// <exception cref="ObjectDisposedException">
/// The object is disposed.
/// </exception>
public TReceiver GetTopicReceiver<TMessage>(String receiverIdentifier)
where TMessage : class => GetTopicReceiver<TMessage>(receiverIdentifier, pathLabels: null);
/// <summary>
/// Gets a shared, managed, implementation-specific message receiver for a type-defined topic.
/// </summary>
/// <typeparam name="TMessage">
/// The type of the message that the client handles.
/// </typeparam>
/// <param name="receiverIdentifier">
/// A unique textual identifier for the message receiver, which is appended to the path.
/// </param>
/// <param name="pathLabels">
/// An ordered collection of as many as three non-null, non-empty alphanumeric textual labels to append to the path, or
/// <see langword="null" /> to omit path labels. The default value is <see langword="null" />.
/// </param>
/// <returns>
/// The managed, implementation-specific message receiver.
/// </returns>
/// <exception cref="ArgumentEmptyException">
/// <paramref name="receiverIdentifier" /> is empty.
/// </exception>
/// <exception cref="ArgumentException">
/// <paramref name="pathLabels" /> contains one or more null or empty labels and/or labels with non-alphanumeric characters,
/// or contains more than three elements.
/// </exception>
/// <exception cref="ArgumentNullException">
/// <paramref name="receiverIdentifier" /> is <see langword="null" />.
/// </exception>
/// <exception cref="MessageListeningException">
/// An exception was raised while creating the client.
/// </exception>
/// <exception cref="ObjectDisposedException">
/// The object is disposed.
/// </exception>
public TReceiver GetTopicReceiver<TMessage>(String receiverIdentifier, IEnumerable<String> pathLabels)
where TMessage : class => GetMessageReceiver<TMessage>(MessagingEntityType.Topic, receiverIdentifier.RejectIf().IsNullOrEmpty(nameof(receiverIdentifier)).TargetArgument, pathLabels);
/// <summary>
/// Gets a shared, managed, implementation-specific message sender for a type-defined topic.
/// </summary>
/// <typeparam name="TMessage">
/// The type of the message that the client handles.
/// </typeparam>
/// <returns>
/// The managed, implementation-specific message sender.
/// </returns>
/// <exception cref="MessageTransmissionException">
/// An exception was raised while creating the client.
/// </exception>
/// <exception cref="ObjectDisposedException">
/// The object is disposed.
/// </exception>
public TSender GetTopicSender<TMessage>()
where TMessage : class => GetTopicSender<TMessage>(pathLabels: null);
/// <summary>
/// Gets a shared, managed, implementation-specific message sender for a type-defined topic.
/// </summary>
/// <typeparam name="TMessage">
/// The type of the message that the client handles.
/// </typeparam>
/// <param name="pathLabels">
/// An ordered collection of as many as three non-null, non-empty alphanumeric textual labels to append to the path, or
/// <see langword="null" /> to omit path labels. The default value is <see langword="null" />.
/// </param>
/// <returns>
/// The managed, implementation-specific message sender.
/// </returns>
/// <exception cref="ArgumentException">
/// <paramref name="pathLabels" /> contains one or more null or empty labels and/or labels with non-alphanumeric characters,
/// or contains more than three elements.
/// </exception>
/// <exception cref="MessageTransmissionException">
/// An exception was raised while creating the client.
/// </exception>
/// <exception cref="ObjectDisposedException">
/// The object is disposed.
/// </exception>
public TSender GetTopicSender<TMessage>(IEnumerable<String> pathLabels)
where TMessage : class => GetMessageSender<TMessage>(MessagingEntityType.Topic, pathLabels);
/// <summary>
/// Creates a new implementation-specific client that facilitates receive operations.
/// </summary>
/// <typeparam name="TMessage">
/// The type of the message that the client handles.
/// </typeparam>
/// <param name="connection">
/// A connection that governs interaction with messaging entities.
/// </param>
/// <param name="entityType">
/// The type of the entity.
/// </param>
/// <param name="entityPath">
/// The unique path for the entity.
/// </param>
/// <param name="subscriptionName">
/// The unique name of the subscription.
/// </param>
/// <returns>
/// A new implementation-specific client that facilitates receive operations.
/// </returns>
protected abstract TReceiver CreateMessageReceiver<TMessage>(TConnection connection, MessagingEntityType entityType, IMessagingEntityPath entityPath, String subscriptionName)
where TMessage : class;
/// <summary>
/// Creates a new implementation-specific client that facilitates send operations.
/// </summary>
/// <typeparam name="TMessage">
/// The type of the message that the client handles.
/// </typeparam>
/// <param name="connection">
/// A connection that governs interaction with messaging entities.
/// </param>
/// <param name="entityType">
/// The type of the entity.
/// </param>
/// <param name="entityPath">
/// The unique path for the entity.
/// </param>
/// <returns>
/// A new implementation-specific client that facilitates send operations.
/// </returns>
protected abstract TSender CreateMessageSender<TMessage>(TConnection connection, MessagingEntityType entityType, IMessagingEntityPath entityPath)
where TMessage : class;
/// <summary>
/// Releases all resources consumed by the current
/// <see cref="MessagingClientFactory{TSender, TReceiver, TConnection, TWrappedMessage}" />.
/// </summary>
/// <param name="disposing">
/// A value indicating whether or not managed resources should be released.
/// </param>
protected override void Dispose(Boolean disposing) => base.Dispose(disposing);
/// <summary>
/// Returns an entity path for the specified message type.
/// </summary>
/// <param name="pathPrefix">
/// An alphanumeric path prefix, or <see langword="null" /> to omit a prefix.
/// </param>
/// <param name="messageType">
/// The type of the message.
/// </param>
/// <param name="pathLabels">
/// An ordered collection of as many as three non-null, non-empty alphanumeric textual labels to append to the path, or
/// <see langword="null" /> to omit path labels. The default value is <see langword="null" />.
/// </param>
/// <returns>
/// An entity path for the specified message type.
/// </returns>
/// <exception cref="ArgumentException">
/// <paramref name="pathLabels" /> contains one or more null or empty labels and/or labels with non-alphanumeric characters,
/// or contains more than three elements.
/// </exception>
[DebuggerHidden]
private static IMessagingEntityPath GetEntityPath(String pathPrefix, Type messageType, IEnumerable<String> pathLabels)
{
try
{
return new MessagingEntityPath(messageType, pathPrefix, pathLabels?.ToArray() ?? Array.Empty<String>());
}
catch (Exception exception)
{
throw new ArgumentException("The specified path label information is invalid. See inner exception.", nameof(pathLabels), exception);
}
}
/// <summary>
/// Returns an entity path for the specified entity type and message type.
/// </summary>
/// <typeparam name="TMessage">
/// The type of the message.
/// </typeparam>
/// <param name="entityType">
/// The type of the entity.
/// </param>
/// <param name="pathLabels">
/// An ordered collection of as many as three non-null, non-empty alphanumeric textual labels to append to the path, or
/// <see langword="null" /> to omit path labels. The default value is <see langword="null" />.
/// </param>
/// <returns>
/// An entity path for the specified entity type and message type combination.
/// </returns>
/// <exception cref="ArgumentException">
/// <paramref name="pathLabels" /> contains one or more null or empty labels and/or labels with non-alphanumeric characters,
/// or contains more than three elements.
/// </exception>
[DebuggerHidden]
private IMessagingEntityPath GetEntityPath<TMessage>(MessagingEntityType entityType, IEnumerable<String> pathLabels)
where TMessage : class => entityType switch
{
MessagingEntityType.Queue => GetQueuePath<TMessage>(pathLabels),
MessagingEntityType.Topic => GetTopicPath<TMessage>(pathLabels),
_ => throw new UnsupportedSpecificationException($"The specified entity type, {entityType}, is not supported.")
};
/// <summary>
/// Gets a shared, managed, implementation-specific message receiver.
/// </summary>
/// <typeparam name="TMessage">
/// The type of the message that the client handles.
/// </typeparam>
/// <param name="entityType">
/// The type of the entity.
/// </param>
/// <param name="receiverIdentifier">
/// A unique textual identifier for the message receiver, or <see langword="null" /> if the receiver is unspecified.
/// </param>
/// <param name="pathLabels">
/// An ordered collection of as many as three non-null, non-empty alphanumeric textual labels to append to the path, or
/// <see langword="null" /> to omit path labels. The default value is <see langword="null" />.
/// </param>
/// <returns>
/// The managed, implementation-specific message receiver.
/// </returns>
/// <exception cref="ArgumentException">
/// <paramref name="pathLabels" /> contains one or more null or empty labels and/or labels with non-alphanumeric characters,
/// or contains more than three elements.
/// </exception>
/// <exception cref="MessageListeningException">
/// An exception was raised while creating the client.
/// </exception>
/// <exception cref="ObjectDisposedException">
/// The object is disposed.
/// </exception>
[DebuggerHidden]
private TReceiver GetMessageReceiver<TMessage>(MessagingEntityType entityType, String receiverIdentifier, IEnumerable<String> pathLabels)
where TMessage : class
{
var entityPath = GetEntityPath<TMessage>(entityType.RejectIf().IsEqualToValue(MessagingEntityType.Unspecified, nameof(entityType)), pathLabels);
using (var controlToken = StateControl.Enter())
{
RejectIfDisposed();
if (MessageReceivers.TryGetValue(entityPath.ToString(), out var receiver))
{
return receiver;
}
try
{
var subscriptionName = receiverIdentifier.IsNullOrEmpty() ? null : GetSubscriptionName<TMessage>(receiverIdentifier, entityPath);
receiver = CreateMessageReceiver<TMessage>(Connection, entityType, entityPath, subscriptionName);
}
catch (Exception exception)
{
throw new MessageListeningException(typeof(TMessage), exception);
}
MessageReceivers.Add(entityPath.ToString(), receiver);
return receiver;
}
}
/// <summary>
/// Gets a shared, managed, implementation-specific message sender.
/// </summary>
/// <typeparam name="TMessage">
/// The type of the message that the client handles.
/// </typeparam>
/// <param name="entityType">
/// The type of the entity.
/// </param>
/// <param name="pathLabels">
/// An ordered collection of as many as three non-null, non-empty alphanumeric textual labels to append to the path, or
/// <see langword="null" /> to omit path labels. The default value is <see langword="null" />.
/// </param>
/// <returns>
/// The managed, implementation-specific message sender.
/// </returns>
/// <exception cref="ArgumentException">
/// <paramref name="pathLabels" /> contains one or more null or empty labels and/or labels with non-alphanumeric characters,
/// or contains more than three elements.
/// </exception>
/// <exception cref="MessageTransmissionException">
/// An exception was raised while creating the client.
/// </exception>
/// <exception cref="ObjectDisposedException">
/// The object is disposed.
/// </exception>
[DebuggerHidden]
private TSender GetMessageSender<TMessage>(MessagingEntityType entityType, IEnumerable<String> pathLabels)
where TMessage : class
{
var entityPath = GetEntityPath<TMessage>(entityType.RejectIf().IsEqualToValue(MessagingEntityType.Unspecified, nameof(entityType)), pathLabels);
using (var controlToken = StateControl.Enter())
{
RejectIfDisposed();
if (MessageSenders.TryGetValue(entityPath.ToString(), out var sender))
{
return sender;
}
try
{
sender = CreateMessageSender<TMessage>(Connection, entityType, entityPath);
}
catch (Exception exception)
{
throw new MessageTransmissionException(typeof(TMessage), exception);
}
MessageSenders.Add(entityPath.ToString(), sender);
return sender;
}
}
/// <summary>
/// Gets an entity path prefix for queues.
/// </summary>
protected virtual String EntityPathQueuePrefix => null;
/// <summary>
/// Gets an entity path prefix for topics.
/// </summary>
protected virtual String EntityPathTopicPrefix => null;
/// <summary>
/// Gets a name prefix for subscriptions.
/// </summary>
protected virtual String SubscriptionNamePrefix => null;
/// <summary>
/// Gets a collection of message receivers that are keyed by entity path.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private IDictionary<String, TReceiver> MessageReceivers => LazyMessageReceivers.Value;
/// <summary>
/// Gets a collection of message senders that are keyed by entity path.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private IDictionary<String, TSender> MessageSenders => LazyMessageSenders.Value;
/// <summary>
/// Represents a connection that governs interaction with messaging entities.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly TConnection Connection;
/// <summary>
/// Represents a lazily-initialized collection of message receivers that are keyed by entity path.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly Lazy<IDictionary<String, TReceiver>> LazyMessageReceivers = new Lazy<IDictionary<String, TReceiver>>(() => new Dictionary<String, TReceiver>(), LazyThreadSafetyMode.ExecutionAndPublication);
/// <summary>
/// Represents a lazily-initialized collection of message senders that are keyed by entity path.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly Lazy<IDictionary<String, TSender>> LazyMessageSenders = new Lazy<IDictionary<String, TSender>>(() => new Dictionary<String, TSender>(), LazyThreadSafetyMode.ExecutionAndPublication);
}
}