Skip to content

1.3.0

Latest

Choose a tag to compare

@rossdanderson rossdanderson released this 06 Feb 11:19
78bcf6b

This release introduces support for publishing DataSource Containers directly from Spring @MessageMapping endpoints.

Endpoints can now return Flow<ContainerEvent<T>> (Kotlin) or Flux<ContainerEvent<T>> (Java). The starter automatically detects the ContainerEvent type and configures the underlying DataSource with active containers and records. As with other subject types, the container and record subjects are automatically registered with the Caplin Platform via Dynamic Configuration.

Usage Example

@MessageMapping("/public/container/{id}")
fun myContainer(@DestinationVariable id: String): Flow<ContainerEvent<MyPayload>> = flow {
    // Emit initial rows
    emit(ContainerEvent.Bulk(
        ContainerEvent.RowEvent.Upsert("row-1", MyPayload("Data 1")),
        ContainerEvent.RowEvent.Upsert("row-2", MyPayload("Data 2"))
    ))

    // Emit subsequent updates
    while (true) {
        delay(1.seconds)
        emit(ContainerEvent.RowEvent.Upsert("row-1", MyPayload("Updated Data")))
    }
}