Containerizing an application helps to use it more conveniently across different platforms and, most importantly, as a microservice. Further, scaling an application becomes more straightforward as various standardized orchestration tools can be utilized. A Microservice can be launched either (locally) or, for example, as a highly-scalable web-micro-service in a Kubernetes cluster.
This repository is part of our JOpt-REST-Suite. It provides examples of how to set up a REST client in Java to access the following DNA Evolution's web services:
- JOpt-TourOptimizer based on JOpt-Core (available as local Container and via Azure)
- JOpt-GeoCoder based on JOpt-Core and Pelias (available via Azure)
- JOpt-RoutePlanner based on JOpt-Core and Valhalla (available via Azure)
You can find an extensive collection of examples for the core library in our Java-TourOptimizer-Examples repository. Please let us know if you need help to port an example and run it by a REST-Service.
The service can be called via an API-Key using our Microsoft Azure-Kubernetes Infrastructure. If you are interested in hosting our JOpt-REST-GeoCoder and JOpt-REST-GeoRouter products in your environment, please get in touch with us.
All our RESTful Services utilise Spring WebFlux and Swagger. Internally the Java version of TourOptimizer is used. Indeed all specifications for the different services are derived from the core library, leading to guaranteed compatibility between all three services.
Forward-/Reverse geocode Addresses or Positions.
Find distances and driving times between points. Either as turn-by-turn result optionally providing driving instructions and route shapes or as matrix request for multiple routings.
Optimize a problem consisting of Nodes, Resources, and optionally externally provided connections. In contrast to our other services, we allow you to host your JOpt-TourOptimizer locally.
The project is subdivided into five major types of examples:
Each of the example-sections has its own README.
The REST-Client class files used by the examples of this repository will be automatically generated from the provided API-docs (OpenAPI 3 Specification) in the resources swagger folder once the project gets built utilizing the openapi-generator-maven-plugin by OpenAPI Tools.
OpenApi Generator allows setting some generation configuration. Indeed, it is vital to adjust the generator to slightly create the correct client files.
As we use the maven-plugin, we define the configuration directly inside the pom.xml
. For example, for our TourOptimizer endpoint, we use:
<configuration>
...
<generatorName>java</generatorName>
<typeMappings>
<typeMapping>OffsetDateTime=Instant</typeMapping>
</typeMappings>
<importMappings>
<importMapping>java.time.OffsetDateTime=java.time.Instant</importMapping>
</importMappings>
<library>webclient</library>
...
</configuration>
Please see the pom.xml
for the entire configuration description. Besides some mappings, we use the WebClient library to enable Flux and Mono compatible access to our swagger endpoints.
You can also generate a client in the programming language of your choice utilizing our API-docs. REST facilitates software integration in your desired language (including famous ones like C#, Java, JS, Scala, Python, and many more ). Don't hesitate to contact us if you need help setting up your client.
You can start using our examples in different ways.
In any case, you need to provide a secrets.json
file. Please follow the README.md file inside the Secrets creation package.
- In your IDE as native Java dependency: Install at least Java 8, Maven
- In our sandbox: Working Docker environment
Clone this repository, import it as Maven project in your IDE, create a secrets.json
and start any example.
If you want to get started without the hassle of installing Java, Maven and an IDE, we provide a sandbox. The sandbox is based on code-server and can be used inside your browser, and the interface itself is based on Visual Code. The sandbox is available via DockerHub (here). You have to host the sandbox in your Docker environment (Please provide at least 2-4Gb of Ram and 2 Cores). You can pull the sandbox from our DockerHub account (The Dockerfile for creating the sandbox is included in this repository). The latest version of our examples is cloned by default on launching the Docker container, and you can start testing JOpt-REST right away.
You must mount a volume to which the examples of this project are downloaded on the container's startup. After re-launching the container, the latest version of our examples is only cloned if the folder is not already existing, keeping your files safe from being overridden.
Launching a sandbox and mount your current directory ('$PWD') or any other directory you want:
docker run -it -d --name jopt-rest-examples -p 127.0.0.1:8043:8080 -v "$PWD/:/home/coder/project" dnaevolutions/jopt_rest_example_server:latest
After starting the container, you can open http://localhost:8043/ with your browser and login with the password:
joptrest
During the run of your first example file, some dependencies are downloaded, and it will take some time (below 1 minute depending on your internet connection). In case you need help, contact us.
- Further documentation - docs.dna-evolutions.com
- Special features - Overview of special features
- Our official repository - public.repo.dna-evolutions.com
- Our official JavaDocs - public.javadoc.dna-evolutions.com
- Our YouTube channel - DNA Tutorials
- Documentation - DNA's RESTful Spring-TourOptimizer in Docker
- Our DockerHub channel - DNA DockerHub
- Our LinkedIn channel - DNA LinkedIn
If you need any help, please contact us via our company website www.dna-evolutions.com or write an email to info@dna-evolutions.com.
Originally, JOpt is a flexible routing optimization-engine written in Java, allowing to solve tour-optimization problems that are highly restricted, for example, regarding time windows, skills, and even mandatory constraints can be applied.
Click, to open our video:
For reading our license agreement and for further information about license plans, please visit www.dna-evolutions.com.
A product by dna-evolutions ©