public interface CollaborationMessagePersister extends Serializable
CollaborationMessage
items, which enables to read and
write messages from/to a backend, for example a database.
It can be used with a CollaborationMessageList
to have the component
read messages from the backend when attached and write new messages to it
when appended to the list with a sumbmitter component, e.g.
CollaborationMessageInput
.
Modifier and Type | Interface and Description |
---|---|
static class |
CollaborationMessagePersister.FetchQuery
A query to fetch messages from a backend.
|
static class |
CollaborationMessagePersister.PersistRequest
A request to persist messages to a backend.
|
Modifier and Type | Method and Description |
---|---|
Stream<CollaborationMessage> |
fetchMessages(CollaborationMessagePersister.FetchQuery query)
Reads a stream of
CollaborationMessage items from a persistence
backend. |
static CollaborationMessagePersister |
fromCallbacks(SerializableFunction<CollaborationMessagePersister.FetchQuery,Stream<CollaborationMessage>> fetchCallback,
SerializableConsumer<CollaborationMessagePersister.PersistRequest> persistCallback)
Creates an instance of
CollaborationMessagePersister from the
provided callbacks. |
void |
persistMessage(CollaborationMessagePersister.PersistRequest request)
Writes a
CollaborationMessage to the persistence backend. |
static CollaborationMessagePersister fromCallbacks(SerializableFunction<CollaborationMessagePersister.FetchQuery,Stream<CollaborationMessage>> fetchCallback, SerializableConsumer<CollaborationMessagePersister.PersistRequest> persistCallback)
CollaborationMessagePersister
from the
provided callbacks.fetchCallback
- the callback to fetch messages, not nullpersistCallback
- the callback to persist messages, not nullStream<CollaborationMessage> fetchMessages(CollaborationMessagePersister.FetchQuery query)
CollaborationMessage
items from a persistence
backend. The query parameter contains the topic identifier and the
timestamp from which messages should be read.
Note: You must include the messages sent during or after the timestamp
returned from CollaborationMessagePersister.FetchQuery.getSince()
, including the
messages sent at that exact time. More formally, you should return all
such messages, for which the following condition is true:
message.getTime() >= fetchQuery.getSince()
query
- the fetch queryvoid persistMessage(CollaborationMessagePersister.PersistRequest request)
CollaborationMessage
to the persistence backend.
It is recommended to let the backend set the message timestamp and only
use CollaborationMessage.getTime()
as a fallback.
request
- the request to persist the messageCopyright © 2021. All rights reserved.