![]() |
VOOZH | about |
dotnet add package MQDotnetClient --version 1.2.0
NuGet\Install-Package MQDotnetClient -Version 1.2.0
<PackageReference Include="MQDotnetClient" Version="1.2.0" />
<PackageVersion Include="MQDotnetClient" Version="1.2.0" />Directory.Packages.props
<PackageReference Include="MQDotnetClient" />Project file
paket add MQDotnetClient --version 1.2.0
#r "nuget: MQDotnetClient, 1.2.0"
#:package MQDotnetClient@1.2.0
#addin nuget:?package=MQDotnetClient&version=1.2.0Install as a Cake Addin
#tool nuget:?package=MQDotnetClient&version=1.2.0Install as a Cake Tool
Dotnet wrapper on top official IBMMQDotnetClient library. Built with resilience and transient-fault-handling
To install the client library via NuGet:
Search for MQDotnetClient in the NuGet Library, or type into the Package Manager Console
Install-Package MQDotnetClient
Type into the dotnet CLI
dotnet add package MQDotnetClient
Configure IBM MQ QueueManager configuration in your appsettings.json
*USER: IBM MQ.NET accesses the current user's certificate store to retrieve the client certificates.
*SYSTEM": IBM MQ.NET accesses the local computer account to retrieve the certificates.
If the CipherSpec value supplied by the application is not a CipherSpec known to IBM MQ, then the IBM MQ managed client disregards it and negotiates the connection based on the Windows system's group policy.
MQSSLRESET: It represents the number of unencrypted bytes sent and received on a TLS channel before the secret key is renegotiated. It is optional
MQSSLCERTREVOCATIONCHECK: The SSLStream class supports certificate revocation checking. It is optional
RetryPolicy
"QueueManager":
{
"SET_MQCONN_PROPERTIES": "true",
"MQSERVER": "DEV.ADMIN.SVRCONN/TCP/localhost(1414)",
"MQCNO_RECONNECT": "false",
"MESSAGE_TIMOUT_IN_MS": "1000", // read timeout if message not found
"USE_ENCODING_LEADING_BYTES": "true",
"MESSAGE_ENCODING": "UTF16",
"USE_MQCSP_AUTHENTICATION_PROPERTY": "false",
"USER_ID_PROPERTY": "admin", // it only use if USE_MQCSP_AUTHENTICATION_PROPERTY is true
"PASSWORD_PROPERTY": "passw0rd",
"SET_MQCONN_SSL": "false",
"MQSSLKEYR": "*USER",
//*USER: IBM� MQ.NET accesses the current user's certificate store to retrieve the client certificates.
//*SYSTEM": IBM MQ.NET accesses the local computer account to retrieve the certificates.
"MQSSLPEERNAME": "PEERNAME",
"MQCERTLABEL": "ibmwebspheremqlogonuserID",
"MQSSLCIPHERSPEC": "TLS_RSA_WITH_AES_128_CBC_SHA",
"MQSSLRESET": "500000",
"MQSSLCERTREVOCATIONCHECK": "false",
"RetryPolicy": {
"RetryCount": 3,
"WaitAndRetrySeconds": 60,
"CircuitBreakerExceptionAllowedCount": 3,
"CircutBreakerTimeoutSeconds": 5
}
}
static void Main(string[] args)
{
private const string QUEUEMANAGER_SECTION = "QueueManager";
private const string QUEUE_MANAGER_NAME = "QUEUE_MANAGER_NAME";
private const string QUEUEMANAGER_RETRY_POLICY_SECTION = "RetryPolicy";
private const string MESSAGE_ENCODING_SECTION = "MESSAGE_ENCODING";
private const string MESSAGE_TIMOUT_IN_MS_SECTION = "MESSAGE_TIMOUT_IN_MS";
private const string USE_ENCODING_LEADING_BYTES_SECTION = "USE_ENCODING_LEADING_BYTES";
var config = ConfigHelper.SetConfiguration();
var serviceProvider = new ServiceCollection()
.AddLogging(builder =>
{
builder.AddConfiguration(config.GetSection("Logging"));
builder.AddConsole();
})
.BuildServiceProvider();
var logger = serviceProvider.GetService<ILogger<QueueManager>>();
// Read QueueManagerModel
QueueManagerModel? queueManagerModel = GetQueueManagerConfig(config);
//Connect your Queue Manager
QueueManager queueManager = new(queueManagerModel, logger);
queueManager.Connect();
//Put Message to Queue
for (int i = 0; i < 100; i++)
{
PutMessage(queueManager, logger, $"This is my test message {i}");
}
// Read the message from the queue
GetMessages(queueManager, logger);
}
private static QueueManagerModel? GetQueueManagerConfig(IConfiguration config)
{
var queueManager = config.GetSection(QUEUEMANAGER_SECTION);
var retryPolicyDic = ConfigHelper.GetDictionary(queueManager.GetSection(QUEUEMANAGER_RETRY_POLICY_SECTION));
List<QueueConfig> queueConfigs = new();
QueueManagerModel? queueManagerModel = null;
var queueManagerConfig = queueManager.GetChildren().ToDictionary(x => x.Key, x => x.Value ?? string.Empty);
if (queueManagerConfig != null)
{
MessageEncoding messageEncoding;
switch (queueManagerConfig[MESSAGE_ENCODING_SECTION].ToUpper())
{
case "UTF8":
messageEncoding = MessageEncoding.UTF8;
break;
case "UTF16":
messageEncoding = MessageEncoding.UTF16;
break;
case "UNICODE":
messageEncoding = MessageEncoding.UTF16;
break;
default:
messageEncoding = MessageEncoding.OTHER;
break;
}
queueManagerModel = new QueueManagerModel
{
ManagerName = queueManagerConfig[QUEUE_MANAGER_NAME],
MessageEncoding = messageEncoding,
Settings = queueManagerConfig,
MessageTimeOutInMs = Convert.ToInt32(queueManagerConfig[MESSAGE_TIMOUT_IN_MS_SECTION]),
UseEncodingLeadBytes = Convert.ToBoolean(queueManagerConfig[USE_ENCODING_LEADING_BYTES_SECTION]),
RetryPolicy = GetRetryPolicy(retryPolicyDic)
};
}
return queueManagerModel;
}
private static QueueRetryPolicy GetRetryPolicy(IDictionary<string, string>? retryPolicyDic)
{
QueueRetryPolicy retryPolicy;
if (retryPolicyDic != null && retryPolicyDic.Any())
{
retryPolicy = new()
{
WaitAndRetrySeconds = Convert.ToInt32(retryPolicyDic["WaitAndRetrySeconds"]),
RetryCount = Convert.ToInt32(retryPolicyDic["RetryCount"]),
CircuitBreakerExceptionAllowedCount = Convert.ToInt32(retryPolicyDic["CircuitBreakerExceptionAllowedCount"]),
CircutBreakerTimeoutSeconds = Convert.ToInt32(retryPolicyDic["CircutBreakerTimeoutSeconds"]),
};
}
else
{
retryPolicy = new();
}
return retryPolicy;
}
Open docker-componse.yml file and copy and create the compose file.
Goto the directory and run below command:
docker compose up -d
You downloaded the pre-built Docker image and ran the container to get MQ running on RHEL. The IBM MQ objects and permissions that the client applications need to connect to a queue manager and to be able to put and get messages to and from the queue are created automatically. Docker and MQ are using your host computer resource and connectivity.
Inside the container, the MQ installation on RHEL has the following objects:
The queue that you will be using, DEV.QUEUE.1, "lives" on the queue manager QM1. The queue manager also has a listener that listens for incoming connections, for example, on port 1414. Client applications can connect to the queue manager and can open, put, and get messages, and close the queue.
Applications use an MQ channel to connect to the queue manager. Access to these three objects is restricted in different ways. For example, user "app", who is a member of the group "mqclient" is permitted to use the channel DEV.APP.SVRCONN and user admin is permitted to use the channel DEV.ADMIN.SVRCONN to connect to the queue manager QM1 and is authorized to put and get messages to and from the queue DEV.QUEUE.1.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.