本文介绍如何使用Java SDK删除一个事件总线。

示例代码如下:

import com.aliyun.eventbridge.EventBridge;
import com.aliyun.eventbridge.EventBridgeClient;
import com.aliyun.eventbridge.models.Config;
import com.aliyun.eventbridge.models.DeleteEventBusRequest;

public class deleteEventBusSample {

    private EventBridge eventBridgeClient;

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

    public void deleteEventBusSample() {
        try {
            DeleteEventBusRequest deleteEventBusRequest = new DeleteEventBusRequest();
            deleteEventBusRequest.setEventBusName("mybus");
            eventBridgeClient.deleteEventBus(deleteEventBusRequest);
            System.out.println("delete bus success : " + deleteEventBusRequest.getEventBusName());
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }

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