This topic describes how to use the SMC Java SDK to call the DeleteSourceServer operation to delete a migration source.

Background information

You can delete a migration source by calling the DeleteSourceServer operation. For more information, see DeleteSourceServer.

  • If a migration source is associated with a migration task in the Running state, the migration source cannot be deleted.
  • If a migration source is associated with a migration task in a non-Running state, you must set the Force parameter to true to force delete the migration source.

Sample code

The following code can be used to force delete a migration source:

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.smc.model.v20190601.DeleteSourceServerRequest;
import com.aliyuncs.smc.model.v20190601.DeleteSourceServerResponse;

public class DeleteSourceServer {
    public static void main(String[] args) {
        // Initialize the AcsClient instance, and set the region ID and your AccessKey pair.
        DefaultProfile profile = DefaultProfile.getProfile("<region-Id>", "<accessKeyId>", "<accessSecret>");
        IAcsClient client = new DefaultAcsClient(profile);

        // Create an API request and configure its parameters.
        DeleteSourceServerRequest request = new DeleteSourceServerRequest();
        // The ID of the migration source.
        // Specify whether to force delete the migration source.

        // Send the request to obtain the return value or handle the exception.
        try {
            DeleteSourceServerResponse response = client.getAcsResponse(request);
            System.out.println(new Gson().toJson(response));
        } catch (ServerException e) {
        } catch (ClientException e) {


    "RequestId": "0A01347D-887F-4816-85B3-2BB8A298AA27"