Este contenido no está disponible en el idioma seleccionado.

Chapter 5. Using the API


For more information, see the AMQ JavaScript API reference and AMQ JavaScript example suite.

5.1. Handling messaging events

AMQ JavaScript 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

var rhea = require("rhea");
var container = rhea.create_container();

container.on("sendable", function (event) {
    console.log("A message can be sent");
});

container.on("message", function (event) {
    console.log("A message is received");
});
Copy to Clipboard Toggle word wrap

These are only a few common-case events. The full set is documented in the {ClientAmqpJavaScriptApiLink}.

5.3. Creating a container

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();
Copy to Clipboard Toggle word wrap

5.4. Setting the container identity

Each container instance has a unique identity called the container ID. When AMQ JavaScript 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"});
Copy to Clipboard Toggle word wrap

If the user does not set the ID, the library will generate a UUID when the container is constucted.

Volver arriba
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2025 Red Hat