MQContract 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MQContract --version 1.0.0                
NuGet\Install-Package MQContract -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MQContract" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MQContract --version 1.0.0                
#r "nuget: MQContract, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MQContract as a Cake Addin
#addin nuget:?package=MQContract&version=1.0.0

// Install MQContract as a Cake Tool
#tool nuget:?package=MQContract&version=1.0.0                

<a name='assembly'></a>

MQContract

Contents

<a name='T-MQContract-ChannelMapper'></a>

ChannelMapper type

Namespace

MQContract

Summary

Used to map channel names depending on the usage of the channel when necessary

<a name='M-MQContract-ChannelMapper-AddDefaultPublishMap-System-Func{System-String,System-Threading-Tasks-Task{System-String}}-'></a>

AddDefaultPublishMap(mapFunction) method

Summary

Add a default map function to call for publish calls

Returns

The current instance of the Channel Mapper

Parameters
Name Type Description
mapFunction System.Func{System.String,System.Threading.Tasks.Task{System.String}} A function to be called with the channel supplied expecting a mapped channel name

<a name='M-MQContract-ChannelMapper-AddDefaultPublishSubscriptionMap-System-Func{System-String,System-Threading-Tasks-Task{System-String}}-'></a>

AddDefaultPublishSubscriptionMap(mapFunction) method

Summary

Add a default map function to call for pub/sub subscription calls

Returns

The current instance of the Channel Mapper

Parameters
Name Type Description
mapFunction System.Func{System.String,System.Threading.Tasks.Task{System.String}} A function to be called with the channel supplied expecting a mapped channel name

<a name='M-MQContract-ChannelMapper-AddDefaultQueryMap-System-Func{System-String,System-Threading-Tasks-Task{System-String}}-'></a>

AddDefaultQueryMap(mapFunction) method

Summary

Add a default map function to call for query calls

Returns

The current instance of the Channel Mapper

Parameters
Name Type Description
mapFunction System.Func{System.String,System.Threading.Tasks.Task{System.String}} A function to be called with the channel supplied expecting a mapped channel name

<a name='M-MQContract-ChannelMapper-AddDefaultQuerySubscriptionMap-System-Func{System-String,System-Threading-Tasks-Task{System-String}}-'></a>

AddDefaultQuerySubscriptionMap(mapFunction) method

Summary

Add a default map function to call for query/response subscription calls

Returns

The current instance of the Channel Mapper

Parameters
Name Type Description
mapFunction System.Func{System.String,System.Threading.Tasks.Task{System.String}} A function to be called with the channel supplied expecting a mapped channel name

<a name='M-MQContract-ChannelMapper-AddPublishMap-System-String,System-String-'></a>

AddPublishMap(originalChannel,newChannel) method

Summary

Add a direct map for publish calls

Returns

The current instance of the Channel Mapper

Parameters
Name Type Description
originalChannel System.String The original channel that is being used in the connection
newChannel System.String The channel to map it to

<a name='M-MQContract-ChannelMapper-AddPublishMap-System-String,System-Func{System-String,System-Threading-Tasks-Task{System-String}}-'></a>

AddPublishMap(originalChannel,mapFunction) method

Summary

Add a map function for publish calls for a given channel

Returns

The current instance of the Channel Mapper

Parameters
Name Type Description
originalChannel System.String The original channel that is being used in the connection
mapFunction System.Func{System.String,System.Threading.Tasks.Task{System.String}} A function to be called with the channel supplied expecting a mapped channel name

<a name='M-MQContract-ChannelMapper-AddPublishMap-System-Func{System-String,System-Boolean},System-Func{System-String,System-Threading-Tasks-Task{System-String}}-'></a>

AddPublishMap(isMatch,mapFunction) method

Summary

Add a map function call pair for publish calls

Returns

The current instance of the Channel Mapper

Parameters
Name Type Description
isMatch System.Func{System.String,System.Boolean} A callback that will return true if the supplied function will mape that channel
mapFunction System.Func{System.String,System.Threading.Tasks.Task{System.String}} A function to be called with the channel supplied expecting a mapped channel name

<a name='M-MQContract-ChannelMapper-AddPublishSubscriptionMap-System-String,System-String-'></a>

AddPublishSubscriptionMap(originalChannel,newChannel) method

Summary

Add a direct map for pub/sub subscription calls

Returns

The current instance of the Channel Mapper

Parameters
Name Type Description
originalChannel System.String The original channel that is being used in the connection
newChannel System.String The channel to map it to

<a name='M-MQContract-ChannelMapper-AddPublishSubscriptionMap-System-String,System-Func{System-String,System-Threading-Tasks-Task{System-String}}-'></a>

AddPublishSubscriptionMap(originalChannel,mapFunction) method

Summary

Add a map function for pub/sub subscription calls

Returns

The current instance of the Channel Mapper

Parameters
Name Type Description
originalChannel System.String The original channel that is being used in the connection
mapFunction System.Func{System.String,System.Threading.Tasks.Task{System.String}} A function to be called with the channel supplied expecting a mapped channel name

<a name='M-MQContract-ChannelMapper-AddPublishSubscriptionMap-System-Func{System-String,System-Boolean},System-Func{System-String,System-Threading-Tasks-Task{System-String}}-'></a>

AddPublishSubscriptionMap(isMatch,mapFunction) method

Summary

Add a map function call pair for pub/sub subscription calls

Returns

The current instance of the Channel Mapper

Parameters
Name Type Description
isMatch System.Func{System.String,System.Boolean} A callback that will return true if the supplied function will mape that channel
mapFunction System.Func{System.String,System.Threading.Tasks.Task{System.String}} A function to be called with the channel supplied expecting a mapped channel name

<a name='M-MQContract-ChannelMapper-AddQueryMap-System-String,System-String-'></a>

AddQueryMap(originalChannel,newChannel) method

Summary

Add a direct map for query calls

Returns

The current instance of the Channel Mapper

Parameters
Name Type Description
originalChannel System.String The original channel that is being used in the connection
newChannel System.String The channel to map it to

<a name='M-MQContract-ChannelMapper-AddQueryMap-System-String,System-Func{System-String,System-Threading-Tasks-Task{System-String}}-'></a>

AddQueryMap(originalChannel,mapFunction) method

Summary

Add a map function for query calls for a given channel

Returns

The current instance of the Channel Mapper

Parameters
Name Type Description
originalChannel System.String The original channel that is being used in the connection
mapFunction System.Func{System.String,System.Threading.Tasks.Task{System.String}} A function to be called with the channel supplied expecting a mapped channel name

<a name='M-MQContract-ChannelMapper-AddQueryMap-System-Func{System-String,System-Boolean},System-Func{System-String,System-Threading-Tasks-Task{System-String}}-'></a>

AddQueryMap(isMatch,mapFunction) method

Summary

Add a map function call pair for query calls

Returns

The current instance of the Channel Mapper

Parameters
Name Type Description
isMatch System.Func{System.String,System.Boolean} A callback that will return true if the supplied function will mape that channel
mapFunction System.Func{System.String,System.Threading.Tasks.Task{System.String}} A function to be called with the channel supplied expecting a mapped channel name

<a name='M-MQContract-ChannelMapper-AddQuerySubscriptionMap-System-String,System-String-'></a>

AddQuerySubscriptionMap(originalChannel,newChannel) method

Summary

Add a direct map for query/response subscription calls

Returns

The current instance of the Channel Mapper

Parameters
Name Type Description
originalChannel System.String The original channel that is being used in the connection
newChannel System.String The channel to map it to

<a name='M-MQContract-ChannelMapper-AddQuerySubscriptionMap-System-String,System-Func{System-String,System-Threading-Tasks-Task{System-String}}-'></a>

AddQuerySubscriptionMap(originalChannel,mapFunction) method

Summary

Add a map function for query/response subscription calls

Returns

The current instance of the Channel Mapper

Parameters
Name Type Description
originalChannel System.String The original channel that is being used in the connection
mapFunction System.Func{System.String,System.Threading.Tasks.Task{System.String}} A function to be called with the channel supplied expecting a mapped channel name

<a name='M-MQContract-ChannelMapper-AddQuerySubscriptionMap-System-Func{System-String,System-Boolean},System-Func{System-String,System-Threading-Tasks-Task{System-String}}-'></a>

AddQuerySubscriptionMap(isMatch,mapFunction) method

Summary

Add a map function call pair for query/response subscription calls

Returns

The current instance of the Channel Mapper

Parameters
Name Type Description
isMatch System.Func{System.String,System.Boolean} A callback that will return true if the supplied function will mape that channel
mapFunction System.Func{System.String,System.Threading.Tasks.Task{System.String}} A function to be called with the channel supplied expecting a mapped channel name

<a name='T-MQContract-ContractConnection'></a>

ContractConnection type

Namespace

MQContract

Summary

This is the primary class for this library and is used to create a Contract style connection between systems using the underlying service connection layer.

Parameters
Name Type Description
serviceConnection T:MQContract.ContractConnection The service connection implementation to use for the underlying message requests.

<a name='M-MQContract-ContractConnection-#ctor-MQContract-Interfaces-Service-IMessageServiceConnection,MQContract-Interfaces-Encoding-IMessageEncoder,MQContract-Interfaces-Encrypting-IMessageEncryptor,System-IServiceProvider,Microsoft-Extensions-Logging-ILogger,MQContract-ChannelMapper-'></a>

#ctor(serviceConnection,defaultMessageEncoder,defaultMessageEncryptor,serviceProvider,logger,channelMapper) constructor

Summary

This is the primary class for this library and is used to create a Contract style connection between systems using the underlying service connection layer.

Parameters
Name Type Description
serviceConnection MQContract.Interfaces.Service.IMessageServiceConnection The service connection implementation to use for the underlying message requests.
defaultMessageEncoder MQContract.Interfaces.Encoding.IMessageEncoder A default message encoder implementation if desired. If there is no specific encoder for a given type, this encoder would be called. The built in default being used dotnet Json serializer.
defaultMessageEncryptor MQContract.Interfaces.Encrypting.IMessageEncryptor A default message encryptor implementation if desired. If there is no specific encryptor
serviceProvider System.IServiceProvider A service prodivder instance supplied in the case that dependency injection might be necessary
logger Microsoft.Extensions.Logging.ILogger An instance of a logger if logging is desired
channelMapper MQContract.ChannelMapper An instance of a ChannelMapper used to translate channels from one instance to another based on class channel attributes or supplied channels if necessary.
For example, it might be necessary for a Nats.IO instance when you are trying to read from a stored message stream that is comprised of another channel or set of channels

<a name='M-MQContract-ContractConnection-PingAsync'></a>

PingAsync() method

Summary

Called to execute a ping against the service layer

Returns

The ping result from the service layer, if supported

Parameters

This method has no parameters.

<a name='M-MQContract-ContractConnection-PublishAsync1-0,System-String,MQContract-Messages-MessageHeader,MQContract-Interfaces-Service-IServiceChannelOptions,System-Threading-CancellationToken-'></a>

PublishAsync``1(message,channel,messageHeader,options,cancellationToken) method

Summary

Called to publish a message out into the service layer in the Pub/Sub style

Returns

An instance of the TransmissionResult record to indicate success or failure and an ID

Parameters
Name Type Description
message ``0 The instance of the message to publish
channel System.String Used to override the MessageChannelAttribute from the class or to specify a channel to transmit the message on
messageHeader MQContract.Messages.MessageHeader A message header to be sent across with the message
options MQContract.Interfaces.Service.IServiceChannelOptions An instance of a ServiceChannelOptions to pass down to the service layer if desired and/or necessary
cancellationToken System.Threading.CancellationToken A cancellation token
Generic Types
Name Description
T The type of message to publish

<a name='M-MQContract-ContractConnection-QueryAsync1-0,System-Nullable{System-TimeSpan},System-String,MQContract-Messages-MessageHeader,MQContract-Interfaces-Service-IServiceChannelOptions,System-Threading-CancellationToken-'></a>

QueryAsync``1(message,timeout,channel,messageHeader,options,cancellationToken) method

Summary

Called to publish a message in the Query/Response style except the response Type is gathered from the QueryResponseTypeAttribute

Returns

A QueryResult that will contain the response message and or an error

Parameters
Name Type Description
message ``0 The message to transmit for the query
timeout System.Nullable{System.TimeSpan} The timeout to allow for waiting for a response
channel System.String Used to override the MessageChannelAttribute from the class or to specify a channel to transmit the message on
messageHeader MQContract.Messages.MessageHeader A message header to be sent across with the message
options MQContract.Interfaces.Service.IServiceChannelOptions An instance of a ServiceChannelOptions to pass down to the service layer if desired and/or necessary
cancellationToken System.Threading.CancellationToken A cancellation token
Generic Types
Name Description
Q The type of message to transmit for the Query
Exceptions
Name Description
MQContract.UnknownResponseTypeException Thrown when the supplied Query type does not have a QueryResponseTypeAttribute and therefore a response type cannot be determined

<a name='M-MQContract-ContractConnection-QueryAsync2-0,System-Nullable{System-TimeSpan},System-String,MQContract-Messages-MessageHeader,MQContract-Interfaces-Service-IServiceChannelOptions,System-Threading-CancellationToken-'></a>

QueryAsync``2(message,timeout,channel,messageHeader,options,cancellationToken) method

Summary

Called to publish a message in the Query/Response style

Returns

A QueryResult that will contain the response message and or an error

Parameters
Name Type Description
message ``0 The message to transmit for the query
timeout System.Nullable{System.TimeSpan} The timeout to allow for waiting for a response
channel System.String Used to override the MessageChannelAttribute from the class or to specify a channel to transmit the message on
messageHeader MQContract.Messages.MessageHeader A message header to be sent across with the message
options MQContract.Interfaces.Service.IServiceChannelOptions An instance of a ServiceChannelOptions to pass down to the service layer if desired and/or necessary
cancellationToken System.Threading.CancellationToken A cancellation token
Generic Types
Name Description
Q The type of message to transmit for the Query
R The type of message expected as a response

<a name='M-MQContract-ContractConnection-SubscribeAsync1-System-Func{MQContract-Interfaces-IRecievedMessage{0},System-Threading-Tasks-Task},System-Action{System-Exception},System-String,System-String,System-Boolean,System-Boolean,MQContract-Interfaces-Service-IServiceChannelOptions,System-Threading-CancellationToken-'></a>

SubscribeAsync``1(messageRecieved,errorRecieved,channel,group,ignoreMessageHeader,synchronous,options,cancellationToken) method

Summary

Called to establish a Subscription in the sevice layer for the Pub/Sub style messaging

Returns

An instance of the Subscription that can be held or called to end

Parameters
Name Type Description
messageRecieved System.Func{MQContract.Interfaces.IRecievedMessage{``0},System.Threading.Tasks.Task} The callback to be executed when a message is recieved
errorRecieved System.Action{System.Exception} The callback to be executed when an error occurs
channel System.String Used to override the MessageChannelAttribute from the class or to specify a channel to listen for messages on
group System.String Used to specify a group to associate to at the service layer (refer to groups in KubeMQ, Nats.IO, etc)
ignoreMessageHeader System.Boolean If set to true this will cause the subscription to ignore the message type specified and assume that the type of message is of type T
synchronous System.Boolean Set true if the desire the messageRecieved callback to be called such that it waits for the call to complete prior to calling for the next message
options MQContract.Interfaces.Service.IServiceChannelOptions An instance of a ServiceChannelOptions to pass down to the service layer if desired and/or necessary
cancellationToken System.Threading.CancellationToken A cancellation token
Generic Types
Name Description
T The type of message to listen for
Exceptions
Name Description
MQContract.SubscriptionFailedException An exception thrown when the subscription has failed to establish

<a name='M-MQContract-ContractConnection-SubscribeQueryResponseAsync2-System-Func{MQContract-Interfaces-IRecievedMessage{0},System-Threading-Tasks-Task{MQContract-Messages-QueryResponseMessage{``1}}},System-Action{System-Exception},System-String,System-String,System-Boolean,System-Boolean,MQContract-Interfaces-Service-IServiceChannelOptions,System-Threading-CancellationToken-'></a>

SubscribeQueryResponseAsync``2(messageRecieved,errorRecieved,channel,group,ignoreMessageHeader,synchronous,options,cancellationToken) method

Summary

Creates a subscription with the underlying service layer for the Query/Response style

Returns

An instance of the Subscription that can be held or called to end

Parameters
Name Type Description
messageRecieved System.Func{MQContract.Interfaces.IRecievedMessage{``0},System.Threading.Tasks.Task{MQContract.Messages.QueryResponseMessage{``1}}} The callback to be executed when a message is recieved and expects a returned response
errorRecieved System.Action{System.Exception} The callback to be executed when an error occurs
channel System.String Used to override the MessageChannelAttribute from the class or to specify a channel to listen for messages on
group System.String Used to specify a group to associate to at the service layer (refer to groups in KubeMQ, Nats.IO, etc)
ignoreMessageHeader System.Boolean If set to true this will cause the subscription to ignore the message type specified and assume that the type of message is of type T
synchronous System.Boolean Set true if the desire the messageRecieved callback to be called such that it waits for the call to complete prior to calling for the next message
options MQContract.Interfaces.Service.IServiceChannelOptions An instance of a ServiceChannelOptions to pass down to the service layer if desired and/or necessary
cancellationToken System.Threading.CancellationToken A cancellation token
Generic Types
Name Description
Q The expected message type for the Query
R The expected message type for the Response
Exceptions
Name Description
MQContract.SubscriptionFailedException An exception thrown when the subscription has failed to establish

<a name='T-MQContract-MessageChannelNullException'></a>

MessageChannelNullException type

Namespace

MQContract

Summary

Thrown when a call is made but the system is unable to detect the channel

<a name='T-MQContract-MessageConversionException'></a>

MessageConversionException type

Namespace

MQContract

Summary

Thrown when an incoming data message causes a null object return from a converter

<a name='T-MQContract-QueryResponseException'></a>

QueryResponseException type

Namespace

MQContract

Summary

Thrown when a Query call is made and there is an error in the response

<a name='T-MQContract-SubscriptionFailedException'></a>

SubscriptionFailedException type

Namespace

MQContract

Summary

Thrown when a Subscription has failed to be established/created

<a name='T-MQContract-UnknownResponseTypeException'></a>

UnknownResponseTypeException type

Namespace

MQContract

Summary

Thrown when a QueryResponse type message is attempted without specifying the response type and there is no Response Type attribute for the query class.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 106 10/3/2024
1.0.0 121 8/8/2024