Unmanaged mode of spring boot kie-server - Container Id for the deployed kmodule

524 views
Skip to first unread message

Nick

unread,
Feb 9, 2018, 4:46:38 AM2/9/18
to jBPM Usage

Hi,

I am looking at running spring boot kie-server in unmanaged mode after going pass the development phase. In this case, I don't need to run kie-wb. This can reduce the CPU and memory resources required. 

I managed to deployed the kmodule with the following code
            String deploymentUnit. = "com.myteam:demo:1.0.194";
 
             String[] gav = deploymentUnit.split(":");
            
            unit = new KModuleDeploymentUnit(gav[0], gav[1], gav[2]);
            deploymentService.deploy(unit); 

I can see the following log which indicates that the kmodule was successfully deployed

kie-server_1   | 2018-02-09 09:22:57.711  INFO 5 --- [           main] o.d.c.k.builder.impl.KieRepositoryImpl   : KieModule was added: ZipKieModule[releaseId=com.myteam:demo:1.0.194,file=/root/.m2/repository/com/myteam/demo/1.0.194/demo-1.0.194.jar]

However, when accessing the /rest/server/containers REST endpoint, I got the following

<response type="SUCCESS" msg="List of created containers">
<kie-containers/>
</response>

Any idea?

Also, how can I specify the container Id for the deployed kmodule? No such method in  deploymentService. I believe I need that as most of rest call requires container Id or deployment Id to be specified.

Regards,'
--Nick
 




Nick

unread,
Feb 9, 2018, 7:28:00 AM2/9/18
to jBPM Usage
Managed to get this done via KieServer.


ServiceResponse<KieContainerResource> createContainer = kieServer.createContainer(CONTAINER_ID, containerResource);

Maciej Swiderski

unread,
Feb 9, 2018, 8:16:34 AM2/9/18
to Nick, jBPM Usage
kie server in unmanaged mode relies on server state file {kie-server-id}.xml where you can define your containers to be started. You can do it in several ways:
- embed that file from other environment so it will already have containers defined
- use API to add containers to that file https://github.com/mswiderski/itorders-app/blob/master/itorders-web/src/main/java/org/kie/server/swarm/bpm/KieServerMain.java#L45-L57 note that this must be done before kie server is booted - so it must be before any of the auto configuration is triggered
- deploy manually as you already did

depending on your needs you might chose one option over the other but 1 or 2 seems to be the best one from my point of view

Maciej

-- 
You received this message because you are subscribed to the Google Groups "jBPM Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-usage+...@googlegroups.com.
To post to this group, send email to jbpm-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jbpm-usage/8753482d-70e6-4bad-8f66-82ff8a95dc6e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nick

unread,
Feb 9, 2018, 12:11:37 PM2/9/18
to jBPM Usage
Hi Maciej,

I tried the following code. No error but no container gets created. /rest/server/containers returns empty list. Did I miss anything?

   
    @SpringBootApplication
    public class KieServerApplication {
    
    private static final Logger LOGGER = LoggerFactory.getLogger(KieServerApplication.class);

    @Autowired
    public KieServerApplication(@Value("${kieserver.kmodule-deployment-unit}") String deploymentUnit,
                         @Value("${kieserver.serverId}") String serverId) {
    
        String controller = System.getProperty(KieServerConstants.KIE_SERVER_CONTROLLER);
if ( controller != null && !controller.isEmpty()) {
LOGGER.info("Controller is configured ("+controller+") - no local kjars can be installed");
            return;
        }
LOGGER.info("@@@@@@@@@@@@@@@@ configure container @@@@@@@@@@@@@");
String[] gav = deploymentUnit.split(":");
        
KieServerStateFileRepository repository = new KieServerStateFileRepository();
        KieServerState currentState = repository.load(serverId);
        
        Set<KieContainerResource> containers = new HashSet<KieContainerResource>();
        

        ReleaseId releaseId = new ReleaseId(gav[0], gav[1], gav[2]);                     
        KieContainerResource container = new KieContainerResource(releaseId.getArtifactId(), releaseId, KieContainerStatus.STARTED);
        containers.add(container);        
        
        currentState.setContainers(containers);
        
        repository.store(serverId, currentState);
    }


I got this to works however.

         String[] gav = deploymentUnit.split(":");
        
         ReleaseId releaseId = new ReleaseId(gav[0], gav[1], gav[2]);
               
        KieContainerResource containerResource = new KieContainerResource(releaseId.getArtifactId(), releaseId);
        ServiceResponse<KieContainerResource> createContainer = kieServer.createContainer(releaseId.getArtifactId(), containerResource);


By the way, I found out that the system keeps making attempt to connect to controller although I didn't add  kieserver.controllers property to application.properties and didn't set -Dorg.kie.server.controller.  

kie-server_1   | 2018-02-09 17:00:45.935 DEBUG 5 --- [ntrollerConnect] o.k.s.s.i.c.ControllerConnectRunnable    : Attempting to connect to one of the controllers...
kie-server_1   | 2018-02-09 17:00:45.935 DEBUG 5 --- [ntrollerConnect] o.k.s.s.i.c.ControllerConnectRunnable    : Still cannot connect to any controllers, waiting for 10000 before next attempt

I notice that System.getProperty(KieServerConstants.KIE_SERVER_CONTROLLER) returns empty String; not null. Is this a bug?

Thanks,
--Nick

Maciej Swiderski

unread,
Feb 12, 2018, 2:11:57 AM2/12/18
to Nick, jBPM Usage
if this does not work it indicates it’s invoked too late - meaning it is after kie server initialised already so the state file is already read.


most likely you have state file being reused - search for a file named {org.kie.server.id}.xml where org.kie.server.id is identifier of your server. There you will most likely still have controller defined, remove it from there and off you go. same you can add your containers in that file so that will get deployed automatically.

Maciej

Clinton Gomes

unread,
Mar 20, 2019, 3:25:58 PM3/20/19
to jBPM Usage
Can we change the location of where it picks this file: {org.kie.server.id}.xml   . For eg: src/main/resources  or somewhere inside our project jars.

Maciej Swiderski

unread,
Mar 21, 2019, 3:35:04 AM3/21/19
to Clinton Gomes, jBPM Usage
You can change it via system properties
org.kie.server.repo

Maciej

Wiadomość napisana przez Clinton Gomes <canuc...@gmail.com> w dniu 20.03.2019, o godz. 20:25:

Clinton Gomes

unread,
Mar 22, 2019, 11:59:17 AM3/22/19
to jBPM Usage
Thanks Marc. 
How do we package {org.kie.server.id}.xml  in spring boot? Since it lives outside the spring boot jar.

I'd like to deploy this file on openshift environment and maintain through git source control.

Please let me know if you'd like this question posted in another thread.

Clinton Gomes

unread,
Mar 22, 2019, 1:53:25 PM3/22/19
to jBPM Usage
Perhaps PV (persistent volumes) could help with {state}.xml file

Maciej Swiderski

unread,
Mar 22, 2019, 2:14:54 PM3/22/19
to Clinton Gomes, jBPM Usage
I’d more go for config map and mount that as file in the container 

Maciej

Wiadomość napisana przez Clinton Gomes <canuc...@gmail.com> w dniu 22.03.2019, o godz. 18:53:

Reply all
Reply to author
Forward
0 new messages