Skip to content

Navigation Menu

Sign in
Sign up

Getting Started with Quarkus

jfarcand edited this page Feb 18, 2026 · 7 revisions

Getting Started with Quarkus

Build a real-time chat application with Atmosphere and Quarkus 3.21+.

Prerequisites

  • JDK 21+
  • Maven 3.9+

1. Create the Project

<properties>
 <quarkus.version>3.31.3</quarkus.version>
 <maven.compiler.release>21</maven.compiler.release>
</properties>
<dependencyManagement>
 <dependencies>
 <dependency>
 <groupId>io.quarkus</groupId>
 <artifactId>quarkus-bom</artifactId>
 <version>${quarkus.version}</version>
 <type>pom</type>
 <scope>import</scope>
 </dependency>
 </dependencies>
</dependencyManagement>
<dependencies>
 <dependency>
 <groupId>org.atmosphere</groupId>
 <artifactId>atmosphere-quarkus-extension</artifactId>
 <version>4.0.0</version>
 </dependency>
 <dependency>
 <groupId>io.quarkus</groupId>
 <artifactId>quarkus-undertow</artifactId>
 </dependency>
 <dependency>
 <groupId>io.quarkus</groupId>
 <artifactId>quarkus-websockets</artifactId>
 </dependency>
 <dependency>
 <groupId>io.quarkus</groupId>
 <artifactId>quarkus-jackson</artifactId>
 </dependency>
</dependencies>
<build>
 <plugins>
 <plugin>
 <groupId>io.quarkus</groupId>
 <artifactId>quarkus-maven-plugin</artifactId>
 <version>${quarkus.version}</version>
 <extensions>true</extensions>
 <executions>
 <execution>
 <goals><goal>build</goal></goals>
 </execution>
 </executions>
 </plugin>
 </plugins>
</build>

2. Configure

In application.properties:

quarkus.atmosphere.packages=com.example.chat

The extension auto-configures the AtmosphereServlet and handles build-time annotation scanning.

Available Properties

Property Default Description
quarkus.atmosphere.packages (none) Packages to scan for annotations
quarkus.atmosphere.servlet-path /atmosphere/* Servlet URL mapping
quarkus.atmosphere.session-support false Enable HttpSession support
quarkus.atmosphere.heartbeat-interval-in-seconds (default) Heartbeat frequency

3. Create the Chat Service

The code is identical to other deployment models — @ManagedService works the same everywhere:

@ManagedService(path = "/atmosphere/chat",
 atmosphereConfig = "org.atmosphere.cpr.maxInactiveActivity=120000")
public class Chat {
 @Inject
 private AtmosphereResource r;
 @Inject
 private AtmosphereResourceEvent event;
 @Ready
 public void onReady() {
 // Connection is ready
 }
 @Disconnect
 public void onDisconnect() {
 if (event.isClosedByClient()) {
 // Client closed the connection
 }
 }
 @Message(encoders = {JacksonEncoder.class}, decoders = {JacksonDecoder.class})
 public Message onMessage(Message message) {
 return message;
 }
}

4. Run in Dev Mode

mvn quarkus:dev

Open http://localhost:8080 and start chatting!

Native Image

The Quarkus extension supports GraalVM native compilation:

mvn package -Dnative
./target/atmosphere-quarkus-chat-4.0.0-runner

The extension registers all Atmosphere classes for reflection at build time, so native images work out of the box.

How It Works

The Quarkus extension differs from other deployment models in how it initializes:

  1. Build timeAtmosphereProcessor scans for Atmosphere annotations and registers classes for reflection
  2. Build time — JSR-356 WebSocket endpoints are registered via AtmosphereRecorder
  3. RuntimeQuarkusAtmosphereServlet initializes the framework with the pre-scanned annotation map
  4. RuntimeQuarkusAtmosphereObjectFactory delegates bean creation to the Arc CDI container

This build-time processing is what makes Quarkus startup fast and native-image compatible.

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /