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
Nested ClassesModifier and TypeInterfaceDescriptionstatic classA query to fetch messages from a backend.static classA request to persist messages to a backend. -
Method Summary
Modifier and TypeMethodDescriptionReads a stream ofCollaborationMessageitems from a persistence backend.fromCallbacks(SerializableFunction<CollaborationMessagePersister.FetchQuery, Stream<CollaborationMessage>> fetchCallback, SerializableConsumer<CollaborationMessagePersister.PersistRequest> persistCallback) Creates an instance ofCollaborationMessagePersisterfrom the provided callbacks.voidWrites aCollaborationMessageto the persistence backend.
-
Method Details
-
fromCallbacks
static CollaborationMessagePersister fromCallbacks(SerializableFunction<CollaborationMessagePersister.FetchQuery, Stream<CollaborationMessage>> fetchCallback, SerializableConsumer<CollaborationMessagePersister.PersistRequest> persistCallback) Creates an instance ofCollaborationMessagePersisterfrom 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 ofCollaborationMessageitems 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 aCollaborationMessageto 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
-