liveBook · Manning

Production mode

As explained in Quarkus in Action

Production mode is the Quarkus execution mode for running a packaged application without development-only features.

Production mode runs a packaged Quarkus application rather than the development server. Package the application with Maven, Gradle, or the Quarkus CLI, then start the executable quarkus-run.jar with java -jar. The startup log confirms that the prod profile is active. Unlike Dev mode, this run does not provide live reload. section 2.3 section 6.4.2

Listing 2.9 Running Quarkus with java -jar
$ java -jar target/quarkus-app/quarkus-run.jar
__  ____  __  _____   ___  __ ____  ______
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2024-09-26 17:00:34,488 INFO  [io.quarkus] (main) quarkus-in-action
 1.0.0-SNAPSHOT on JVM (powered by Quarkus 3.15.1) started in 0.456s.
 Listening on: http://0.0.0.0:8080
2024-09-26 17:00:34,492 INFO  [io.quarkus] (main) Profile prod activated.
2024-09-26 17:00:34,492 INFO  [io.quarkus] (main) Installed features: [cdi,
 rest, smallrye-context-propagation, vertx]

The command starts the packaged JVM application; the log line “Profile prod activated” verifies its execution mode. section 2.3

Packaging alone does not supply services that Quarkus previously managed during development. For example, services that rely on Dev mode to start and configure Keycloak need a separately running Keycloak instance and explicit connection settings in production mode. The example also runs PostgreSQL for Keycloak; its embedded, in-memory H2 database loses changes on restart. section 6.4

Listing 6.20 Wiring the Reservation service to manually managed Keycloak
%prod.quarkus.oidc.auth-server-url=http://localhost:7777/realms/car-rental
%prod.quarkus.oidc.client-id=reservation-service
%prod.quarkus.oidc.token-state-manager.split-tokens=true

The Reservation service sets its Keycloak realm URL and OIDC client ID under the %prod prefix. These properties apply in production mode without changing its Dev mode setup. section 6.4.2

The Users service needs corresponding %prod Keycloak settings. Both services also enable token-state-manager.split-tokens: the configured realm may produce session cookies larger than four kilobytes, which some browsers may ignore. Splitting the encrypted ID, access, and refresh tokens across separate cookies avoids that authentication problem. Production-mode execution is a step toward container and cloud deployment, not a substitute for configuring the infrastructure each service needs. section 6.4.2 section 11.0

How Quarkus in Action covers it

How deep it goes
Provides packaging commands, a startup check, and a service-configuration checklist, but does not detail production operation in Kubernetes.
Examples
Uses a packaged JAR startup log and %prod OIDC settings for Reservation and Users services.
What it assumes
Assumes an existing Quarkus service and introduces the commands and configuration needed to move it beyond Dev mode.
What you can do after
Operate/configure it by packaging a Quarkus service, starting its executable JAR, and supplying production-only Keycloak settings when needed.
How it connects
Connects production mode to Dev mode, configuration profiles, OIDC, Keycloak, PostgreSQL, containers, and cloud deployment.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quarkus in Action. The section links point to the parts of the book it draws on.