Package com.vaadin.collaborationengine
Interface CollaborationMessagePersister
- All Superinterfaces:
Serializable
Persister of
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 submitter component, e.g.
CollaborationMessageInput
.
- Since:
- 3.1
- Author:
- Vaadin Ltd
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
A query to fetch messages from a backend.static class
A request to persist messages to a backend. -
Method Summary
Modifier and TypeMethodDescriptionReads a stream ofCollaborationMessage
items from a persistence backend.fromCallbacks
(SerializableFunction<CollaborationMessagePersister.FetchQuery, Stream<CollaborationMessage>> fetchCallback, SerializableConsumer<CollaborationMessagePersister.PersistRequest> persistCallback) Creates an instance ofCollaborationMessagePersister
from the provided callbacks.void
Writes aCollaborationMessage
to the persistence backend.
-
Method Details
-
fromCallbacks
static CollaborationMessagePersister fromCallbacks(SerializableFunction<CollaborationMessagePersister.FetchQuery, Stream<CollaborationMessage>> fetchCallback, SerializableConsumer<CollaborationMessagePersister.PersistRequest> persistCallback) Creates an instance ofCollaborationMessagePersister
from the provided callbacks.- Parameters:
fetchCallback
- the callback to fetch messages, not nullpersistCallback
- the callback to persist messages, not null- Returns:
- the persister instance
-
fetchMessages
Reads a stream ofCollaborationMessage
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()
- Parameters:
query
- the fetch query- Returns:
- a stream of messages
-
persistMessage
Writes aCollaborationMessage
to the persistence backend.It is recommended to let the backend set the message timestamp and only use
CollaborationMessage.getTime()
as a fallback.- Parameters:
request
- the request to persist the message
-