Este conteúdo não está disponível no idioma selecionado.
Chapter 13. File-based configuration
AMQ C++ can read the configuration options used to establish connections from a local file named connect.json. This enables you to configure connections in your application at the time of deployment.
The library attempts to read the file when the application calls the container connect method without supplying any connection options.
13.1. File locations Copiar o linkLink copiado para a área de transferência!
If set, AMQ C++ uses the value of the MESSAGING_CONNECT_FILE environment variable to locate the configuration file.
If MESSAGING_CONNECT_FILE is not set, AMQ C++ searches for a file named connect.json at the following locations and in the order shown. It stops at the first match it encounters.
On Linux:
-
$PWD/connect.json, where$PWDis the current working directory of the client process -
$HOME/.config/messaging/connect.json, where$HOMEis the current user home directory -
/etc/messaging/connect.json
On Windows:
-
%cd%/connect.json, where%cd%is the current working directory of the client process
If no connect.json file is found, the library uses default values for all options.
13.2. The file format Copiar o linkLink copiado para a área de transferência!
The connect.json file contains JSON data, with additional support for JavaScript comments.
All of the configuration attributes are optional or have default values, so a simple example need only provide a few details:
Example: A simple connect.json file
{
"host": "example.com",
"user": "alice",
"password": "secret"
}
{
"host": "example.com",
"user": "alice",
"password": "secret"
}
SASL and SSL/TLS options are nested under "sasl" and "tls" namespaces:
Example: A connect.json file with SASL and SSL/TLS options
13.3. Configuration options Copiar o linkLink copiado para a área de transferência!
The option keys containing a dot (.) represent attributes nested inside a namespace.
| Key | Value type | Default value | Description |
|---|---|---|---|
|
| string |
|
|
|
| string |
| The hostname or IP address of the remote host |
|
| string or number |
| A port number or port literal |
|
| string | None | The user name for authentication |
|
| string | None | The password for authentication |
|
| list or string | None (system defaults) | A JSON list of enabled SASL mechanisms. A bare string represents one mechanism. If none are specified, the client uses the default mechanisms provided by the system. |
|
| boolean |
| Enable mechanisms that send cleartext passwords |
|
| string | None | The filename or database ID of the client certificate |
|
| string | None | The filename or database ID of the private key for the client certificate |
|
| string | None | The filename, directory, or database ID of the CA certificate |
|
| boolean |
| Require a valid server certificate with a matching hostname |