This topic describes how to use the SDK for Java to query the details of an event bus.
Sample code:
import com.aliyun.eventbridge.EventBridge;
import com.aliyun.eventbridge.EventBridgeClient;
import com.aliyun.eventbridge.models.Config;
import com.aliyun.eventbridge.models.GetEventBusRequest;
import com.aliyun.eventbridge.models.GetEventBusResponse;
public class getEventBusSample {
private EventBridge eventBridgeClient;
public getEventBusSample() {
Config authConfig = new Config();
authConfig.accessKeyId = "{accessKeyId}";// The AccessKey ID for identity authentication. You can create AccessKey IDs in the RAM console. For more information about how to obtain the ID, see Obtain an AccessKey pair.
authConfig.accessKeySecret = "{accessKeySecret}";// The AccessKey secret for identity authentication. You can create AccessKey secrets in the RAM console. For more information about how to obtain the secret, see Obtain an AccessKey pair.
authConfig.endpoint = "{endpoint}";// The endpoint. For more information, see Regions and endpoints.
eventBridgeClient = new EventBridgeClient(authConfig);
}
public void getEventBusSample() {
try {
GetEventBusRequest describeEventBusRequest = new GetEventBusRequest();
describeEventBusRequest.setEventBusName("mybus");
GetEventBusResponse deScribeResponse = eventBridgeClient.getEventBus(describeEventBusRequest);
System.out.println("describe bus success : " + deScribeResponse);
} catch (Throwable e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
getEventBusSample sample = new getEventBusSample();
try {
sample.getEventBusSample();
} catch (Throwable e) {
e.printStackTrace();
}
}
}