Skip to main content

Running a Microservice

After building a Job or Route to a Microservice, you can run it independent of Talend Studio in standalone mode.

To run a Microservice .jar file, proceed as follows in a console window:

  1. Change to the directory where the Microservice .jar file is located.

  2. Type in the following command.

    java -jar <ArchiveFileName> --context=<context_environment_name> --configuration.additional-location=<configuration_file_path> --<context_parameter_name>=<context_parameter_value>

By default, when running a Microservice, it calls the configuration files in the /config folder inside the Microservice Jar. You can switch to an external configuration folder where the configuration files are located using the configuration.additional-location property.

For example, the following command executes the Microservice DemoREST_0.1.jar using the configuration in the custom.properties file in the directory where the Microservice Jar is located.

java -jar DemoREST_0.1.jar --configuration.additional-location=./custom.properties

The following parameters can be configured in the properties file, for example:

# server 
server.protocol=http
server.host=0.0.0.0
server.port=8065
server.servlet.context-path=/services

# location of the logging configuration file
logging.config=classpath:config/log4j2.xml

# management
management.server.base-path=/
management.endpoints.web.exposure.include=info,health,jolokia,prometheus

# management - info
management.info.java.enabled=true

## Default use credentials for management enddpoints
security.user.name=${MS_SECURITY_USER_NAME:#{null}}
security.user.password=${MS_SECURITY_USER_PASSWORD:#{null}}

#SSL Configuration
#security.require-ssl=false
#server.ssl.key-store=dispatchJob/src/main/resources/config/keystore.jks
#server.ssl.key-store-type=JKS
#server.ssl.key-store-password=sspass
#server.ssl.key-store-alias=servicekey

Moreover, you can use the management.endpoints.secured=true/false parameter to activate or deactivate basic authentication for health and info endpoints, which has no impact on the basic authentication for jolokia endpoint.

You can customize the data exposed by the info endpoint by adding the management.info.env.enabled=true parameter and info.* properties in the properties file. For example:
info.app.encoding=UTF-8
info.app.java.source=17
info.app.java.target=17

Any context parameter in the Microservice configuration (application.properties) can be overridden. Here is the priority order of the context parameters, the latter overriding the former:

  1. Default context from the Microservice archive.
  2. --context=<context_environment_name>
  3. --config.additional-location=anyFile1,anyFile2
    1. anyFile1
    2. anyFile2
  4. --ctxParamName=ctxParamValue --ctxParamName=ctxOtherParamValue --ctxParam2Name=ctxParam2Value
    In this example, the second ctxParamName parameter overrides the first one. The result would be:
    ctxParamName=ctxOtherParamValue and ctxParam2Name=ctxParam2Value

To run a Microservice as a .zip file, proceed as follows:

  1. Extract the .zip file in the directory of your choice.

  2. Go to the <ArchiveFileName> folder that contains the external config folder, the Microservice .jar file, and the start scripts to start the Microservice for Linux (.sh) and Windows (.bat).

  3. Edit the configuration files in the config folder as needed and run the .sh file on Linux or the .bat file on Windows to start the Microservice with the external configurations.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!