Skip to content

Commit

Permalink
#23 - fixing the scheduling
Browse files Browse the repository at this point in the history
  • Loading branch information
BGehrels committed May 23, 2017
1 parent fda37a2 commit e9ee7d9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ public EventTransmissionService eventTransmissionService(EventLogRepository even
return new EventTransmissionService(eventLogRepository, nakadiPublishingClient, objectMapper);
}

@Scheduled(fixedDelayString = "${nakadi-producer.transmission-polling-delay:1000}")
protected void sendEventsIfSchedulingEnabled(EventTransmitter eventTransmitter) {
eventTransmitter.sendEvents();
}

@PostConstruct
public void migrateFlyway() {
Expand Down

0 comments on commit e9ee7d9

Please sign in to comment.