-
-
Notifications
You must be signed in to change notification settings - Fork 761
Migrating from 2.x to 4.0
jfarcand edited this page Feb 18, 2026
·
3 revisions
Atmosphere 4.0 is a major release with significant changes from 2.x:
| Area | 2.x | 4.0 |
|---|---|---|
| Java version | JDK 8+ | JDK 21+ |
| Servlet API | javax.servlet |
jakarta.servlet (Jakarta EE 10+) |
| Dependency injection | javax.inject |
jakarta.inject |
| Client library | jQuery-based atmosphere.js | TypeScript atmosphere.js 5.0 |
| Chat/groups | Manual Broadcaster management | First-class Rooms API |
| Spring Boot | Spring Boot 2.x (community) | Spring Boot 4.0 (official starter) |
| Quarkus | Not supported | Official extension |
All javax.* packages are now jakarta.*:
// 2.x import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; // 4.0 import jakarta.inject.Inject; import jakarta.servlet.http.HttpServletRequest;
The core annotation model is the same. Your @ManagedService classes work with minimal changes:
// Same in both 2.x and 4.0 @ManagedService(path = "/chat") public class Chat { @Ready public void onReady() { } @Disconnect public void onDisconnect() { } @Message(encoders = {JacksonEncoder.class}, decoders = {JacksonDecoder.class}) public Message onMessage(Message message) { return message; } }
The following have been removed or replaced in 4.0:
| Removed | Replacement |
|---|---|
| Jersey integration | Use @ManagedService or Spring Boot |
| GWT support | Use atmosphere.js 5.0 |
| Socket.IO protocol | Use atmosphere.js 5.0 |
| Cometd protocol | Use atmosphere.js 5.0 |
| SwaggerSocket | Removed |
| Meteor API | Use @ManagedService
|
@MeteorService |
Use @ManagedService
|
web.xml-only config |
Still supported, but annotation-based is preferred |
| jQuery dependency | atmosphere.js 5.0 has zero dependencies |
| Feature | Description |
|---|---|
| Rooms | Named groups with presence, history, direct messaging |
| RoomManager | Create/manage rooms backed by Broadcasters |
| PresenceEvent | Join/leave tracking with member identity |
| RoomMember | Application-level member ID (stable across reconnects) |
| RoomAuthorizer | Authorization for room operations |
| Framework hooks | React useRoom, Vue useRoom, Svelte createRoomStore
|
| Spring Boot 4.0 starter | Auto-configuration, health, metrics |
| Quarkus extension | Build-time processing, native image support |
var socket = $.atmosphere; var request = { url: '/chat', transport: 'websocket', fallbackTransport: 'long-polling' }; request.onMessage = function(response) { var message = response.responseBody; }; var subSocket = socket.subscribe(request); subSocket.push(JSON.stringify(data));
import { Atmosphere } from 'atmosphere.js'; const atm = new Atmosphere(); const sub = await atm.subscribe( { url: '/chat', transport: 'websocket', fallbackTransport: 'long-polling', }, { message: (response) => { const data = JSON.parse(response.responseBody); }, } ); sub.push(JSON.stringify(data));
The global atmosphere object is still available for <script> tag usage (no build step):
const sub = await atmosphere.atmosphere.subscribe(request, handlers);
- Update JDK to 21+
-
Replace
javax.*imports withjakarta.* -
Update
atmosphere-runtimedependency to4.0.0 -
Replace Jersey/Meteor code with
@ManagedService(if not already using it) -
Update
atmosphere.jsto 5.0 and remove jQuery dependency - Optionally adopt Rooms for group messaging patterns
- Optionally adopt Spring Boot starter or Quarkus extension
Update the web-app namespace for Jakarta EE:
<!-- 2.x --> <web-app xmlns="http://java.sun.com/xml/ns/javaee" version="3.0"> <!-- 4.0 --> <web-app xmlns="https://jakarta.ee/xml/ns/jakartaee" version="6.0">
The AtmosphereServlet class name is unchanged: org.atmosphere.cpr.AtmosphereServlet.