Este conteúdo não está disponível no idioma selecionado.
Chapter 20. Realtime Decision Server Functionality
20.1. Introduction Copiar o linkLink copiado para a área de transferência!
The Realtime Decision Server is a modular, standalone server component that can be used to instantiate and execute rules and processes. It exposes this functionality through REST, JMS and Java interfaces to client application.
At its core, the Realtime Decision Server is a configurable web application packaged as a WAR file. Distributions are available for pure web containers (like Tomcat) and for JEE 6 and JEE 7 containers.
Most capabilities on the Realtime Decision Server are configurable, and based on the concepts of extensions. Each extension can be enabled/disabled independently, allowing the user to configure the server to its need.
20.2. Business Resource Planner REST API Copiar o linkLink copiado para a área de transferência!
When the Planner capability is enabled, the Realtime Decision Server supports the following additional REST APIs. All these APIs are also available through JMS and the Java client API. Please also note:
- To deploy the Realtime Decision Server, see chapter Realtime Decision Server from Red Hat JBoss BRMS User Guide.
-
The base URL for these will remain as the endpoint defined earlier (for example
http://SERVER:PORT/kie-server/services/rest/server/). -
All requests require the user to have the role
kie-server. To get a specific marshalling format, add the HTTP headers
Content-Typeand optionalX-KIE-ContentTypein the HTTP request. For example:Content-Type: application/xml X-KIE-ContentType: xstream
Content-Type: application/xml X-KIE-ContentType: xstreamCopy to Clipboard Copied! Toggle word wrap Toggle overflow
The example requests and responses used below presume that a KIE container is built using the optacloud example of OptaPlanner Workbench, by calling a PUT on /services/rest/server/containers/optacloud-kiecontainer-1 with this content:
20.2.1. [GET] /containers/{containerId}/solvers Copiar o linkLink copiado para a área de transferência!
Returns the list of solvers created in the container.
Example 20.1. Example Server Response (XStream)
Example 20.2. Example Server Response (JSON)
20.2.2. [PUT] /containers/{containerId}/solvers/{solverId} Copiar o linkLink copiado para a área de transferência!
Creates a new solver with the given {solverId} in the container {containerId}. The request’s body is a marshalled SolverInstance entity that must specify the solver configuration file.
The following is an example of the request and the corresponding response.
Example 20.3. Example Server Request (XStream)
<solver-instance> <solver-config-file>opta/optacloud/cloudSolverConfig.solver.xml</solver-config-file> </solver-instance>
<solver-instance>
<solver-config-file>opta/optacloud/cloudSolverConfig.solver.xml</solver-config-file>
</solver-instance>
Example 20.4. Example Server Response (XStream)
Example 20.5. Example Server Request (JSON)
{
"solver-config-file" : "opta/optacloud/cloudSolverConfig.solver.xml"
}
{
"solver-config-file" : "opta/optacloud/cloudSolverConfig.solver.xml"
}
Example 20.6. Example Server Response (JSON)
20.2.3. [GET] /containers/{containerId}/solvers/{solverId} Copiar o linkLink copiado para a área de transferência!
Returns the current state of the solver {solverId} in container {containerId}.
Example 20.7. Example Server Response (XStream)
Example 20.8. Example Server Response (JSON)
20.2.4. Start solving Copiar o linkLink copiado para a área de transferência!
Here is an example to solve an optacloud problem with 2 computers and 1 process:
Example 20.9. Example Server Request (XStream)
Notice that the response does not contain the best solution yet, because solving can take seconds, minutes, days or hours and this would time out the HTTP request:
Example 20.10. Example Server Response (XStream)
Instead, it’s solving asynchronously and you need to call the bestsolution URL to get the best solution.
20.2.5. Terminate solving Copiar o linkLink copiado para a área de transferência!
For example, to terminate solving:
Example 20.11. Example Server Request (XStream)
<solver-instance> <status>NOT_SOLVING</status> </solver-instance>
<solver-instance>
<status>NOT_SOLVING</status>
</solver-instance>
Example 20.12. Example Server Response (XStream)
This doesn’t delete the solver, the best solution can still be retrieved.
20.2.6. [GET] /containers/{containerId}/solvers/{solverId}/bestsolution Copiar o linkLink copiado para a área de transferência!
Returns the best solution found at the time the request is made. If the solver hasn’t terminated yet (so the status field is still SOLVING), it will return the best solution found up to then, but later calls can return a better solution.
For example, the problem submitted above would return this solution, with the process assigned to the second computer (because the first one doesn’t have enough memory).
Example 20.13. Example Server Response (XStream)
20.2.7. [DELETE] /containers/{containerId}/solvers/{solverId} Copiar o linkLink copiado para a área de transferência!
Disposes the solver {solverId} in container {containerId}. If it hasn’t terminated yet, it terminates it first.
Example 20.14. Example Server Response (XStream)
<org.kie.server.api.model.ServiceResponse> <type>SUCCESS</type> <msg>Solver 'solver1' successfully disposed from container 'optacloud-kiecontainer-1'</msg> </org.kie.server.api.model.ServiceResponse>
<org.kie.server.api.model.ServiceResponse>
<type>SUCCESS</type>
<msg>Solver 'solver1' successfully disposed from container 'optacloud-kiecontainer-1'</msg>
</org.kie.server.api.model.ServiceResponse>
Example 20.15. Example Server Response (JSON)
{
"type" : "SUCCESS",
"msg" : "Solver 'solver1' successfully disposed from container 'optacloud-kiecontainer-1'"
}
{
"type" : "SUCCESS",
"msg" : "Solver 'solver1' successfully disposed from container 'optacloud-kiecontainer-1'"
}