Skip to content

AMQP publication

The engine can be configured to publish any Notifications that are emitted to an AMQP 1.0-compatible broker.

This is an alternative to the Notification SSE API and is suitable for work queues where the consumers are not within the application boundary, and where scalability is a concern.

Configuration

AMQP publication is enabled by setting the AMQP_BROKER_URL environment variable to the URL of the broker. If it is not set, AMQP publication is disabled and notifications are neither published nor added to the internal publication queue.

The other environment variables that can be used to configure the AMQP publication are documented here.

Multinode notifications

Notifications with the @multinode annotation will not be published to the AMQP broker.

Using RabbitMQ

RabbitMQ is a popular AMQP broker. It is not compatible with the AMQP 1.0 protocol out of the box, but can be configured to support it by installing the AMQP 1.0 plugin.

Delivery guarantees

The engine can only guarantee that messages are delivered at least once to the broker. It is the responsibility of the consumers to handle duplicate messages. This can be done by using the messageId header, which is set to the notification ID.

Serialization format

The AMQP messages use the same serialization format as the Notification SSE API, i.e. ApiNotification.

Simple streaming client

The clients package includes a simple streaming client that can be used to consume notifications from the broker. It is available as AmqpReceiveClientImpl and is configured with an AmqpReceiveClientConfig. Its receiveMessages method can be used to open a stream of notifications from the broker. If the timeout parameter is set, the stream will be closed after waiting to receive a message for the specified duration. If the timeout parameter is not set or is negative, the stream will be kept open indefinitely. A duration of zero will close the stream immediately once no more messages are available.

For more advanced use cases, it is recommended to use the Client from the qpid-protonj2 package directly.