Skip to main content

juneau-microservice

Maven
<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-microservice</artifactId>
<version>${juneau.version}</version>
</dependency>
Jarjuneau-microservice-10.0.0.jar
OSGiorg.apache.juneau.microservice_10.0.0.jar
LinksMaven Central · Javadocs · Source

Contents/Features​

Juneau Microservice is an API for creating stand-alone executable jars with automatic support for Juneau configurations and console commands.

Features include:

  • A builder-based API for defining and starting microservices.
  • An extensible API that allows you to hook into various lifecycle events.
  • Simple-to-use APIs for accessing manifest file entries, command-line arguments, and external configuration file properties.
  • A bean-store-aware inject-style bootstrap (@Configuration + @Bean) that lets companion modules — such as juneau-microservice-jetty — contribute servers, listeners, and servlets through standard @Bean definitions, rather than via subclassing.

When to use it​

Use juneau-microservice when you want a stand-alone executable jar that reads its settings from a config file and manifest. Add juneau-microservice-jetty to serve REST resources.

Example​

import org.apache.juneau.microservice.*;

public class MyMicroservice {

public static void main(String[] args) throws Exception {
// Build the microservice from the command-line arguments, start it, and wait for it to stop.
Microservice.create().args(args).build().start().join();
}
}

Options​

Builder methodUse it to
args(String...)Pass the command-line arguments
listener(MicroserviceListener)React to start, stop and config changes

Module Name (Renamed in 10.0)​

In 10.0 this module was renamed from juneau-microservice-core to juneau-microservice. The Java package (org.apache.juneau.microservice) is unchanged. See the V10 Migration Guide for the exact dependency update.

See also​

In This Section​