Skip to content

Instantly share code, notes, and snippets.

@lankydan
Last active February 4, 2018 21:41
Show Gist options
  • Save lankydan/40363710bc5c0170ec6abedc22db242f to your computer and use it in GitHub Desktop.
Save lankydan/40363710bc5c0170ec6abedc22db242f to your computer and use it in GitHub Desktop.
Scheduling - Using fixedRate property
@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