本文介绍如何使用Java SDK查询所有事件总线。

示例代码如下:

import com.aliyun.eventbridge.EventBridge;
import com.aliyun.eventbridge.EventBridgeClient;
import com.aliyun.eventbridge.models.Config;
import com.aliyun.eventbridge.models.ListEventBusesRequest;
import com.aliyun.eventbridge.models.ListEventBusesResponse;

public class listEventBusSample {

    private EventBridge eventBridgeClient;

    public listEventBusSample()  {
        Config authConfig = new Config();
        authConfig.accessKeyId = "{accessKeyId}";
        authConfig.accessKeySecret = "{accessKeySecret}";
        authConfig.endpoint = "{endpoint}";
        eventBridgeClient = new EventBridgeClient(authConfig);
    }

    public void listEventBusSample() {
        try {
            ListEventBusesRequest listEventBusesRequest = new ListEventBusesRequest();
            ListEventBusesResponse response = eventBridgeClient.listEventBuses(listEventBusesRequest);
            System.out.println("list bus success : " + response);
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args)  {
        listEventBusSample sample = new listEventBusSample();
        try {
            sample.listEventBusSample();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}