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.
Handling messages from a custom log
Section titled “Handling messages from a custom log”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);}@HandleCustom("metering-points")fun on(event: MeteringPoint) { 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
Publishing to a custom log
Section titled “Publishing to a custom log”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));Fluxzero.get() .customGateway("metering-points") .sendAndForget(MeteringPoint("meter-1", 12.5))The reading goes to metering-points, where the handler above receives it.
Controlling retention
Section titled “Controlling retention”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));Fluxzero.get() .customGateway("metering-points") .setRetentionTime(Duration.ofDays(90))© 2026 Fluxzero