Class AzureBusHelper<TAuthenticationToken>
A helper for Azure Service Bus and Event Hub.
Inheritance
Namespace: Cqrs.Azure.ServiceBus
Assembly: Cqrs.Azure.ServiceBus.dll
Syntax
public class AzureBusHelper<TAuthenticationToken> : object, IAzureBusHelper<TAuthenticationToken>
Type Parameters
Name | Description |
---|---|
TAuthenticationToken | The |
Constructors
AzureBusHelper(IAuthenticationTokenHelper<TAuthenticationToken>, ICorrelationIdHelper, ILogger, IMessageSerialiser<TAuthenticationToken>, IBusHelper, IConfigurationManager, IDependencyResolver)
Instantiates a new instance of AzureBusHelper<TAuthenticationToken>.
Declaration
public AzureBusHelper(IAuthenticationTokenHelper<TAuthenticationToken> authenticationTokenHelper, ICorrelationIdHelper correlationIdHelper, ILogger logger, IMessageSerialiser<TAuthenticationToken> messageSerialiser, IBusHelper busHelper, IConfigurationManager configurationManager, IDependencyResolver dependencyResolver)
Parameters
Type | Name | Description |
---|---|---|
IAuthenticationTokenHelper<TAuthenticationToken> | authenticationTokenHelper | |
ICorrelationIdHelper | correlationIdHelper | |
ILogger | logger | |
IMessageSerialiser<TAuthenticationToken> | messageSerialiser | |
IBusHelper | busHelper | |
IConfigurationManager | configurationManager | |
IDependencyResolver | dependencyResolver |
Properties
AuthenticationTokenHelper
Gets or sets the IAuthenticationTokenHelper<TAuthenticationToken>.
Declaration
protected IAuthenticationTokenHelper<TAuthenticationToken> AuthenticationTokenHelper { get; }
Property Value
Type | Description |
---|---|
IAuthenticationTokenHelper<TAuthenticationToken> |
BusHelper
Gets or sets the IBusHelper.
Declaration
protected IBusHelper BusHelper { get; }
Property Value
Type | Description |
---|---|
IBusHelper |
ConfigurationManager
Gets or sets the IConfigurationManager.
Declaration
protected IConfigurationManager ConfigurationManager { get; }
Property Value
Type | Description |
---|---|
IConfigurationManager |
CorrelationIdHelper
Gets or sets the
Declaration
protected ICorrelationIdHelper CorrelationIdHelper { get; }
Property Value
Type | Description |
---|---|
ICorrelationIdHelper |
DependencyResolver
Gets or sets the IDependencyResolver.
Declaration
protected IDependencyResolver DependencyResolver { get; }
Property Value
Type | Description |
---|---|
IDependencyResolver |
Logger
Gets or sets the
Declaration
protected ILogger Logger { get; }
Property Value
Type | Description |
---|---|
ILogger |
MessageSerialiser
Gets or sets the IMessageSerialiser<TAuthenticationToken>.
Declaration
protected IMessageSerialiser<TAuthenticationToken> MessageSerialiser { get; }
Property Value
Type | Description |
---|---|
IMessageSerialiser<TAuthenticationToken> |
Methods
DefaultReceiveCommand(ICommand<TAuthenticationToken>, RouteManager, String)
The default command handler that
check if the ICommand<TAuthenticationToken> has already been processed by this framework,
checks if the ICommand<TAuthenticationToken> is required,
finds the handler from the provided routeManager
.
Declaration
public virtual bool ? DefaultReceiveCommand(ICommand<TAuthenticationToken> command, RouteManager routeManager, string framework)
Parameters
Type | Name | Description |
---|---|---|
ICommand<TAuthenticationToken> | command | The ICommand<TAuthenticationToken> to process. |
RouteManager | routeManager | The RouteManager to get the ICommandHandler<TAuthenticationToken, TCommand> from. |
System.String | framework | The current framework. |
Returns
Type | Description |
---|---|
System.Nullable<System.Boolean> | True indicates the |
Implements
DefaultReceiveEvent(IEvent<TAuthenticationToken>, RouteManager, String)
The default event handler that
check if the IEvent<TAuthenticationToken> has already been processed by this framework,
checks if the IEvent<TAuthenticationToken> is required,
finds the handler from the provided routeManager
.
Declaration
public virtual bool ? DefaultReceiveEvent(IEvent<TAuthenticationToken> event, RouteManager routeManager, string framework)
Parameters
Type | Name | Description |
---|---|---|
IEvent<TAuthenticationToken> | event | The IEvent<TAuthenticationToken> to process. |
RouteManager | routeManager | The RouteManager to get the IEventHandler<TAuthenticationToken, TEvent> from. |
System.String | framework | The current framework. |
Returns
Type | Description |
---|---|
System.Nullable<System.Boolean> | True indicates the |
Implements
PrepareAndValidateCommand<TCommand>(TCommand, String)
Prepares and validates a ICommand<TAuthenticationToken> to be sent specifying the framework it is sent via.
Declaration
public virtual bool PrepareAndValidateCommand<TCommand>(TCommand command, string framework)where TCommand : ICommand<TAuthenticationToken>
Parameters
Type | Name | Description |
---|---|---|
TCommand | command | The ICommand<TAuthenticationToken> to send. |
System.String | framework | The framework the |
Returns
Type | Description |
---|---|
System.Boolean |
Type Parameters
Name | Description |
---|---|
TCommand | The |
Implements
PrepareAndValidateEvent<TEvent>(TEvent, String)
Prepares and validates an IEvent<TAuthenticationToken> to be sent specifying the framework it is sent via.
Declaration
public virtual bool PrepareAndValidateEvent<TEvent>(TEvent event, string framework)where TEvent : IEvent<TAuthenticationToken>
Parameters
Type | Name | Description |
---|---|---|
TEvent | event | The IEvent<TAuthenticationToken> to send. |
System.String | framework | The framework the |
Returns
Type | Description |
---|---|
System.Boolean |
Type Parameters
Name | Description |
---|---|
TEvent | The |
Implements
PrepareCommand<TCommand>(TCommand, String)
Prepares a ICommand<TAuthenticationToken> to be sent specifying the framework it is sent via.
Declaration
public virtual void PrepareCommand<TCommand>(TCommand command, string framework)where TCommand : ICommand<TAuthenticationToken>
Parameters
Type | Name | Description |
---|---|---|
TCommand | command | The ICommand<TAuthenticationToken> to send. |
System.String | framework | The framework the |
Type Parameters
Name | Description |
---|---|
TCommand | The |
Implements
PrepareEvent<TEvent>(TEvent, String)
Prepares an IEvent<TAuthenticationToken> to be sent specifying the framework it is sent via.
Declaration
public virtual void PrepareEvent<TEvent>(TEvent event, string framework)where TEvent : IEvent<TAuthenticationToken>
Parameters
Type | Name | Description |
---|---|---|
TEvent | event | The IEvent<TAuthenticationToken> to send. |
System.String | framework | The framework the |
Type Parameters
Name | Description |
---|---|
TEvent | The |
Implements
ReceiveCommand(String, Func<ICommand<TAuthenticationToken>, Nullable<Boolean>>, String, Action, Action)
Deserialises and processes the messageBody
received from the network through the provided receiveCommandHandler
.
Declaration
public virtual ICommand<TAuthenticationToken> ReceiveCommand(string messageBody, Func<ICommand<TAuthenticationToken>, bool ? > receiveCommandHandler, string messageId, Action skippedAction = null, Action lockRefreshAction = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | messageBody | A serialised IMessage. |
Func<ICommand<TAuthenticationToken>, System.Nullable<System.Boolean>> | receiveCommandHandler | The handler method that will process the ICommand<TAuthenticationToken>. |
System.String | messageId | The network id of the IMessage. |
Action | skippedAction | The |
Action | lockRefreshAction | The |
Returns
Type | Description |
---|---|
ICommand<TAuthenticationToken> | The ICommand<TAuthenticationToken> that was processed. |
Implements
ReceiveEvent(String, Func<IEvent<TAuthenticationToken>, Nullable<Boolean>>, String, Action, Action)
Deserialises and processes the messageBody
received from the network through the provided receiveEventHandler
.
Declaration
public virtual IEvent<TAuthenticationToken> ReceiveEvent(string messageBody, Func<IEvent<TAuthenticationToken>, bool ? > receiveEventHandler, string messageId, Action skippedAction = null, Action lockRefreshAction = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | messageBody | A serialised IMessage. |
Func<IEvent<TAuthenticationToken>, System.Nullable<System.Boolean>> | receiveEventHandler | The handler method that will process the IEvent<TAuthenticationToken>. |
System.String | messageId | The network id of the IMessage. |
Action | skippedAction | The |
Action | lockRefreshAction | The |
Returns
Type | Description |
---|---|
IEvent<TAuthenticationToken> | The IEvent<TAuthenticationToken> that was processed. |
Implements
RefreshLock(CancellationTokenSource, BrokeredMessage, String)
Refreshes the network lock.
Declaration
public virtual void RefreshLock(CancellationTokenSource brokeredMessageRenewCancellationTokenSource, BrokeredMessage message, string type = "message")
Parameters
Type | Name | Description |
---|---|---|
CancellationTokenSource | brokeredMessageRenewCancellationTokenSource | |
BrokeredMessage | message | |
System.String | type |
Implements
RegisterGlobalEventHandler<TMessage>(ITelemetryHelper, RouteManager, Action<TMessage>, Boolean)
Register an event handler that will listen and respond to all events.
Declaration
public void RegisterGlobalEventHandler<TMessage>(ITelemetryHelper telemetryHelper, RouteManager routeManger, Action<TMessage> handler, bool holdMessageLock = true)where TMessage : IMessage
Parameters
Type | Name | Description |
---|---|---|
ITelemetryHelper | telemetryHelper | |
RouteManager | routeManger | |
Action<TMessage> | handler | |
System.Boolean | holdMessageLock |
Type Parameters
Name | Description |
---|---|
TMessage |
Implements
RegisterHandler<TMessage>(ITelemetryHelper, RouteManager, Action<TMessage>, Type, Boolean)
Manually registers the provided handler
on the provided routeManger
Declaration
public virtual void RegisterHandler<TMessage>(ITelemetryHelper telemetryHelper, RouteManager routeManger, Action<TMessage> handler, Type targetedType, bool holdMessageLock = true)where TMessage : IMessage
Parameters
Type | Name | Description |
---|---|---|
ITelemetryHelper | telemetryHelper | |
RouteManager | routeManger | |
Action<TMessage> | handler | |
Type | targetedType | |
System.Boolean | holdMessageLock |
Type Parameters
Name | Description |
---|---|
TMessage | The |