zalando-nakadi / nakadi-producer-spring-boot-starter

Nakadi event producer as a Spring boot starter
MIT License
13 stars 8 forks source link

Make lock-timeout configurable #120

Closed fbrns closed 5 years ago

fbrns commented 5 years ago

Currently the lock-timeout is hard-coded in EventTransmissionService.java. For applications it would be a benefit to adapt the configuration to their special needs. The current configuration should be kept as the default.

eventLogRepository.lockSomeMessages(lockId, now(), now().plus(10, MINUTES));
private boolean lockNearlyExpired(EventLog eventLog) {
        // since clocks never work exactly synchronous and sending the event also takes some time, we include a minute
        // of safety buffer here. This is still not 100% precise, but since we require events to be consumed idempotent,
        // sending one event twice wont hurt much.
        return now().isAfter(eventLog.getLockedUntil().minus(1, MINUTES));
    }