Simple example of how to build a simulator based on SimOne. The example creates a Quarkus server that depends on the SimOne core jar.
OrderResource.java: Implements A JAX-RS REST API to simulate. In the example it is possible to create and view a Coffee order.
OrderController.java: Create the example order and submits a event that is published on the FEED.
OrderRepository.java: Stores the order for later retrieval.
./mvnw quarkus:dev
./mvnw clean package
java -jar target/simeone-example-runner.jar
./mvnw clean package -Dquarkus.container-image.build=true
docker run -it --rm -p 8080:8080 -p 1527:1527 test/simone-example
curl -X POST -d "Coffee" 'http://localhost:8080/order'
curl 'http://localhost:8080/order'
curl 'http://localhost:8080/feed/recent'
curl -X DELETE 'http://localhost:8080/admin/database'
Sends a custom Feed event (possible erroneous) for test purposes
curl -X POST --header 'Content-Type: application/json' -d '{"contentType": "application/xml","content": "<message>hello</message>"}' 'http://localhost:8080/admin/feed/event'
For every REST request respond with status code 201.
curl -X PUT --header 'Content-Type: application/json' -d '201' 'http://localhost:8080/admin/rs/response/code/global'
See OpenAPI for more information about the admin API.
There are two options to load SimOne with a batch of orders.
Load SimOne with information from etc/orders.txt
curl -X POST --header 'Content-Type: multipart/form-data' -F 'file=@etc/orders.txt' 'http://localhost:8080/order/file'
See simone-example.http for more examples.
Expose port 1527 from the docker container. Use a SQL CLient with the org.apache.derby.jdbc.ClientDriver
driver.
URL: jdbc:derby://localhost:1527/memory:feed;create=false
When you run the application the OpenAPI documentation is available at: http://localhost:8080/q/openapi
You can remote debug the application in the running container by hooking up jdb to port 8787. Note that you also must expose the port in the docker run command.
jdb -attach 8787
curl http://localhost:8080/q/health
Get number of orders
curl http://localhost:8080/q/metrics
- It is not possible to load SimOne by selecting a file in Swagger.
- JDK 17