Skip to main content

Getting started

Prerequisites

  • Basic knowledge of Java

  • Installed:

Setup

The steps to create a new Micro Executor are the following

1. In your system, modify settings.xml file of Maven (typicaly you can find it in ~/.m2/settings.xml) adding this configuration

<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>https://repo.smeup.cloud/nexus/content/groups/public</url>
</mirror>
</mirrors>

2. With your favorite IDE, create new Maven project called me-java-tutorial

3. Modify pom.xml file adding this configurations:

  • Set Java 21 as the version for compiling the project
    <properties>
    <maven.compiler.source>21</maven.compiler.source>
    <maven.compiler.target>21</maven.compiler.target>
    </properties>
  • Add Kokos SDK library (necessary to build the Micro Executor) as dependency under <dependencies> tag
        <dependency>
    <groupId>com.smeup.kokos</groupId>
    <artifactId>kokos-sdk-java</artifactId>
    <version>2.3.0-SNAPSHOT</version>
    </dependency>

4. Create a Main class to start the Micro Executor

In the package com.smeup.kokos

package com.smeup.kokos;

import com.smeup.kokos.sdk.configuration.MicroExecutorConfiguration;
import com.smeup.kokos.sdk.entrypoint.restapi.RestApi;

public class Main {

private static final String ME_ID = "me-java-tutorial";

public static void main(String[] args) throws Exception {
// start server
RestApi.startServer(ME_ID, MicroExecutorConfiguration.class);
}
}

5. Start the Micro Executor server
Run the Main class created to start the Micro Executor server.

warning

If Data container is running, the Micro Executor won't be able to start becuase, by default, it automatically binds to the same port as the kokos-dispatcher (8000).

To avoid conflicts, open the file located at ~/etc/kokos/me-java-tutorial/me-java-tutorial.yaml (it's generated after the first start) and change port from 8000 to 8181 (or any other port that you are sure isn't in use by another service)

server:
port: 8181
idleTimeout: 30000
timeoutRequestOnExternalCall: 30000

Run again

6. Make it FUN!

Here is how you can be able to use a FUN to call your services at http://localhost:8181/swagger/index.html.
On endpoint POST /api/v2/executeFun

{
"fun": {
"component": "<SMEUP_DATA_STRUCTURE_TYPE>",
"service": "<SERVICE_NAME>",
"function": "<METHOD_NAME>"
},
"context": {
"user": {
"environment": "standard"
}
}
}

Example
  • SMEUP_DATA_STRUCTURE_TYPE: EXB
  • SERVICE_NAME: SER_EXM
  • METHOD_NAME: INIT
    {
"fun": {
"component": "EXB",
"service": "SER_EXM",
"function": "INIT"
},
"context": {
"user": {
"environment": "standard"
}
}
}