Domino & Spring Boot: ScheduledTasks

When developing Spring Boot applications running on Domino, there is a feature which runs out of the box and makes developers happy: ScheduledTasks.

These are the equivalent for agents, but they are running directly in the HTTP task (which allows to access the complete Spring Application at runtime) and can be scheduled exactly to the milisecond.

To enable a scheduled task, you first have to add the @EnableScheduling annotation in your Application class:

package domino_spring.plugin;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;

public class Application extends {

   public static void main(String[] args) {, args);


Next step is to declare the TaskScheduler used. Just add a bean to your Application class:

 public TaskScheduler taskScheduler() {
      return new ConcurrentTaskScheduler();

After completing the setup you can define your scheduled task:

package domino_spring.plugin;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

public class ScheduledTasks {

   private static final Logger log = LoggerFactory.getLogger(ScheduledTasks.class);

   private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");

   @Scheduled(fixedRate = 5000)
   public void reportCurrentTime() {"The time is now {}", dateFormat.format(new Date()));

When the Sprint Boot application is now started, the current time is  printed to the logs every 5 seconds.

Dieser Beitrag wurde unter Agenten, Java, Server, Spring, Web abgelegt und mit , , , , , verschlagwortet. Setze ein Lesezeichen auf den Permalink.

2 Kommentare zu Domino & Spring Boot: ScheduledTasks

  1. What do you have to do to run Spring Boot apps on Domino?

    • 1. Create an OSGi plugin
      2. Add the required resources / libs / your app
      3. Build & Deploy the plugin on the Domino server
      4. Enjoy the result

      I will upload a starter project asap.

      There was a Hands-On Session with Carsten @ EntwicklerCamp this year.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.