Skip to content

Commit 1b1546d

Browse files
fbrnsBGehrels
authored andcommitted
#120 make lock-timeout configurable
(cherry picked from commit 0b7d793)
1 parent c86b9f2 commit 1b1546d

File tree

3 files changed

+16
-21
lines changed

3 files changed

+16
-21
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -277,21 +277,6 @@ You may also define a spring bean of type `FlywayCallback` and annotate it with
277277
interface provide several hook into the schema management lifecycle that may, for example, be used to
278278
`SET ROLE migrator` before and `RESET ROLE` after each migration.
279279

280-
### Customizing event locks
281-
282-
* **lock-duration**: The selected events are locked before transmission. If the transmission fails the events stay locked
283-
until the lock expires (default: 600 seconds).
284-
285-
* **lock-duration-buffer**: Since clocks never work exactly synchronous and sending events also takes some time, a safety
286-
buffer is included. During the last x seconds before the expiration of the lock the events are not considered for
287-
transmission (default: 60 seconds).
288-
289-
```yaml
290-
nakadi-producer:
291-
lock-duration: 600
292-
lock-duration-buffer: 60
293-
```
294-
295280
### Test support
296281

297282
This library provides a mock implementation of its Nakadi client that can be used in integration testing:
@@ -332,6 +317,21 @@ The example above uses `com.jayway.jsonpath:json-path:jar:2.2.0` to parse and te
332317

333318
Note that you should disable the scheduled event transmission for the test (e.g. by setting `nakadi-producer.scheduled-transmission-enabled:false`), as that might interfere with the manual transmission and the clearing in the test setup, leading to events from one test showing up in the next test, depending on timing issues.
334319

320+
### Customizing event locks
321+
322+
* **lock-duration**: The selected events are locked before transmission. If the transmission fails the events stay locked
323+
until the lock expires. The default is currently 600 seconds but might change in future releases.
324+
325+
* **lock-duration-buffer**: Since clocks never work exactly synchronous and sending events also takes some time, a safety
326+
buffer is included. During the last x seconds before the expiration of the lock the events are not considered for
327+
transmission. The default is currently 60 seconds but might change in future releases.
328+
329+
```yaml
330+
nakadi-producer:
331+
lock-duration: 600
332+
lock-duration-buffer: 60
333+
```
334+
335335
## Contributing
336336

337337
We welcome contributions. Please have a look at our [contribution guidelines](CONTRIBUTING.md).

nakadi-producer/src/main/java/org/zalando/nakadiproducer/transmission/impl/EventTransmissionService.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ public class EventTransmissionService {
3636

3737
private Clock clock = Clock.systemDefaultZone();
3838

39-
public EventTransmissionService(EventLogRepository eventLogRepository, NakadiPublishingClient nakadiPublishingClient, ObjectMapper objectMapper) {
40-
this(eventLogRepository, nakadiPublishingClient, objectMapper, 600, 60);
41-
}
42-
4339
public EventTransmissionService(EventLogRepository eventLogRepository, NakadiPublishingClient nakadiPublishingClient, ObjectMapper objectMapper,
4440
int lockDuration, int lockDurationBuffer) {
4541
this.eventLogRepository = eventLogRepository;

nakadi-producer/src/test/java/org/zalando/nakadiproducer/transmission/impl/EventTransmissionServiceTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.fasterxml.jackson.databind.ObjectMapper;
66
import org.junit.Before;
77
import org.junit.Test;
8-
import org.mockito.ArgumentMatchers;
98
import org.mockito.Mockito;
109
import org.zalando.fahrschein.EventPublishingException;
1110
import org.zalando.fahrschein.domain.BatchItemResponse;
@@ -53,7 +52,7 @@ public void setUp() {
5352
repo = mock(EventLogRepository.class);
5453
publishingClient = spy(new MockNakadiPublishingClient());
5554
mapper = spy(new ObjectMapper());
56-
service = new EventTransmissionService(repo, publishingClient, mapper);
55+
service = new EventTransmissionService(repo, publishingClient, mapper, 600, 60);
5756
}
5857

5958
@Test

0 commit comments

Comments
 (0)