百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

ably-java

> 开发工具
开源

用于 Ably 实时消息服务的 Java、Android、Clojure 和 Scala 客户端库 SDK

100 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

用于 Ably 实时消息服务的 Java、Android、Clojure 和 Scala 客户端库 SDK

Ably Pub/Sub Java SDK

Build any realtime experience using Ably’s Pub/Sub Java SDK. Supported on all popular platforms and frameworks, including Kotlin and Android.

Ably Pub/Sub provides flexible APIs that deliver features such as pub-sub messaging, message history, presence, and push notifications. Utilizing Ably’s realtime messaging platform, applications benefit from its highly performant, reliable, and scalable infrastructure.

Find out more:

  • Ably Pub/Sub docs.
  • Ably Pub/Sub examples.

Getting started

Everything you need to get started with Ably:

  • Getting started with Pub/Sub using Java.
  • SDK Setup for Java.

Supported platforms

Ably aims to support a wide range of platforms. If you experience any compatibility issues, open an issue in the repository or contact Ably support.

The following platforms are supported:

Platform Support
Java >= 1.8 (JRE 8 or later)
Kotlin All versions (>= 1.0 supported), but we recommend >= 1.8 for best compatibility.
Android >=4.4 (API level 19)

[!IMPORTANT] SDK versions io.ably ably-java 1.8.2


### Install for Gradle:

```gradle
implementation 'io.ably:ably-java:1.8.2'
implementation 'org.slf4j:slf4j-simple:2.0.7'

Run the following to instantiate a client:

java
import io.ably.lib.realtime.AblyRealtime;
import io.ably.lib.types.ClientOptions;

ClientOptions options = new ClientOptions(apiKey);
AblyRealtime realtime = new AblyRealtime(options);

Usage

The following code connects to Ably's realtime messaging service, subscribes to a channel to receive messages, and publishes a test message to that same channel.

java
// Initialize Ably Realtime client
ClientOptions options = new ClientOptions("your-ably-api-key");
options.clientId = "me";
AblyRealtime realtimeClient = new AblyRealtime(options);

// Wait for connection to be established
realtimeClient.connection.on(ConnectionEvent.connected, connectionStateChange -> {
    System.out.println("Connected to Ably");
    
    // Get a reference to the 'test-channel' channel
    Channel channel = realtimeClient.channels.get("test-channel");
    
    // Subscribe to all messages published to this channel
    channel.subscribe(message -> {
        System.out.println("Received message: " + message.data);
    });
    
    // Publish a test message to the channel
    channel.publish("test-event", "hello world");
});

Live Objects

Ably Live Objects provide realtime, collaborative data structures that automatically synchronize state across all connected clients. Build interactive applications with shared data that updates instantly across devices.

For a comprehensive guide, check the Ably Live Objects documentation, starting with the Java quickstart.

Install Live Objects

Add the following dependency to your build.gradle file:

groovy
dependencies {
    runtimeOnly("io.ably:liveobjects:1.8.2")
}

…

java
import io.ably.lib.realtime.AblyRealtime;
import io.ably.lib.rest.AblyRest;
import io.ably.lib.transport.Defaults;
import io.ably.lib.types.ClientOptions;
import io.ably.lib.types.ProxyOptions;
import io.ably.lib.http.HttpAuth;

public class AblyWithProxy {
    public static void main(String[] args) throws Exception {
        // Configure Ably Client options
        ClientOptions options = new ClientOptions();
        
        // Setup proxy settings
        ProxyOptions proxy = new ProxyOptions();
        proxy.host = "your-proxy-host";  // Replace with your proxy host
        proxy.port = 8080;               // Replace with your proxy port
        
        // Optional: If the proxy requires authentication
        proxy.username = "your-username";  // Replace with proxy username
        proxy.password = "your-password";  // Replace with proxy password
        proxy.prefAuthType = HttpAuth.Type.BASIC;  // Choose your preferred authentication type (e.g., BASIC or DIGEST)

        // Attach the proxy settings to the client options
        options.proxy = proxy;

        // Create an instance of Ably using the configured options
        AblyRest ably = new AblyRest(options);

        // Alternatively, for real-time connections
        AblyRealtime ablyRealtime = new AblyRealtime(options);

        // Use the Ably client as usual
    }
}

Contribute

Read the CONTRIBUTING.md guidelines to contribute to Ably.


Releases

The CHANGELOG.md contains details of the latest releases for this SDK. You can also view all Ably releases on changelog.ably.com.


Support, feedback, and troubleshooting

For help or technical support, visit Ably's support page or GitHub Issues for community-reported bugs and discussions.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Javaandroidclient-libraryclojurejava

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类开发工具
定价开源

> 相关工具

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具