Skip to content

Custom message logs

Use a custom log when a stream needs its own topic and retention, such as readings from an external meter. Ordinary domain actions and changes belong in the built-in command and event logs.

In this example the application defines MeteringPoint(String meterId, double value) in Java, or data class MeteringPoint(val meterId: String, val value: Double) in Kotlin. Both sender and handler use the metering-points topic.

To receive messages from a custom log, annotate your handler with @HandleCustom and specify the topic name.

@HandleCustom("metering-points")
void on(MeteringPoint event) {
log.info("Metering point: {}", event);
}

Custom handlers support everything native handlers do:

  • Stateless or @Stateful
  • Optional results if it’s a request
  • Use of custom consumers
  • Segment routing and metadata access
  • Full delivery tracking

You can publish messages directly to a custom topic using the customGateway(...) API.

Fluxzero.get()
.customGateway("metering-points")
.sendAndForget(new MeteringPoint("meter-1", 12.5));

The reading goes to metering-points, where the handler above receives it.


Each log (including custom ones) can have its own retention policy. By default, messages are retained according to the global retention settings — but you can override this per topic.

Fluxzero.get()
.customGateway("metering-points")
.setRetentionTime(Duration.ofDays(90));

© 2026 Fluxzero