The detailed steps to bootstrap a custom worker follow.

  1. Start a Java project with Spring Boot.
  2. In your build file, declare a Maven dependency on “com.decisionbrain:optimserver-worker:2.5.0”.
  3. In the resources, create a worker.yml file, and declare tasks the worker will be able to perform. See the TaskParameter class in the javadoc for a description of the fields. An example is given below.

    - id: kcoloring
      implementationClassName: com.decisionbrain.kcoloringworker.KColoringTask
      description: This task computes a coloration of a partial Europe map with k colors.
      - name: k
        type: NUMERIC
        description: Number of colors to be used by the coloration.
        required: true
      - name: coloration
        type: JSON
        description: "The coloration found: for each country, the associated color."
  4. In the resources, write an application.yml file with the following content. Set the relevant property values.

        name: MyCustomWorker
        username: decisionbrain
        password: decisionbrain
        host: localhost
        port: 5672
  5. Write a Spring Boot application, with the EnableOptimServerWorker annotation, like this one:

    public class MyCustomWorker {
        public static void main(String[] args) {
  , args);
  6. Write a Java class for each declared task, and reference it in the worker.yml file. This class has to implement Interface com.decisionbrain.optimserver.worker.api.Task (see javadoc). Here is the skeleton of such a class:

    public class MyCustomTask implements Task {
        private static final Logger LOGGER = LoggerFactory.getLogger(MyCustomTask.class);
        public void execute(Parameter input, Parameter output, ExecutionContext context) {
            // TODO: put your optimization code here
  7. Now your worker is actually able to handle the declared tasks, it has to be packaged as a docker image to be deployable. First, a jar file should be built, using your favorite build tool (gradle for example). Then a docker image has to be built, using a Dockerfile, and the docker shell client, or any docker plugin for your build tool. Here is a typical Dockerfile:

    ADD build/libs/my-custom-worker.jar my-custom-worker.jar
    CMD java $JAVA_OPTS -jar my-custom-worker.jar $PROGRAM_ARGS

    Then a docker image can be built using:

    docker build .