LiveStream
The LiveStream class provides a blocking interface for receiving real-time notifications from live queries. It implements AutoCloseable, so it can be used in a try-with-resources block. Live streams are created by calling .selectLive() on a Surreal instance.
Note
Source: surrealdb.java
Methods
.next()
Blocks until the next live query notification is available and returns it. Returns an empty Optional if the stream has been closed.
Returns: Optional<LiveNotification>
.close()
Closes the live query subscription and releases associated resources. This is called automatically when using try-with-resources.
Returns: void
LiveNotification
The LiveNotification class represents a single real-time notification received from a live query. Each notification contains the action that triggered it, the affected record value, and the live query identifier.
Methods
.getAction()
Returns the type of action that triggered the notification.
Returns: String — one of "CREATE", "UPDATE", or "DELETE"
.getValue()
Returns the record value associated with the notification. For CREATE and UPDATE actions, this is the full record. For DELETE actions, this may be null.
Returns: Value (may be null for DELETE actions)
.getQueryId()
Returns the UUID of the live query that produced this notification.
Returns: String
Complete Example
See Also
Surreal — Connection and method reference
Live queries — Live query concepts and patterns
SurrealQL LIVE SELECT — Live query syntax