Line data Source code
1 : #region Copyright
2 : // // -----------------------------------------------------------------------
3 : // // <copyright company="cdmdotnet Limited">
4 : // // Copyright cdmdotnet Limited. All rights reserved.
5 : // // </copyright>
6 : // // -----------------------------------------------------------------------
7 : #endregion
8 :
9 : using System;
10 : using System.Threading;
11 : using cdmdotnet.Logging;
12 : using Cqrs.Bus;
13 : using Cqrs.Commands;
14 : using Cqrs.Events;
15 : using Cqrs.Messages;
16 : using Microsoft.ServiceBus.Messaging;
17 :
18 : namespace Cqrs.Azure.ServiceBus
19 : {
20 : public interface IAzureBusHelper<TAuthenticationToken>
21 : {
22 0 : void PrepareCommand<TCommand>(TCommand command, string framework)
23 : where TCommand : ICommand<TAuthenticationToken>;
24 :
25 0 : bool PrepareAndValidateCommand<TCommand>(TCommand command, string framework)
26 : where TCommand : ICommand<TAuthenticationToken>;
27 :
28 0 : ICommand<TAuthenticationToken> ReceiveCommand(string messageBody, Func<ICommand<TAuthenticationToken>, bool?> receiveCommandHandler, string messageId, Action skippedAction = null, Action lockRefreshAction = null);
29 :
30 : /// <returns>
31 : /// True indicates the <paramref name="command"/> was successfully handled by a handler.
32 : /// False indicates the <paramref name="command"/> wasn't handled, but didn't throw an error, so by convention, that means it was skipped.
33 : /// Null indicates the command<paramref name="command"/> wasn't handled as it was already handled.
34 : /// </returns>
35 1 : bool? DefaultReceiveCommand(ICommand<TAuthenticationToken> command, RouteManager routeManager, string framework);
36 :
37 0 : void PrepareEvent<TEvent>(TEvent @event, string framework)
38 : where TEvent : IEvent<TAuthenticationToken>;
39 :
40 0 : bool PrepareAndValidateEvent<TEvent>(TEvent @event, string framework)
41 : where TEvent : IEvent<TAuthenticationToken>;
42 :
43 0 : IEvent<TAuthenticationToken> ReceiveEvent(string messageBody, Func<IEvent<TAuthenticationToken>, bool?> receiveCommandHandler, string messageId, Action skippedAction = null, Action lockRefreshAction = null);
44 :
45 0 : void RefreshLock(CancellationTokenSource brokeredMessageRenewCancellationTokenSource, BrokeredMessage message, string type = "message");
46 :
47 : /// <returns>
48 : /// True indicates the <paramref name="event"/> was successfully handled by a handler.
49 : /// False indicates the <paramref name="event"/> wasn't handled, but didn't throw an error, so by convention, that means it was skipped.
50 : /// Null indicates the <paramref name="event"/> wasn't handled as it was already handled.
51 : /// </returns>
52 1 : bool? DefaultReceiveEvent(IEvent<TAuthenticationToken> @event, RouteManager routeManager, string framework);
53 :
54 0 : void RegisterHandler<TMessage>(ITelemetryHelper telemetryHelper, RouteManager routeManger, Action<TMessage> handler, Type targetedType, bool holdMessageLock = true)
55 : where TMessage : IMessage;
56 : }
57 : }
|