Using Qpid Proton DotNet
Developing an AMQ messaging client using .NET
Abstract
Making open source more inclusive Copy linkLink copied to clipboard!
Red Hat is committed to replacing problematic language in our code, documentation, and web properties. We are beginning with these four terms: master, slave, blacklist, and whitelist. Because of the enormity of this endeavor, these changes will be implemented gradually over several upcoming releases. For more details, see our CTO Chris Wright’s message.
Chapter 1. Overview Copy linkLink copied to clipboard!
Red Hat build of Apache Qpid Proton DotNet is a lightweight AMQP 1.0 library for the .NET platform. It enables you to write .NET applications that send and receive AMQP messages.
Red Hat build of Apache Qpid Proton DotNet is part of AMQ Clients, a suite of messaging libraries supporting multiple languages and platforms. For information on available clients, see AMQ Clients.
1.1. Key features Copy linkLink copied to clipboard!
- SSL/TLS for secure communication
- Flexible SASL authentication
- Seamless conversion between AMQP and native data types
- Access to all the features and capabilities of AMQP 1.0
- An integrated development environment with full IntelliSense API documentation
1.2. Supported standards and protocols Copy linkLink copied to clipboard!
Red Hat build of Apache Qpid Proton DotNet supports the following industry-recognized standards and network protocols:
- Version 1.0 of the Advanced Message Queueing Protocol (AMQP)
- Versions 1.0, 1.1, 1.2, and 1.3 of the Transport Layer Security (TLS) protocol, the successor to SSL
- Simple Authentication and Security Layer (SASL) mechanisms ANONYMOUS, PLAIN, and EXTERNAL
- Modern TCP with IPv6
1.3. Supported configurations Copy linkLink copied to clipboard!
Refer to Red Hat AMQ Supported Configurations on the Red Hat Customer Portal for current information regarding Red Hat build of Apache Qpid Proton DotNet supported configurations.
1.4. Terms and concepts Copy linkLink copied to clipboard!
This section introduces the core API entities and describes how they operate together.
| Entity | Description |
|---|---|
| Client | A context for creating Connections to Brokers |
| Connection | A channel for communication between two peers on a network |
| Session | A context for sending and receiving messages |
| Sender | A channel for sending messages to a target |
| Receiver | A channel for receiving messages from a source |
| Delivery | A Delivery received from a IReceiver that can be acted upon and contains a message |
| Message | A mutable holder of application data |
Red Hat build of Apache Qpid Proton DotNet sends and receives Messages. Messages are transferred to Brokers via Senders and from Brokers using Receivers. Received Messages are wrapped in a Delivery which can be Accepted, Rejected or Released.
Senders and Receivers are created using Connections which are in turn created using Clients. Sessions are established over Connections.
1.5. Document conventions Copy linkLink copied to clipboard!
The sudo command
In this document, sudo is used for any command that requires root privileges. Exercise caution when using sudo because any changes can affect the entire system. For more information about sudo, see Using the sudo command.
File paths
In this document, all file paths are valid for Linux, UNIX, and similar operating systems (for example, /home/andrea). On Microsoft Windows, you must use the equivalent Windows paths (for example, C:\Users\andrea).
Variable text
This document contains code blocks with variables that you must replace with values specific to your environment. Variable text is enclosed in arrow braces and styled as italic monospace. For example, in the following command, replace <project-dir> with the value for your environment:
$ cd <project-dir>
Chapter 2. Installation Copy linkLink copied to clipboard!
This chapter guides you through the steps to install Red Hat build of Apache Qpid Proton DotNet in your environment.
2.1. Prerequisites Copy linkLink copied to clipboard!
- You must have a subscription to access AMQ release files and repositories.
- To use Red Hat build of Apache Qpid Proton DotNet on Red Hat Enterprise Linux, you must install the the .NET 8.0 developer tools. For information, see the Getting started with .NET on RHEL 9 and Getting started with .NET on RHEL 8.
- To build programs using Red Hat build of Apache Qpid Proton DotNet on Microsoft Windows, you must install Visual Studio.
2.2. Installing on Red Hat Enterprise Linux Copy linkLink copied to clipboard!
Procedure
- Open a browser and log in to the Red Hat Customer Portal Product Downloads page at https://access.redhat.com/downloads
- Locate the Red Hat AMQ Clients entry in the INTEGRATION AND AUTOMATION category.
- Click Red Hat AMQ Clients. The Software Downloads page opens.
- Download the amq-qpid-dotnet-1.0.0 .zip file.
Use the
unzipcommand to extract the file contents into a directory of your choosing.$ unzip amq-qpid-dotnet-1.0.0.zipWhen you extract the contents of the .zip file, a directory named
amq-dotnet-1.0.0is created. This is the top-level directory of the installation and is referred to as<install-dir>throughout this document.Use a text editor to create the file
$HOME/.nuget/NuGet/NuGet.Configand add the following content:<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3"/> <add key="amq-clients" value="<install-dir>/lib"/> </packageSources> </configuration>If you already have a
NuGet.Configfile, add theamq-clientsline to it.Alternatively, you can move the .nupkg file inside the
nupkgdirectory to an existing package source location.
2.3. Installing on Microsoft Windows Copy linkLink copied to clipboard!
Procedure
- Open a browser and log in to the Red Hat Customer Portal Product Downloads page at https://access.redhat.com/downloads
- Locate the Red Hat AMQ Clients entry in the INTEGRATION AND AUTOMATION category.
- Click Red Hat AMQ Clients. The Software Downloads page opens.
- Download the amq-qpid-proton-dotnet-1.0.0 .zip file.
- Extract the file contents into a directory of your choosing by right-clicking on the zip file and selecting Extract All.
When you extract the contents of the .zip file, a directory named amq-dotnet-1.0.0 is created. This is the top-level directory of the installation and is referred to as <install-dir> throughout this document.
2.4. Adding the client to your .NET application Copy linkLink copied to clipboard!
Using the dotnet CLI you can add a reference to the Red Hat build of Apache Qpid Proton DotNet client to your application which will also download release binaries from the Nuget gallery. The following command should be run (with the appropriate version updated) in the location where your project file is saved.
dotnet add package Apache.Qpid.Proton.Client --version 1.0.0
Following this command your csproj file should be updated to contain a reference to to the proton-dotnet client library and should look similar to the following example:
<ItemGroup>
<PackageReference Include="Apache.Qpid.Proton.Client" Version="1.0.0" />
</ItemGroup>
Users can manually add this reference as well and use the dotnet restore command to fetch the artifacts from the Nuget gallery.
2.5. Installing the examples Copy linkLink copied to clipboard!
-
Use the
git clonecommand to clone the source repository to a local directory namedqpid-proton-dotnet:
$ git clone https://github.com/apache/qpid-proton-dotnet.git
Change to the qpid-proton-dotnet directory and use the git checkout command to checkout the commit associated with this release:
$ cd qpid-proton-dotnet
$ git checkout 1.0.0
The resulting local directory is referred to as <source-dir> in this guide.
Chapter 3. Getting started Copy linkLink copied to clipboard!
This chapter guides you through the steps to set up your environment and run a simple messaging program.
3.1. Prerequisites Copy linkLink copied to clipboard!
- You must complete the installation procedure for your environment.
-
You must have an AMQP 1.0 message broker listening for connections on interface
localhostand port5672. It must have anonymous access enabled. For more information, see Starting the broker. -
You must have a queue named
hello-world-example. For more information, see Creating a queue. -
Alternatively, you can specify above information using following environment variables:
HOST,PORT,ADDRESS - The examples are available from the source or upstream
-
Download the amq-qpid-proton-dotnet-1.0.0-src .zip file. When you extract the contents of the .zip file, a directory named
amq-dotnet-1.0.0-srcis created. This is the top-level directory of the installation and is referred to as<src-install-dir>throughout this document.
3.2. Running HelloWorld on Red Hat Enterprise Linux Copy linkLink copied to clipboard!
The Hello World example creates a connection to the broker, sends a message containing a greeting to the hello-world-example queue, and receives it back. On success, it prints the received message to the console.
Change to the <source-dir>/examples/Example.HelloWorld/ and use dotnet run to build and execute the program.
$ cd <source-dir>/examples/Example.HelloWorld/
$ dotnet run
Received message with body: Hello World
3.3. Running Hello World on Microsoft Windows Copy linkLink copied to clipboard!
The Hello World example creates a connection to the broker, sends a message containing a greeting to the hello-world-example queue, and receives it back. On success, it prints the received message to the console.
Procedure
-
Navigate to
<source-dir>and open theProton.slnsolution file in Visual Studio. - Select Build Solution from the Build menu to compile the solution.
Open a command prompt window and execute the following commands to send and receive a message:
> cd <source-dir>\bin\Debug > Example.HelloWorld Received message with body: Hello World
Chapter 4. Examples Copy linkLink copied to clipboard!
This chapter demonstrates the use of Red Hat build of Apache Qpid Proton DotNet through example programs.
The examples are available from the source package or upstream, for more details and examples, see the Qpid Proton DotNet examples.
4.1. Sending messages Copy linkLink copied to clipboard!
This client program connects to a server using <serverHost> and <serverPort>, creates a sender for target <address>, sends 100 messages containing String and exits.
Example: Sending messages
using System;
using Apache.Qpid.Proton.Client;
namespace Apache.Qpid.Proton.Examples.HelloWorld
{
class Program
{
private static readonly int MessageCount = 100;
static void Main(string[] args)
{
string serverHost =
Environment.GetEnvironmentVariable("HOST") ?? "localhost";
int serverPort =
Convert.ToInt32(Environment.GetEnvironmentVariable("PORT") ?? "5672");
string address =
Environment.GetEnvironmentVariable("ADDRESS") ?? "send-receive-example";
IClient client = IClient.Create();
ConnectionOptions options = new ConnectionOptions();
options.User = Environment.GetEnvironmentVariable("USER");
options.Password = Environment.GetEnvironmentVariable("PASSWORD");
using IConnection connection = client.Connect(serverHost, serverPort, options);
using ISender sender = connection.OpenSender(address);
for (int i = 0; i < MessageCount; ++i)
{
IMessage<string> message =
IMessage<string>.Create(string.Format("Hello World! [{0}]", i));
ITracker tracker = sender.Send(message);
tracker.AwaitSettlement();
Console.WriteLine(string.Format("Sent message to {0}: {1}",
sender.Address, message.Body));
}
}
}
}
- 1
using Apache.Qpid.Proton.Client;Imports types defined in the Proton namespace. Proton is defined by a project reference to library file Proton.Net.dll and provides all the classes, interfaces, and value types associated with Red Hat build of Apache Qpid Proton DotNet.- 2
- The number of messages to send.
- 3
serverHostis the network address of the host or virtual host for the AMQP connection and can be configured by setting the Environment variable 'HOST'.- 4
serverPortis the port on the host that the broker is accepting connections and can be configured by setting the environment variablePORT.- 5
Clientis the container that can create multiple Connections to a broker.- 6
optionsis used for various setting, including 'User' and 'Password'. See Section 5.1, “Connection Options” for more information.- 7
connectionis the AMQP Connection to a broker.- 8
- Create a
senderfor transferring messages to the broker. - 9
- In the message send loop a new message is created.
- 10
- The message is sent to the broker.
- 11
- Wait for the broker to settle the message.
Running the example
To run the example program, compile it and execute it from the command line. For more information, see Chapter 3, Getting started.
<source-dir>\bin\Debug>Example.Send
4.2. Receiving messages Copy linkLink copied to clipboard!
This client program connects to a server using <connection-url>, creates a receiver for source <address>, and receives messages until it is terminated or it reaches <count> messages.
Example: Receiving messages
using System;
using Apache.Qpid.Proton.Client;
namespace Apache.Qpid.Proton.Examples.HelloWorld
{
class Program
{
private static readonly int MessageCount = 100;
static void Main(string[] args)
{
string serverHost =
Environment.GetEnvironmentVariable("HOST") ?? "localhost";
int serverPort =
Convert.ToInt32(Environment.GetEnvironmentVariable("PORT") ?? "5672");
string address =
Environment.GetEnvironmentVariable("ADDRESS") ?? "send-receive-example";
IClient client = IClient.Create();
ConnectionOptions options = new ConnectionOptions();
options.User = Environment.GetEnvironmentVariable("USER");
options.Password = Environment.GetEnvironmentVariable("PASSWORD");
using IConnection connection = client.Connect(serverHost, serverPort, options);
using IReceiver receiver = connection.OpenReceiver(address);
for (int i = 0; i < MessageCount; ++i)
{
IDelivery delivery = receiver.Receive();
IMessage<object> received = delivery.Message();
Console.WriteLine("Received message with body: " + received.Body);
}
}
}
}
- 1
using Apache.Qpid.Proton.Client;Imports types defined in the Proton namespace. Proton is defined by a project reference to library file Proton.Net.dll and provides all the classes, interfaces, and value types associated with Red Hat build of Apache Qpid Proton DotNet.- 2
- The number of messages to receive.
- 3
serverHostis the network address of the host or virtual host for the AMQP connection and can be configured by setting the Environment variableHOST.- 4
serverPortis the port on the host that the broker is accepting connections and can be configured by setting the environment variablePORT.- 5
Clientis the container that can create multiple Connections to a broker.- 6
optionsis used for various setting, including 'User' and 'Password'. See Section 5.1, “Connection Options” for more information.- 7
connectionis the AMQP Connection to a broker.- 8
- Create a
receiverfor receiving messages from the broker. - 9
- In the message receive loop a new delivery is received.
- 10
- The message is obtained from the
delivery.
Running the example
To run the example program, compile it and execute it from the command line. For more information, see Chapter 3, Getting started.
<source-dir>\bin\Debug>Example.Receive
Chapter 5. Network connections Copy linkLink copied to clipboard!
5.1. Connection Options Copy linkLink copied to clipboard!
This section describes how to configure how to configure connections.
The ConnectionOptions object can be provided to a Client instance when creating a new connection and allows configuration of several different aspects of the resulting Connection instance.
ConnectionOptions can be passed in the connect method on IClient and are used to configure
Example: Configuring authentication
ConnectionOptions connectionOptions = new ConnectionOptions();
connectionOptions.User = "user"
connectionOptions.Password = "password"
IConnection connection = client.Connect(serverHost, serverPort, connectionOptions);
For a definitive list of options refer to Connection Options
5.1.1. Connection Transport Options Copy linkLink copied to clipboard!
The ConnectionOptions object exposes a set of configuration options for the underlying I/O transport layer known as the TransportOptions which allows for fine grained configuration of network level options.
Example: Configuring transport options
ConnectionOptions connectionOptions = new ConnectionOptions();
connectionOptions.TransportOptions.TcpNoDelay = false;
IConnection connection = client.Connect(serverHost, serverPort, connectionOptions);
For a definitive list of options refer to Connection Transport Options
5.2. Reconnect and failover Copy linkLink copied to clipboard!
When creating a new connection it is possible to configure that connection to perform automatic connection recovery.
Example: Configuring transport reconnection and failover
ConnectionOptions connectionOptions = new ConnectionOptions();
connectionOptions.ReconnectOptions.ReconnectEnabled = true;
connectionOptions.ReconnectOptions.ReconnectDelay = 30_000;
connectionOptions.ReconnectOptions.AddReconnectLocation(<hostname>, <port>);
IConnection connection = client.Connect(serverHost, serverPort, connectionOptions);
For a definitive list of options refer to Reconnect and failover
Chapter 6. Security Copy linkLink copied to clipboard!
6.1. Connecting with a user and password Copy linkLink copied to clipboard!
Red Hat build of Apache Qpid Proton DotNet can authenticate connections with a user and password.
To specify the credentials used for authentication, set the Username and Password fields on the ConnectionOptions object
Example: Connecting with a user and password
ConnectionOptions connectionOptions = new();
connectionOptions.User = "user";
connectionOptions.Password = "pass";
6.2. Configuring SASL authentication Copy linkLink copied to clipboard!
Client connections to remote peers may exchange SASL user name and password credentials. The presence of the user field in the connection URI controls this exchange. If user is specified then SASL credentials are exchanged; if user is absent then the SASL credentials are not exchanged.
Various SASL mechanisms are supported, please see SASL Reference
6.3. Configuring an SSL/TLS transport Copy linkLink copied to clipboard!
Secure communication with servers is achieved using SSL/TLS. A client may be configured for SSL/TLS Handshake only or for SSL/TLS Handshake and client certificate authentication. See the Managing Certificates section for more information.
TLS Server Name Indication (SNI) is handled automatically by the client library. However, SNI is signaled only for addresses that use the amqps transport scheme where the host is a fully qualified domain name or a host name. SNI is not signaled when the host is a numeric IP address.
Chapter 7. Senders and receivers Copy linkLink copied to clipboard!
The client uses sender and receiver links to represent channels for delivering messages. Senders and receivers are unidirectional, with a source end for the message origin, and a target end for the message destination.
Sources and targets often point to queues or topics on a message broker. Sources are also used to represent subscriptions.
7.1. Creating queues and topics on demand Copy linkLink copied to clipboard!
Some message servers support on-demand creation of queues and topics. When a sender or receiver is attached, the server uses the sender target address or the receiver source address to create a queue or topic with a name matching the address.
The message server typically defaults to creating either a queue (for one-to-one message delivery) or a topic (for one-to-many message delivery). The client can indicate which it prefers by setting the queue or topic capability on the source or target.
To select queue or topic semantics, follow these steps:
- Configure your message server for automatic creation of queues and topics. This is often the default configuration.
-
Set either the
queueortopiccapability on your sender target or receiver source, as in the examples below.
Example: Sending to a queue created on demand
SenderOptions senderOptions = new SenderOptions();
senderOptions.TargetOptions.Capabilities = new String []{"queue"};
ISender sender = connection.OpenSender(address, senderOptions);
Example: Receiving from a topic created on demand
ReceiverOptions receiverOptions = new ReceiverOptions();
receiverOptions.SourceOptions.Capabilities = new String [] {"topic"};
using IReceiver receiver = connection.OpenReceiver(address, receiverOptions);
7.2. Creating durable subscriptions Copy linkLink copied to clipboard!
A durable subscription is a piece of state on the remote server representing a message receiver. Ordinarily, message receivers are discarded when a client closes. However, because durable subscriptions are persistent, clients can detach from them and then re-attach later. Any messages received while detached are available when the client re-attaches.
Durable subscriptions are uniquely identified by combining the client container ID and receiver name to form a subscription ID. These must have stable values so that the subscription can be recovered.
To create a durable subscription, follow these steps:
Set the connection container ID to a stable value, such as
client-1:ClientOptions clientOptions = new(); clientOptions.Id = "client-1"; IClient client = IClient.Create(clientOptions);Configure the receiver to act like a topic subscription.
ReceiverOptions receiverOptions = new ReceiverOptions(); receiverOptions.SourceOptions.Capabilities = new String [] {"topic", "shared"}; receiverOptions.SourceOptions.DurabilityMode = DurabilityMode.UnsettledState; receiverOptions.SourceOptions.ExpiryPolicy = ExpiryPolicy.Never; using IReceiver receiver = connection.OpenDurableReceiver(address, "sub-1", receiverOptions);
To detach from a subscription, close the receiver.
Delete the subscription.
receiver.CloseAsync();
if you dont close the receiver then the durable subscription will remain.
Chapter 8. Message delivery Copy linkLink copied to clipboard!
8.1. Sending messages Copy linkLink copied to clipboard!
To send a message, create a client, connection and a sender
Example: Sending messages
IConnection connection = client.Connect(serverHost, serverPort, options);
SenderOptions senderOptions = new SenderOptions();
ISender sender = connection.OpenSender(address, senderOptions);
IMessage<string> message = IMessage<string>.Create("Hello World!"));
ITracker tracker = sender.Send(message);
For more information, see the Send example.
8.2. Tracking sent messages Copy linkLink copied to clipboard!
When the message is sent a Tracker is returned which can be used to track the message or settle it if not using auto settlement
Example: waiting for the broker to settle the message
tracker.AwaitSettlement();
Example: settling the messsage
tracker.Settle();
8.3. Receiving messages Copy linkLink copied to clipboard!
To receive a message, create a connection, client and receiver.
Example: Receiving messages
IConnection connection = client.Connect(serverHost, serverPort, options);
using IReceiver receiver = connection.OpenReceiver(address);
IDelivery delivery = receiver.Receive();
IMessage<object> received = delivery.Message();
The Receiver.Accept() call tells the remote peer that the message was received and processed.
For more information, see the Receive example.
8.4. Acknowledging received messages Copy linkLink copied to clipboard!
The IDelivery object can be used to accept, reject modify the delivery.
Example: Acknowledging received messages
----
delivery.Accept()
----
Example: Rejecting received messages
----
delivery.Reject()
----
Example: Releasing received messages
----
delivery.Release()
----
Chapter 9. Logging Copy linkLink copied to clipboard!
Logging is important in troubleshooting and debugging. By default logging is turned off. To enable logging, you must set a logging level and provide a delegate function to receive the log messages.
9.1. Setting the log output level Copy linkLink copied to clipboard!
The library emits log traces at different levels:
- Error
- Warning
- Information
- Verbose
The lowest log level, Error, traces only error events and produces the fewest log messages. A higher log level includes all the log levels below it and generates a larger volume of log messages.
// Enable Error logs only.
Trace.TraceLevel = TraceLevel.Error
// Enable Verbose logs. This includes logs at all log levels.
Trace.TraceLevel = TraceLevel.Verbose
9.2. Enabling protocol logging Copy linkLink copied to clipboard!
The Log level Frame is handled differently. Setting trace level Frame enables tracing outputs for AMQP protocol headers and frames.
Logical OR must be used to get normal tracing output and AMQP frame tracing at the same time. For example
// Enable just AMQP frame tracing
Trace.TraceLevel = TraceLevel.Frame;
// Enable AMQP Frame logs, and Warning and Error logs
Trace.TraceLevel = TraceLevel.Frame | TraceLevel.Warning;
The following code writes AMQP frames to the console.
Example: Logging delegate
Trace.TraceLevel = TraceLevel.Frame;
Trace.TraceListener = (f, a) => Console.WriteLine(
DateTime.Now.ToString("[hh:mm:ss.fff]") + " " + string.Format(f, a));
Chapter 10. Interoperability Copy linkLink copied to clipboard!
This chapter discusses how to use Red Hat build of Apache Qpid Proton DotNet in combination with other AMQ components. For an overview of the compatibility of AMQ components, see the product introduction.
10.1. Interoperating with other AMQP clients Copy linkLink copied to clipboard!
AMQP messages are composed using the AMQP type system. This common format is one of the reasons AMQP clients in different languages are able to interoperate with each other.
When sending messages, Red Hat build of Apache Qpid Proton DotNet automatically converts language-native types to AMQP-encoded data. When receiving messages, the reverse conversion takes place.
More information about AMQP types is available at the interactive type reference maintained by the Apache Qpid project.
| AMQP type | Description |
|---|---|
| An empty value | |
| A true or false value | |
| A single Unicode character | |
| A sequence of Unicode characters | |
| A sequence of bytes | |
| A signed 8-bit integer | |
| A signed 16-bit integer | |
| A signed 32-bit integer | |
| A signed 64-bit integer | |
| An unsigned 8-bit integer | |
| An unsigned 16-bit integer | |
| An unsigned 32-bit integer | |
| An unsigned 64-bit integer | |
| A 32-bit floating point number | |
| A 64-bit floating point number | |
| A sequence of values of a single type | |
| A sequence of values of variable type | |
| A mapping from distinct keys to values | |
| A universally unique identifier | |
| A 7-bit ASCII string from a constrained domain | |
| An absolute point in time |
| AMQP type | Qpid Proton DotNet type before encoding | Qpid Proton DotNet type after decoding |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Qpid Proton DotNet type before encoding | AMQ C++ type | Red Hat build of Rhea type |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Qpid Proton DotNet type before encoding | Red Hat build of Apache Qpid Proton Python type | |
|---|---|---|
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
| - | |
|
|
| |
|
|
|
10.2. Interoperating with Red Hat build of Apache Qpid JMS Copy linkLink copied to clipboard!
AMQP defines a standard mapping to the JMS messaging model. This section discusses the various aspects of that mapping. For more information, see the Red Hat build of Apache Qpid JMS Interoperability chapter.
JMS message types
Red Hat build of Apache Qpid Proton DotNet provides a single message type whose body type can vary. By contrast, the JMS API uses different message types to represent different kinds of data. The table below indicates how particular body types map to JMS message types.
For more explicit control of the resulting JMS message type, you can set the x-opt-jms-msg-type message annotation.
| Qpid Proton DotNet body type | JMS message type |
|---|---|
|
| |
|
| |
|
| |
| Any other type |
10.3. Connecting to AMQ Broker Copy linkLink copied to clipboard!
AMQ Broker is designed to interoperate with AMQP 1.0 clients. Check the following to ensure the broker is configured for AMQP messaging:
- Port 5672 in the network firewall is open.
- The AMQ Broker AMQP acceptor is enabled. See Default acceptor settings.
- The necessary addresses are configured on the broker. See Addresses, Queues, and Topics.
- The broker is configured to permit access from your client, and the client is configured to send the required credentials. See Broker Security.
Appendix A. Managing certificates Copy linkLink copied to clipboard!
A.1. Installing certificate authority certificates Copy linkLink copied to clipboard!
SSL/TLS authentication relies on digital certificates issued by trusted Certificate Authorities (CAs). When an SSL/TLS connection is established by a client, the AMQP peer sends a server certificate to the client. This server certificate must be signed by one of the CAs in the client’s Trusted Root Certification Authorities certificate store.
If the user is creating self-signed certificates for use by AMQ Broker, then the user must create a CA to sign the certificates. Then the user can enable the client SSL/TLS handshake by installing the self-signed CA file ca.crt.
-
From an administrator command prompt, run the MMC Certificate Manager plugin,
certmgr.msc. - Expand the Trusted Root Certification Authorities folder on the left to expose Certificates.
- Right-click Certificates and select All Tasks and then Import.
- Click Next.
-
Browse to select file
ca.crt. - Click Next.
- Select Place all certificates in the following store.
- Select certificate store Trusted Root Certification Authorities.
- Click Next.
- Click Finish.
For more information about installing certificates, see Managing Microsoft Certificate Services and SSL.
A.2. Installing client certificates Copy linkLink copied to clipboard!
In order to use SSL/TLS and client certificates, the certificates with the client’s private keys must be imported into the proper certificate store on the client system.
-
From an administrator command prompt, run the MMC Certificate Manager plugin,
certmgr.msc. - Expand the Personal folder on the left to expose Certificates.
- Right-click Certificates and select All Tasks and then Import.
- Click Next.
- Click Browse.
-
In the file type pulldown, select Personal Information Exchange
(\.pfx;*.p12). -
Select file
client.p12and click Open. - Click Next.
- Enter the password for the private key password field. Accept the default import options.
- Click Next.
- Select Place all certificates in the following store.
- Select certificate store Personal.
- Click Next.
- Click Finish.
A.3. Using client certificates Copy linkLink copied to clipboard!
Before a client will return a certificate to the broker, the Red Hat build of Apache Qpid Proton DotNet library must be told which certificates to use. The client certificate file client.crt is added to the list of certificates to be used during connection.
ConnectionOptions connectionOptions = new();
connectionOptions.SslOptions.ClientCertificateCollection.Add(
X509Certificate.CreateFromCertFile(certfile)
);
In this example, certfile is the full path to the client.p12 certificate installed in the Personal certificate store.
Appendix B. Using your subscription Copy linkLink copied to clipboard!
AMQ is provided through a software subscription. To manage your subscriptions, access your account at the Red Hat Customer Portal.
B.1. Accessing your account Copy linkLink copied to clipboard!
Procedure
- Go to access.redhat.com.
- If you do not already have an account, create one.
- Log in to your account.
B.2. Activating a subscription Copy linkLink copied to clipboard!
Procedure
- Go to access.redhat.com.
- Navigate to My Subscriptions.
- Navigate to Activate a subscription and enter your 16-digit activation number.
B.3. Downloading release files Copy linkLink copied to clipboard!
To access .zip, .tar.gz, and other release files, use the customer portal to find the relevant files for download. If you are using RPM packages or the Red Hat Maven repository, this step is not required.
Procedure
- Open a browser and log in to the Red Hat Customer Portal Product Downloads page at access.redhat.com/downloads.
- Locate the Red Hat AMQ entries in the INTEGRATION AND AUTOMATION category.
- Select the desired AMQ product. The Software Downloads page opens.
- Click the Download link for your component.
B.4. Registering your system for packages Copy linkLink copied to clipboard!
To install RPM packages for this product on Red Hat Enterprise Linux, your system must be registered. If you are using downloaded release files, this step is not required.
Procedure
- Go to access.redhat.com.
- Navigate to Registration Assistant.
- Select your OS version and continue to the next page.
- Use the listed command in your system terminal to complete the registration.
For more information about registering your system, see one of the following resources:
Appendix C. Using AMQ Broker with the examples Copy linkLink copied to clipboard!
The Red Hat build of Apache Qpid Proton DotNet examples require a running message broker with a queue named hello-world-example. Use the procedures below to install and start the broker and define the queue.
C.1. Installing the broker Copy linkLink copied to clipboard!
Follow the instructions in Getting Started with AMQ Broker to install the broker and create a broker instance. Enable anonymous access.
The following procedures refer to the location of the broker instance as <broker-instance-dir>.
C.2. Starting the broker Copy linkLink copied to clipboard!
Procedure
Use the
artemis runcommand to start the broker.$ <broker-instance-dir>/bin/artemis runCheck the console output for any critical errors logged during startup. The broker logs
Server is now livewhen it is ready.$ example-broker/bin/artemis run __ __ ____ ____ _ /\ | \/ |/ __ \ | _ \ | | / \ | \ / | | | | | |_) |_ __ ___ | | _____ _ __ / /\ \ | |\/| | | | | | _ <| '__/ _ \| |/ / _ \ '__| / ____ \| | | | |__| | | |_) | | | (_) | < __/ | /_/ \_\_| |_|\___\_\ |____/|_| \___/|_|\_\___|_| Red Hat AMQ <version> 2020-06-03 12:12:11,807 INFO [org.apache.activemq.artemis.integration.bootstrap] AMQ101000: Starting ActiveMQ Artemis Server ... 2020-06-03 12:12:12,336 INFO [org.apache.activemq.artemis.core.server] AMQ221007: Server is now live ...
C.3. Creating a queue Copy linkLink copied to clipboard!
In a new terminal, use the artemis queue command to create a queue named hello-world-example.
$ <broker-instance-dir>/bin/artemis queue create --name hello-world-example --address hello-world-example --auto-create-address --anycast
You are prompted to answer a series of yes or no questions. Answer N for no to all of them.
Once the queue is created, the broker is ready for use with the example programs.
C.4. Stopping the broker Copy linkLink copied to clipboard!
When you are done running the examples, use the artemis stop command to stop the broker.
$ <broker-instance-dir>/bin/artemis stop
Revised on 2026-02-25 11:33:50 UTC