-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
26 additions
and
4 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...ing-boot-starter/src/main/java/org/zalando/nakadiproducer/EventTransmissionScheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.zalando.nakadiproducer; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
import org.zalando.nakadiproducer.transmission.impl.EventTransmitter; | ||
|
||
@Component | ||
public class EventTransmissionScheduler { | ||
private final EventTransmitter eventTransmitter; | ||
private final boolean scheduledTransmissionEnabled; | ||
|
||
@Autowired | ||
public EventTransmissionScheduler(EventTransmitter eventTransmitter, @Value("${nakadi-producer.scheduled-transmission-enabled:true}") boolean scheduledTransmissionEnabled) { | ||
this.eventTransmitter = eventTransmitter; | ||
this.scheduledTransmissionEnabled = scheduledTransmissionEnabled; | ||
} | ||
|
||
@Scheduled(fixedDelayString = "${nakadi-producer.transmission-polling-delay:1000}") | ||
protected void sendEventsIfSchedulingEnabled() { | ||
if (scheduledTransmissionEnabled) { | ||
eventTransmitter.sendEvents(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters