Interface EventLogRepository
-
public interface EventLogRepositoryThis interface represents the database table where event log entries are stored. Normal users of the library don't need to care about this, it's implemented in nakadi-producer-spring-boot-starter and used in nakadi-producer. Only if you are using nakadi-producer without the spring-boot-starter, you'll have to implement it yourself.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voiddelete(Collection<EventLog> eventLogs)Deletes multiple event log entries.voiddelete(EventLog eventLog)Deletes a single event log entry from the database.voiddeleteAll()Deletes all event log entries.Collection<EventLog>findByLockedByAndLockedUntilGreaterThan(String lockId, Instant lockedUntil)Fetched events which were locked by the given lock ID, and whose lock is not yet expired.EventLogfindOne(Integer id)Fetches a specific event log by its ID.voidlockSomeMessages(String lockId, Instant now, Instant lockExpires)Lock some event log entries, so that other instances won't try to send them out.default voidpersist(Collection<EventLog> eventLogs)Persist multiple event log entries at once.voidpersist(EventLog eventLog)Persists a single eventlog entry.default voidpersistAndDelete(Collection<EventLog> eventLogs)Persists and immediately deletes some event log entries.
-
-
-
Method Detail
-
findByLockedByAndLockedUntilGreaterThan
Collection<EventLog> findByLockedByAndLockedUntilGreaterThan(String lockId, Instant lockedUntil)
Fetched events which were locked by the given lock ID, and whose lock is not yet expired.- Parameters:
lockId- the lock ID used for locking. This should be the same value as previously used inlockSomeMessages(String, Instant, Instant)for locking the event log entries.lockedUntil- A cut-off for the expiry time. Use a time here where you are reasonably confident that you can send out the fetched events until this time.- Returns:
- the fetched events.
-
lockSomeMessages
void lockSomeMessages(String lockId, Instant now, Instant lockExpires)
Lock some event log entries, so that other instances won't try to send them out. You can later retrieve the locked entries withfindByLockedByAndLockedUntilGreaterThan(String, Instant).- Parameters:
lockId- a unique identifier for this instance / job run / etc. The same value should later be used for fetching them infindByLockedByAndLockedUntilGreaterThan(String, Instant).now- existing locked event logs whose lock expiry time is before this value can be locked again.lockExpires- an expiry time to use for the new locks.
-
delete
void delete(EventLog eventLog)
Deletes a single event log entry from the database.- Parameters:
eventLog- the event log entry. Only itsidproperty is used.
-
delete
default void delete(Collection<EventLog> eventLogs)
Deletes multiple event log entries.- Parameters:
eventLogs- A collection of event log entries. Only theiridproperties are be used.
-
persist
void persist(EventLog eventLog)
Persists a single eventlog entry.- Parameters:
eventLog- the event log entry to insert into the database. It's not part of the contract to fill theidproperty with the generated identifier, but an implementation is free to do so. (The implementation in Nakadi-Producer Spring Boot Starter doesn't do so.)
-
persist
default void persist(Collection<EventLog> eventLogs)
Persist multiple event log entries at once.- Parameters:
eventLogs- A collection of event logs entries. It's not part of the contract to fill theidproperty with the generated identifier, but an implementation is free to do so. (The implementation in Nakadi-Producer Spring Boot Starter doesn't do so.)
-
persistAndDelete
default void persistAndDelete(Collection<EventLog> eventLogs)
Persists and immediately deletes some event log entries. This is meant to be used together with infrastructure listening to a logical DB replication stream.Implementer's note: The default implementation just calls
(The implementation in Nakadi-Producer Spring Boot starter reimplements this method.)persist(Collection)anddelete(Collection)and will only work ifpersiststores back the IDs into the objects (which is not part of the contract). If that's not the case, this methods needs to be overridden to implement it in a different way.- Parameters:
eventLogs- the event log entries to be persisted and deleted.
-
deleteAll
void deleteAll()
Deletes all event log entries. This is only meant for cleanup in tests.
-
-