Skip to content

Commit

Permalink
#23 fixed scheduling
Browse files Browse the repository at this point in the history
  • Loading branch information
BGehrels committed May 23, 2017
1 parent d513e28 commit 5ba13f1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 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 @@ -29,6 +29,7 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.zalando.fahrschein.NakadiClient;
import org.zalando.nakadiproducer.eventlog.EventLogWriter;
import org.zalando.nakadiproducer.eventlog.impl.EventLogRepository;
Expand Down Expand Up @@ -167,6 +168,7 @@ public EventTransmissionService eventTransmissionService(EventLogRepository even
return new EventTransmissionService(eventLogRepository, nakadiPublishingClient, objectMapper);
}


@PostConstruct
public void migrateFlyway() {
Flyway flyway = new Flyway();
Expand Down

0 comments on commit 5ba13f1

Please sign in to comment.