CDI Event Bus Notifier

The CDI Event Bus Notifier provides a way to send notifications from the Notification service into the internal Payara event bus.

Requirements

The Domain Data Grid must be enabled for the CDI Event Bus to be available.

CDI Event Bus Notifier Configuration

Admin console config

Enabled

Enables/Disables the CDI Event Bus notifier.

Dynamic

Applies changes to the notifier without a server restart.

Loop Back

Enables/Disables whether messages should also fire on the same instance or not

Make sure that the Enabled box is ticked so that the notifier will be used. If you would like the changes to take effect without needing a restart, tick the Dynamic box as well. If you want to receive the message events on the same instance, tick the "Loop Back" box as well. Otherwise, messages will be received only by remote Payara instances.

To make these changes via the asadmin tool, use the following command, which mirrors the above screenshot:

asadmin> set-cdieventbus-notifier-configuration --loopBack=true --dynamic=true --enabled=true --hazelcastEnabled=true

To check the current applied configuration from asadmin, run the command:

asadmin> get-cdieventbus-notifier-configuration

This will return the current configuration, with whether it is currently enabled and if looping back is enabled:

$ asadmin get-cdieventbus-notifier-configuration
Enabled  Noisy  Loopback
false    true   false

Observing Notification Events

Any application deployed to any instance in the same cluster can observe notification events triggered by the CDI event bus notifier.

It would receive an instance of EventbusMessage (which extends Notification) that provides structured data about specific event type, such as HealthCheckNotificationData or RequestTracingNotificationData. It also provides the same information in a String form in the title and message fields.

In order to observe the events in an application, use the Payara API artifact as a compile time dependency.

Notification events can be observed as a standard @Inbound CDI event of type EventbusMessage or its supertypes:

    public void observe(@Observes @Inbound EventbusMessage event) {
        String shortInfo = event.getSubject()
        String detailedMessage = event.getMessage();

        String domainName = event.getDomain();
        String sourceInstanceName = event.getInstance();

        if (event.getData() instanceof HealthCheckNotificationData) {
            Optional<HealthCheckResultEntry> mostCritical = event.getData()
            .as(HealthCheckNotificationData.class).getEntries()
            .stream().sorted().findFirst();
        }
    }