Last active
February 4, 2018 21:41
-
-
Save lankydan/40363710bc5c0170ec6abedc22db242f to your computer and use it in GitHub Desktop.
Scheduling - Using fixedRate property
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
@Component | |
public class EventCreator { | |
private static final Logger LOG = LoggerFactory.getLogger(EventCreator.class); | |
private final EventRepository eventRepository; | |
public EventCreator(final EventRepository eventRepository) { | |
this.eventRepository = eventRepository; | |
} | |
@Scheduled(fixedRate = 1000) | |
public void create() { | |
final LocalDateTime start = LocalDateTime.now(); | |
eventRepository.save( | |
new Event(new EventKey("An event type", start, UUID.randomUUID()), Math.random() * 1000)); | |
LOG.debug("Event created!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment