Using Rhea
Developing an AMQ messaging client using JavaScript
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!
Rhea is a library for developing messaging applications. It enables you to write JavaScript applications that send and receive AMQP messages.
Red Hat build of Rhea is part of AMQ Clients, a suite of messaging libraries supporting multiple languages and platforms. For information on available clients, see AMQ Clients.
Red Hat build of Rhea is based on the Rhea messaging library. For detailed API documentation, see the Rhea API reference.
1.1. Key features Copy linkLink copied to clipboard!
- An event-driven API that simplifies integration with existing applications
- SSL/TLS for secure communication
- Flexible SASL authentication
- Automatic reconnect and failover
- Seamless conversion between AMQP and language-native data types
- Access to all the features and capabilities of AMQP 1.0
1.2. Supported standards and protocols Copy linkLink copied to clipboard!
Red Hat build of Rhea 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 Rhea 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 |
---|---|
Container | A top-level container of connections. |
Connection | A channel for communication between two peers on a network. It contains sessions. |
Session | A context for sending and receiving messages. It contains senders and receivers. |
Sender | A channel for sending messages to a target. It has a target. |
Receiver | A channel for receiving messages from a source. It has a source. |
Source | A named point of origin for messages. |
Target | A named destination for messages. |
Message | An application-specific piece of information. |
Delivery | A message transfer. |
Red Hat build of Rhea sends and receives messages. Messages are transferred between connected peers over senders and receivers. Senders and receivers are established over sessions. Sessions are established over connections. Connections are established between two uniquely identified containers. Though a connection can have multiple sessions, often this is not needed. The API allows you to ignore sessions unless you require them.
A sending peer creates a sender to send messages. The sender has a target that identifies a queue or topic at the remote peer. A receiving peer creates a receiver to receive messages. The receiver has a source that identifies a queue or topic at the remote peer.
The sending of a message is called a delivery. The message is the content sent, including all metadata such as headers and annotations. The delivery is the protocol exchange associated with the transfer of that content.
To indicate that a delivery is complete, either the sender or the receiver settles it. When the other side learns that it has been settled, it will no longer communicate about that delivery. The receiver can also indicate whether it accepts or rejects the message.
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>
$ cd <project-dir>
Chapter 2. Installation Copy linkLink copied to clipboard!
This chapter guides you through the steps to install Red Hat build of Rhea in your environment.
2.1. Prerequisites Copy linkLink copied to clipboard!
- You must have a subscription to access AMQ release files and repositories.
-
You must install the
npm
command line tool in your environment. See the npm website for more information. - To use Red Hat build of Rhea, you must install Node.js in your environment. See the Node.js website for more information.
-
Red Hat build of Rhea depends on the Node.js
debug
module. See the debug npm page for installation instructions.
2.2. Using the Red Hat NPM registry Copy linkLink copied to clipboard!
Configure your NPM environment to download the client library from the Red Hat NPM registry.
Procedure
Use the
npm config set
command to add the Red Hat NPM registry to your environment:sudo npm config set @redhat:registry https://npm.registry.redhat.com
$ sudo npm config set @redhat:registry https://npm.registry.redhat.com
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Use the
npm install
command to install the client:sudo npm install -g @redhat/rhea@3.0.2-redhat-00001
$ sudo npm install -g @redhat/rhea@3.0.2-redhat-00001
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The procedure above is for system-wide installations. You can run the commands without sudo
and without the -g
option to perform local installations.
To configure your environment to use the installed library, add the node_modules/@redhat
directory to the NODE_PATH
environment variable:
Red Hat Enterprise Linux
export NODE_PATH=/usr/local/lib/node_modules/@redhat:$NODE_PATH
$ export NODE_PATH=/usr/local/lib/node_modules/@redhat:$NODE_PATH
Windows
set NODE_PATH=%AppData%\Roaming\npm\node_modules\@redhat;%NODE_PATH%
$ set NODE_PATH=%AppData%\Roaming\npm\node_modules\@redhat;%NODE_PATH%
To test your installation, use the following command. It prints OK
to the console if it successfully imports the installed library.
node -e 'require("rhea")' && echo OK
$ node -e 'require("rhea")' && echo OK
OK
2.3. Deploying the client in a browser Copy linkLink copied to clipboard!
Red Hat build of Rhea can run inside a web browser. The NPM package includes a file named rhea.js
at the following location that can be used in browser-based applications:
/usr/local/lib/node_modules/@redhat/rhea/dist/rhea.js
/usr/local/lib/node_modules/@redhat/rhea/dist/rhea.js
Copy the rhea.js
file to a location exposed by your web server and reference it using the HTML <script>
element, as in this example:
Example: Running the client in a browser
2.4. Installing the examples Copy linkLink copied to clipboard!
-
Use the
git clone
command to clone the source repository to a local directory namedrhea
:
git clone https://github.com/amqp/rhea.git
$ git clone https://github.com/amqp/rhea.git
Change to the rhea
directory and use the git checkout command to checkout the commit associated with this release:
cd rhea git checkout 3.0.2
$ cd rhea
$ git checkout 3.0.2
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
localhost
and port5672
. It must have anonymous access enabled. For more information, see Starting the broker. -
You must have a queue named
examples
. For more information, see Creating a queue.
3.2. Running Hello World 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 examples
queue, and receives it back. On success, it prints the received message to the console.
Change to the examples directory and run the helloworld.js
example.
cd <source-dir>/examples node helloworld.js
$ cd <source-dir>/examples
$ node helloworld.js
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 examples
queue, and receives it back. On success, it prints the received message to the console.
Change to the examples directory and run the helloworld.js
example.
> cd <source-dir>/examples > node helloworld.js Hello World!
> cd <source-dir>/examples
> node helloworld.js
Hello World!
Chapter 4. Examples Copy linkLink copied to clipboard!
This chapter demonstrates the use of Red Hat build of Rhea through example programs.
For more examples, see the Rhea example suite and the Rhea examples.
4.1. Sending messages Copy linkLink copied to clipboard!
This client program connects to a server using <connection-url>
, creates a sender for target <address>
, sends a message containing <message-body>
, closes the connection, and exits.
Example: Sending messages
Running the example
To run the example program, copy it to a local file and invoke it using the node
command. For more information, see Chapter 3, Getting started.
node send.js amqp://localhost queue1 hello
$ node send.js amqp://localhost queue1 hello
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
Running the example
To run the example program, copy it to a local file and invoke it using the python
command. For more information, see Chapter 3, Getting started.
node receive.js amqp://localhost queue1
$ node receive.js amqp://localhost queue1
Chapter 5. Using the API Copy linkLink copied to clipboard!
For more information, see the Rhea API reference, Rhea example suite and Rhea examples.
5.1. Handling messaging events Copy linkLink copied to clipboard!
Red Hat build of Rhea is an asynchronous event-driven API. To define how the application handles events, the user registers event-handling functions on the container
object. These functions are then called as network activity or timers trigger new events.
Example: Handling messaging events
These are only a few common-case events. The full set is documented in the Rhea API reference.
5.3. Creating a container Copy linkLink copied to clipboard!
The container is the top-level API object. It is the entry point for creating connections, and it is responsible for running the main event loop. It is often constructed with a global event handler.
Example: Creating a container
var rhea = require("rhea"); var container = rhea.create_container();
var rhea = require("rhea");
var container = rhea.create_container();
5.4. Setting the container identity Copy linkLink copied to clipboard!
Each container instance has a unique identity called the container ID. When Red Hat build of Rhea makes a network connection, it sends the container ID to the remote peer. To set the container ID, pass the id
option to the create_container
method.
Example: Setting the container identity
var container = rhea.create_container({id: "job-processor-3"});
var container = rhea.create_container({id: "job-processor-3"});
If the user does not set the ID, the library will generate a UUID when the container is constructed.
Chapter 6. Network connections Copy linkLink copied to clipboard!
6.1. Creating outgoing connections Copy linkLink copied to clipboard!
To connect to a remote server, pass connection options containing the host and port to the container.connect()
method.
Example: Creating outgoing connections
The default host is localhost
. The default port is 5672.
For information about creating secure connections, Chapter 7, Security.
6.2. Configuring reconnect Copy linkLink copied to clipboard!
Reconnect allows a client to recover from lost connections. It is used to ensure that the components in a distributed system reestablish communication after temporary network or component failures.
Red Hat build of Rhea enables reconnect by default. If a connection attempt fails, the client will try again after a brief delay. The delay increases exponentially for each new attempt, up to a default maximum of 60 seconds.
To disable reconnect, set the reconnect
connection option to false
.
Example: Disabling reconnect
To control the delays between connection attempts, set the initial_reconnect_delay
and max_reconnect_delay
connection options. Delay options are specified in milliseconds.
To limit the number of reconnect attempts, set the reconnect_limit
option.
Example: Configuring reconnect
6.3. Configuring failover Copy linkLink copied to clipboard!
Red Hat build of Rhea allows you to configure alternate connection endpoints programatically.
To specify multiple connection endpoints, define a function that returns new connection options and pass the function in the connection_details
option. The function is called once for each connection attempt.
Example: Configuring failover
This example implements repeating round-robin failover for a list of hosts. You can use this interface to implement your own failover behavior.
6.4. Accepting incoming connections Copy linkLink copied to clipboard!
Red Hat build of Rhea can accept inbound network connections, enabling you to build custom messaging servers.
To start listening for connections, use the container.listen()
method with options containing the local host address and port to listen on.
Example: Accepting incoming connections
The special IP address 0.0.0.0
listens on all available IPv4 interfaces. To listen on all IPv6 interfaces, use [::0]
.
For more information, see the server receive.js example.
Chapter 7. Security Copy linkLink copied to clipboard!
7.1. Securing connections with SSL/TLS Copy linkLink copied to clipboard!
Red Hat build of Rhea uses SSL/TLS to encrypt communication between clients and servers.
To connect to a remote server with SSL/TLS, set the transport
connection option to tls
.
Example: Enabling SSL/TLS
By default, the client will reject connections to servers with untrusted certificates. This is sometimes the case in test environments. To bypass certificate authorization, set the rejectUnauthorized
connection option to false
. Be aware that this compromises the security of your connection.
7.2. Connecting with a user and password Copy linkLink copied to clipboard!
Red Hat build of Rhea can authenticate connections with a user and password.
To specify the credentials used for authentication, set the username
and password
connection options.
Example: Connecting with a user and password
7.3. Configuring SASL authentication Copy linkLink copied to clipboard!
Red Hat build of Rhea uses the SASL protocol to perform authentication. SASL can use a number of different authentication mechanisms. When two network peers connect, they exchange their allowed mechanisms, and the strongest mechanism allowed by both is selected.
Red Hat build of Rhea enables SASL mechanisms based on the presence of user and password information. If the user and password are both specified, PLAIN
is used. If only a user is specified, ANONYMOUS
is used. If neither is specified, SASL is disabled.
Chapter 8. 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.
8.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
queue
ortopic
capability on your sender target or receiver source, as in the examples below.
Example: Sending to a queue created on demand
Example: Receiving from a topic created on demand
For more details, see the following examples:
8.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.
Set the connection container ID to a stable value, such as
client-1
:var container = rhea.create_container({id: "client-1"});
var container = rhea.create_container({id: "client-1"});
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a receiver with a stable name, such as
sub-1
, and configure the receiver source for durability by setting thedurable
andexpiry_policy
properties:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
To detach from a subscription, use the receiver.detach()
method. To terminate the subscription, use the receiver.close()
method.
For more information, see the durable-subscribe.js example.
Chapter 9. Error handling Copy linkLink copied to clipboard!
Errors in Red Hat build of Rhea can be handled by intercepting named events corresponding to AMQP protocol or connection errors.
9.1. Handling connection and protocol errors Copy linkLink copied to clipboard!
You can handle protocol-level errors by intercepting the following events:
-
connection_error
-
session_error
-
sender_error
-
receiver_error
-
protocol_error
-
error
These events are fired whenever there is an error condition with the specific object that is in the event. After calling the error handler, the corresponding <object>_close
handler is also called.
The event
argument has an error
attribute for accessing the error object.
Example: Handling errors
container.on("error", function (event) { console.log("An error!", event.error); });
container.on("error", function (event) {
console.log("An error!", event.error);
});
Because the close handlers are called in the event of any error, only the error itself needs to be handled within the error handler. Resource cleanup can be managed by close handlers. If there is no error handling that is specific to a particular object, it is typical to handle the general error
event and not have a more specific handler.
When reconnect is enabled and the remote server closes a connection with the amqp:connection:forced
condition, the client does not treat it as an error and thus does not fire the connection_error
event. The client instead begins the reconnection process.
Chapter 10. Logging Copy linkLink copied to clipboard!
10.1. Configuring logging Copy linkLink copied to clipboard!
Red Hat build of Rhea uses the JavaScript debug module to implement logging.
For example, to enable detailed client logging, set the DEBUG
environment variable to rhea*
:
Example: Enabling detailed logging
export DEBUG=rhea* <your-client-program>
$ export DEBUG=rhea*
$ <your-client-program>
10.2. Enabling protocol logging Copy linkLink copied to clipboard!
The client can log AMQP protocol frames to the console. This data is often critical when diagnosing problems.
To enable protocol logging, set the DEBUG
environment variable to rhea:frames
:
Example: Enabling protocol logging
export DEBUG=rhea:frames <your-client-program>
$ export DEBUG=rhea:frames
$ <your-client-program>
Chapter 11. File-based configuration Copy linkLink copied to clipboard!
Red Hat build of Rhea 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.
11.1. File locations Copy linkLink copied to clipboard!
If set, Red Hat build of Rhea uses the value of the MESSAGING_CONNECT_FILE
environment variable to locate the configuration file.
If MESSAGING_CONNECT_FILE
is not set, Red Hat build of Rhea 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$PWD
is the current working directory of the client process -
$HOME/.config/messaging/connect.json
, where$HOME
is 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.
11.2. The file format Copy linkLink copied to clipboard!
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
11.3. Configuration options Copy linkLink copied to clipboard!
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 |
Chapter 12. Interoperability Copy linkLink copied to clipboard!
This chapter discusses how to use Red Hat build of Rhea in combination with other AMQ components. For an overview of the compatibility of AMQ components, see the product introduction.
12.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 Rhea 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 |
JavaScript has fewer native types than AMQP can encode. To send messages containing specific AMQP types, use the wrap_
functions from the rhea/types.js
module.
AMQP type | Rhea type before encoding | Rhea type after decoding |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rhea type before encoding | AMQ C++ type | Red Hat build of Apache Qpid Proton DotNet type |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| - | - |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rhea type before encoding | Red Hat build of Apache Qpid Proton Python type | |
---|---|---|
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| - | |
|
| |
|
|
12.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 Rhea 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. See the Red Hat build of Apache Qpid JMS Interoperability chapter for more information.
Rhea body type | JMS message type |
---|---|
| |
| |
| |
Any other type |
12.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. 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.
A.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.
A.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.
A.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.
A.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 B. Using AMQ Broker with the examples Copy linkLink copied to clipboard!
The Red Hat build of Rhea examples require a running message broker with a queue named examples
. Use the procedures below to install and start the broker and define the queue.
B.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>
.
B.2. Starting the broker Copy linkLink copied to clipboard!
Procedure
Use the
artemis run
command to start the broker.<broker-instance-dir>/bin/artemis run
$ <broker-instance-dir>/bin/artemis run
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check the console output for any critical errors logged during startup. The broker logs
Server is now live
when it is ready.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
B.3. Creating a queue Copy linkLink copied to clipboard!
In a new terminal, use the artemis queue
command to create a queue named examples
.
<broker-instance-dir>/bin/artemis queue create --name examples --address examples --auto-create-address --anycast
$ <broker-instance-dir>/bin/artemis queue create --name examples --address examples --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.
B.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
$ <broker-instance-dir>/bin/artemis stop
Revised on 2023-12-07 10:11:47 UTC