DNA //evolutions

TourOptimizer REST Server (JOpt.TourOptimizer)

Deploy and operate JOpt.TourOptimizer as a reactive Spring WebFlux service (OpenAPI/Swagger)

This page documents the server-side of JOpt.TourOptimizer: a reactive Spring WebFlux application that exposes the optimizer via REST + OpenAPI (Swagger UI).


Overview



Why WebFlux + reactive is a great fit

Optimization services are typically used in bursty, concurrent scenarios (batch planning, interactive UI runs, multiple teams, CI regression). The TourOptimizer REST server uses Spring WebFlux and reactive patterns to:

  • keep the HTTP layer non-blocking (avoid thread starvation under load),
  • support high concurrency for status/progress polling and long-running runs,
  • integrate naturally with reactive event streams coming from the Java core (progress, warnings, errors).

The optimizer itself is compute-heavy, but WebFlux keeps the service layer scalable and responsive in real platform environments.


Swagger / OpenAPI

Swagger Endpoint UISwagger Endpoint UI

The Swagger/OpenAPI schema is derived from the snapshot model inside the Java library via annotations. This ensures that:

  • the REST contract matches the SDK snapshot definition,
  • generated clients stay aligned with the server,
  • snapshots remain reproducible across environments.

Run locally (Docker)

docker run -d --rm --name jopt-touroptimizer \
  -p 8081:8081 \
  -e SPRING_PROFILES_ACTIVE=cors \
  dnaevolutions/jopt_touroptimizer:latest
  • Swagger UI (typical): http://localhost:8081/swagger-ui/index.html
  • OpenAPI JSON (typical): http://localhost:8081/v3/api-docs

If your REST client runs inside a Docker-based sandbox container, use http://host.docker.internal:8081 instead of http://localhost:8081.

Please also read our containter deployment help:


Fire-and-forget mode

This page will describe asynchronous job submission patterns, polling, and optional persistence.


Configuration overview

This section lists the configurable properties and groups them into:

  • DNA/JOpt keys (product-specific behavior),
  • Spring keys (standard Spring Boot / WebFlux / springdoc / actuator).

DNA / JOpt properties

PropertyDefaultPurpose / Notes
touroptimizer.debug.active${DNA_IS_DEBUG:false}Enables/disables debug mode
touroptimizer.elementslimit.active${DNA_HAS_ELEMENT_LIMITS:false}This will basically allow to keep our swagger endpoint open without the danger that any customer will overutilize the endpoint
touroptimizer.elementslimit.count${DNA_ELEMENT_LIMITS_COUNT:100}Only takes action if touroptimizer.elementslimit.active == true
touroptimizer.security.database-clean-rate-seconds${DNA_DATABASE_CLEAN_SECONDS:7200}Checking for expired objects in the databse
touroptimizer.security.database-download-enabled${DNA_DATABASE_DOWNLOAD_ACTIVE:true}Enable/disable auto-clean behaviour
touroptimizer.security.database-enabled${DNA_DATABASE_ACTIVE:true}Optional mongo / database is enabled/disabled
touroptimizer.security.default-lic${DNA_DEFAULT_LIC:}Default fallback JSON license
touroptimizer.security.password${DNA_USER:jopt}Login to swagger endpoint
touroptimizer.security.plugins-enabled${DNA_PLUGINS_ACTIVE:true}Enable/disable Plugins
touroptimizer.security.protection-enabled${DNA_SECURITY_ENABLED:false}Password protection enable /disable
touroptimizer.security.server-url${DNA_SERVER_URL:/}For defining the server url
touroptimizer.security.user${DNA_USER:dna}Security
touroptimizer.security.whitelistips${DNA_IP_WHITELIST:}EXAMPLE touroptimizer.security.whitelistips = ${DNA_IP_WHITELIST:127.0.0.1,0:0:0:0:0:0:0:1,192.168.1.1}

Spring / WebFlux / springdoc properties

PropertyDefaultPurpose / Notes
server.compression.enabledtrueCompression settings Enable response compression
server.compression.mime-typestext/html, text/xml, text/plain, text/css, text/javascript, application/javascript, application/jsonThe comma-separated list of mime types that should be compressed
server.compression.min-response-size1024Compress the response only if the response size is at least 1KB
server.error.include-messagealwaysFor telling the reason/message
server.forward-headers-strategyframeworkSince spring-boot 2.2, there is a new property to handle reverse proxy headers:
server.http2.enabledtrueEnable HTTP/2 support, if the current environment supports it
server.port8081Internal server port
spring.banner.locationclasspath:/banner/touroptimizerbanner.txtspringdoc.api-docs.groups.enabled=true Markup Using FIGlet Font BIG for banner
spring.data.mongodb.database${DNA_DATABASE_DB:touroptimizer}Missing database will be autocreated
spring.data.mongodb.uri${DNA_DATABASE_URI:mongodb://dnauser:dnapwd@localhost:27017/admin}spring.data.mongodb.uri="mongodb://mongo1:27017,mongo2:27018,mongo3:27019/?replicaSet=rs0"
spring.http.codecs.max-in-memory-size250MBSpring framework configuration.
spring.servlet.multipart.enabledtrueMULTIPART (MultipartProperties) Enable multipart uploads
spring.servlet.multipart.file-size-threshold2KBThreshold after which files are written to disk.
spring.servlet.multipart.max-file-size200MBMax file size.
spring.servlet.multipart.max-request-size215MBMax Request Size
springdoc.api-docs.enabledtrueTests for custom url
springdoc.api-docs.path${DNA_API_DOCS_PATH:/v3/api-docs}OpenAPI / Swagger configuration.
springdoc.api-docs.versionOPENAPI_3_0OpenAPI / Swagger configuration.
springdoc.show-actuatorfalseEndpoint reprsentation related
springdoc.swagger-ui.config-url${DNA_UI_CONFIG_URL:/v3/api-docs/swagger-config}OpenAPI / Swagger configuration.
springdoc.swagger-ui.disable-swagger-default-urltrueOpenAPI / Swagger configuration.
springdoc.swagger-ui.urls[0].nameALLOpenAPI / Swagger configuration.
springdoc.swagger-ui.urls[0].url${DNA_UI_URL:/v3/api-docs}OpenAPI / Swagger configuration.
springdoc.webjars.prefix${DNA_WEBJARS_PREFIX:/webjars}OpenAPI / Swagger configuration.
springdoc.writer-with-default-pretty-printertrueOpenAPI / Swagger configuration.

Container / runtime environment variables

VariableDefaultPurpose / Notes
SPRING_PROFILES_ACTIVE(none)Selects Spring profile(s), e.g. cors to enable browser-friendly CORS settings.
JAVA_TOOL_OPTIONS(none)JVM flags for the container (memory, GC, diagnostics). Recommended for production tuning.

Spring supports environment-variable mapping for many properties (e.g., SERVER_PORT can override server.port) depending on your deployment conventions.


References