-
-
Notifications
You must be signed in to change notification settings - Fork 761
Getting Started with Quarkus
jfarcand edited this page Feb 18, 2026
·
7 revisions
Build a real-time chat application with Atmosphere and Quarkus 3.21+.
- JDK 21+
- Maven 3.9+
<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>
In application.properties:
quarkus.atmosphere.packages=com.example.chatThe extension auto-configures the AtmosphereServlet and handles build-time annotation scanning.
| 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 |
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; } }
mvn quarkus:dev
Open http://localhost:8080 and start chatting!
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.
The Quarkus extension differs from other deployment models in how it initializes:
-
Build time —
AtmosphereProcessorscans for Atmosphere annotations and registers classes for reflection -
Build time — JSR-356 WebSocket endpoints are registered via
AtmosphereRecorder -
Runtime —
QuarkusAtmosphereServletinitializes the framework with the pre-scanned annotation map -
Runtime —
QuarkusAtmosphereObjectFactorydelegates bean creation to the Arc CDI container
This build-time processing is what makes Quarkus startup fast and native-image compatible.