Kie Server Java client API is used when it’s necessary to create a Java service to interact with a remote Kie Server (not an embedded engine). Consider that you have an architecture with a Kie Server running your business projects and you want to consume them using a Java service running in another application server (deploying applications in different JVMs is a recommended practice). To allow this service to interact with deployed Kie Containers, it first needs to be authenticated and authorized to execute operations inside Kie Server. Once the service is authorized, it is now possible to create and manipulate
Containers, interact with business assets and query data.
Kie Server Java client API has core services that can be used in your Java classes to authenticate, manage and consume the assets. These services facilitate the development and interaction with business assets since it is not required to create and parse each detail of the requests (this is a need, for example, in front-end applications which connect directly to Kie Server).
TIP: Instead of presenting details of each available method in the services, the author opted to present the documentation and source code, which is the best origin of reliable knowledge. All the classes presented in this section are in the source code in the jBPM repository: https://github.com/kiegroup/droolsjbpm-integration/blob/master/kie-server-parent/kie-server-remote/kie-server-client/src/main/java/org/kie/server/client/
The available services that can be used to interact with Kie Server and business projects are:
|Kie Management Related:|
Every client application needs to be authenticated and authorized to interact with Kie Server. The necessary role to authorize this interaction is kie-server role. The user containing this role should be configured in the application server where Kie Server is running, or, it should exist in the external IDP (i.e. Keycloak).
The following guideline provides overall steps on how to configure the Kie Client Java API in any Java application. Details on REST and JMS integration configuration are provided in sequence. To allow an application to interact with business assets:
- Add the kie server client library as a dependency in the client application project:
- To consume remote kie servers, add
org.kie.server:kie-server-clientdependency in the
- To consume remote kie servers, add
- Create a configuration class (extending
KieServicesConfiguration) . This class indicates whether this is a JMS or a REST client. Additionally, it contains the connection settings used to integrate with the Kie Server. Let’s see more details on each respective topic in a while.
- Once the configuration is set, use
KieServicesFactoryto create a new
Kie Services Client. It’s recommended that this is done only once, for example during the application startup. All the client services presented in the previous services table are accessible from
KieServicesClientinstance. Use the configuration created on step 2, as to create this object:
kieServicesClient = KieServicesFactory.newKieServicesClient(conf);
4. Choose the services you need in this client, and initialize them. Example:
ProcessServicesClient processService = kieServicesClient.getServicesClient(ProcessServicesClient.class);
5. Use the services as you wish. For example, to start a new process instance:
After following these steps this application is now a client ready to interact with any deployed business application inside the configured remote Kie Server. The developer can now do all kinds of integration: fire rules, manage and interact with processes, cases, and resource planning assets.