Quarkus Real-Time Events

This guide adds an SSE events proxy endpoint to the Quarkus tutorial app. For full details on event kinds, format, and connection lifecycle, see Real-Time Events.

Prerequisites

Starting checkpoint: java/quarkus/examples/doc-checkpoints/03-with-history

SSE Events Proxy

Checkpoint 03b adds an events proxy endpoint that forwards SSE from Memory Service to the frontend:

EventsResource.java
package org.acme;

import io.github.chirino.memory.runtime.MemoryServiceProxy;
import io.github.chirino.memory.runtime.MemoryServiceProxy.EventNotification;
import io.smallrye.mutiny.Multi;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;

@Path("/v1/events")
@ApplicationScoped
public class EventsResource {

    @Inject MemoryServiceProxy proxy;

    @GET
    @Produces(MediaType.SERVER_SENT_EVENTS)
    public Multi<EventNotification> streamEvents(@QueryParam("kinds") String kinds) {
        return proxy.streamEvents(kinds).filter(EventsResource::isFrontendVisible);
    }

    private static boolean isFrontendVisible(EventNotification event) {
        if (!"entry".equals(event.kind())) {
            return true;
        }
        Object channel = event.data() == null ? null : event.data().get("entry_channel");
        return "history".equals(channel);
    }
}

Why proxy? The agent app sits between the frontend and Memory Service. Proxying the SSE stream lets the app forward the caller’s Bearer token for authorization while injecting the agent’s API key for service authentication. Frontends never talk directly to Memory Service.

The checkpoint handler forwards only history-channel entry notifications to browser clients. Context-channel entries are agent-internal and can include prompt context, summaries, retrieval results, or tool payloads.

Connecting

Subscribe to events through the agent app:

curl -N -H "Authorization: Bearer $(get-token)" \
  http://localhost:9090/v1/events

Filter to specific event kinds:

curl -N -H "Authorization: Bearer $(get-token)" \
  "http://localhost:9090/v1/events?kinds=conversation,entry"

Trusted backend processors can subscribe directly to Memory Service with explicit entry filters such as entry_channels=history,context. Browser-facing Quarkus routes should keep their history-only entry forwarding rule.

Next Steps