version 1.42.0
Announcements
Jakarta EE compatible Socket Mode
Since this version, developers can migrate to the newer Jakarta EE compatible WebSocket interface for Socket Mode modules. To enable this, the following two optional modules are added:
- com.slack.api:slack-jakarta-socket-mode-client
- com.slack.api:bolt-jakarata-socket-mode
The Socket Mode client's default implementation uses tyrus-standalone-client 1.x, which is compatible with javax.websocket-api APIs. The Jakarta EE version of this interface is the jakarta.websocket-client-api APIs, and tyrus-standalone-client 2.x is compatible with it. Since it's not feasible to have both tyrus-standalone-client 1.x and 2.x in the same module's dependencies, I have added a new module named slack-jakarta-socket-mode-client. See #919 for more details.
Developers can initialize the Jakarta-compatible SocketModeClient this way:
import com.slack.api.Slack;
import com.slack.api.jakarta_socket_mode.JakartaSocketModeClientFactory;
public class Example {
public static void main(String[] args) throws Exception {
var appToken = System.getenv("SLACK_APP_TOKEN");
var slack = Slack.getInstance();
// Java EE compatible Socket Mode client
slack.socketMode(appToken).connect();
// Jakarta EE compatible Socket Mode client
JakartaSocketModeClientFactory.create(slack, appToken).connect();
}
}
In the same way, I’ve added a new Jakarta-compatible module, which is equivalent to bolt-socket-mode. Here is the demo code. As you can see, just replace the dependency and imports in the code:
import com.slack.api.bolt.App;
import com.slack.api.bolt.jakarta_socket_mode.SocketModeApp;
public class Example {
public static void main(String[] args) throws Exception {
var app = new App();
app.command("/hi", (req, ctx) -> {
ctx.say("Hi there!");
return ctx.ack();
});
var appToken = System.getenv("SLACK_APP_TOKEN");
// Switch from com.slack.api.bolt.socket_mode to com.slack.api.bolt.jakarta_socket_mode
new SocketModeApp(appToken, app).start();
}
}
The reason behind this enhancement is that many Java-house companies are planning to eliminate the legacy javax.* dependencies from their project settings. I don't think the short-term risk of having a javax.websocket dependency is significant, but it seems it's about time to provide an option for migration on the developers' side.
Changes
- [slack-api-client][bot] #1352 Add Jakarta EE compatible Socket Mode client ref: #919 - Thanks @seratch
- [slack-api-client] Add missing properties in web API responses - Thanks @seratch
- All issues/pull requests: https://github.com/slackapi/java-slack-sdk/milestone/105?closed=1
- All changes: v1.41.0...v1.42.0