All Products
Search
Document Center

ApsaraVideo Media Processing:Manage MPS queues

Last Updated:Mar 26, 2024

An ApsaraVideo Media Processing (MPS) queue is a queue for processing jobs. After you submit asynchronous jobs, the jobs are queued for running based on the job priorities and the sequence in which the jobs are submitted. This topic provides examples on how to call API operations to create, update, delete, and query MPS queues. The API operations are encapsulated in MPS SDK for Java.

Prerequisites

MPS SDK for Java is initialized. For more information, see Initialize a client.

AddPipeline

Creates an MPS queue.

Note
  • For more information about MPS queue types, see Create an MPS queue.

  • If the error message "The resource "Pipeline" quota has been used up" is returned, your MPS queue quota has been used up. You can submit a ticket to apply for quota increases.

  • For more information about how to configure parameters related to notifications, see the NotifyConfig section of the "Parameter details" topic.

  • You can configure a Message Service (MNS) queue or topic to receive notifications. For more information, see Enable the notification feature for MPS jobs or workflows.

/**
 * AddPipeline
 * @param client
 * @return
 * @throws Exception
 */
public static AddPipelineResponse addPipeline(DefaultAcsClient client) throws Exception {

    AddPipelineRequest request = new AddPipelineRequest();
    request.setName("test-pipeline");
    // The type of the MPS queue.
    request.setSpeed("Standard");
    //request.setSpeedLevel(1l);
    //request.setNotifyConfig("{\"Topic\":\"mts-topic-1\"}");

    return client.getAcsResponse(request);
}

UpdatePipeline

Updates an MPS queue.

/**
 * UpdatePipeline
 * @param client
 * @return
 * @throws Exception
 */
public static UpdatePipelineResponse updatePipeline(DefaultAcsClient client) throws Exception {

    UpdatePipelineRequest request = new UpdatePipelineRequest();
    // The ID of the MPS queue. To view the ID, log on to the MPS console. In the left-side navigation pane, choose Global Settings > MPS Queue and Callback. You can also obtain the ID of an MPS queue from the response that is returned after you create the MPS queue by calling the AddPipeline operation.
    request.setPipelineId("e03549d796fad2bcb32a****");
    request.setName("update name");
    // The status of the MPS queue. Valid values: Active and Paused. A value of Active indicates that the MPS queue is enabled. A value of Paused indicates that the MPS queue is disabled.
    request.setState("Active");
    //request.setNotifyConfig("{\"Topic\":\"mts-topic-1\"}");

    return client.getAcsResponse(request);
}

DeletePipeline

Deletes an MPS queue.

/**
 * DeletePipeline
 * @param client
 * @return
 * @throws Exception
 */
public static DeletePipelineResponse deletePipeline(DefaultAcsClient client) throws Exception {

    DeletePipelineRequest request = new DeletePipelineRequest();
    // The ID of the MPS queue. To view the ID, log on to the MPS console. In the left-side navigation pane, choose Global Settings > MPS Queue and Callback. You can also obtain the ID of an MPS queue from the response that is returned after you create the MPS queue by calling the AddPipeline operation.
    request.setPipelineId("e03549d796fadd82bcb32a****");

    return client.getAcsResponse(request);
}

QueryPipelineList

Queries one or more MPS queues based on the IDs of the MPS queues.

/**
 * QueryPipelineList
 * @param client
 * @return
 * @throws Exception
 */
public static QueryPipelineListResponse queryPipelineList(DefaultAcsClient client) throws Exception {

    QueryPipelineListRequest request = new QueryPipelineListRequest();
    // The ID of the MPS queue. To view the ID, log on to the MPS console. In the left-side navigation pane, choose Global Settings > MPS Queue and Callback. You can also obtain the ID of an MPS queue from the response that is returned after you create the MPS queue by calling the AddPipeline operation.
    // You can query up to 10 MPS queues at a time. Separate the IDs of MPS queues with commas (,).
    request.setPipelineIds("e03549d796fad2bcb32a****");

    return client.getAcsResponse(request);
}

SearchPipeline

Queries MPS queues in the specified state.

/**
 * SearchPipeline
 * @param client
 * @return
 * @throws Exception
 */
public static SearchPipelineResponse searchPipeline(DefaultAcsClient client) throws Exception {

    SearchPipelineRequest request = new SearchPipelineRequest();
    // The status of the MPS queues. Valid values: All, Active, and Paused. A value of All indicates all MPS queues. A value of Active indicates enabled MPS queues. A value of Paused indicates disabled MPS queues.
    request.setState("All");

    return client.getAcsResponse(request);
}

Sample code

import com.aliyun.mps.utils.InitClient;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.mts.model.v20140618.*;

/**
 * *****   Usage notes     ******
 * This example shows basic operations on an MPS queue.
 *
 * *****   Methods     ******
 * For more information about AddPipeline, visit https://www.alibabacloud.com/help/zh/apsaravideo-for-media-processing/latest/api-doc-mts-2014-06-18-api-doc-addpipeline.
 * For more information about UpdatePipeline, visit https://www.alibabacloud.com/help/zh/apsaravideo-for-media-processing/latest/api-doc-mts-2014-06-18-api-doc-updatepipeline.
 * For more information about DeletePipeline, visit https:/www.alibabacloud.com/help/zh/apsaravideo-for-media-processing/latest/api-doc-mts-2014-06-18-api-doc-deletepipeline.
 * For more information about QueryPipelineList, visit https://www.alibabacloud.com/help/zh/apsaravideo-for-media-processing/latest/api-doc-mts-2014-06-18-api-doc-querypipelinelist.
 * For more information about SearchPipeline, visit https://www.alibabacloud.com/help/zh/apsaravideo-for-media-processing/latest/api-doc-mts-2014-06-18-api-doc-searchpipeline.
 *
 * For more information about the NotifyConfig parameter, visit https://www.alibabacloud.com/help/zh/apsaravideo-for-media-processing/latest/parameter-details-a#section-ayf-324-y2b.
 * ***** main method ******
 * In this example, only the AddPipeline and UpdatePipeline operations are called. If you want to call another operation, set response to the operation that you require.
 */
public class Pipeline {

    public static void main(String[] args) throws ClientException {

        // Initialize the SDK client.
        DefaultAcsClient client = InitClient.initMpsClient();

        AddPipelineResponse response;
        try {
            response = addPipeline(client);
            System.out.println("RequestId is:" + response.getRequestId());
            System.out.println("pipelineId is:" + response.getPipeline().getId());
        } catch (Exception e) {
            e.printStackTrace();
        }

//        UpdatePipelineResponse response;
//        try {
//            response = updatePipeline(client);
//            System.out.println("RequestId is:" + response.getRequestId());
//            System.out.println("Pipeline is:" + JSON.toJSON(response.getPipeline()));
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

    }

    /**
     * AddPipeline
     * @param client
     * @return
     * @throws Exception
     */
    public static AddPipelineResponse addPipeline(DefaultAcsClient client) throws Exception {

        AddPipelineRequest request = new AddPipelineRequest();
        request.setName("test-pipeline");
        // The type of the MPS queue.
        request.setSpeed("Standard");
        //request.setSpeedLevel(1l);
        //request.setNotifyConfig("{\"Topic\":\"mts-topic-1\"}");

        return client.getAcsResponse(request);
    }

    /**
     * UpdatePipeline
     * @param client
     * @return
     * @throws Exception
     */
    public static UpdatePipelineResponse updatePipeline(DefaultAcsClient client) throws Exception {

        UpdatePipelineRequest request = new UpdatePipelineRequest();
        // The ID of the MPS queue. To view the ID, log on to the MPS console. In the left-side navigation pane, choose Global Settings > MPS Queue and Callback. You can also obtain the ID of an MPS queue from the response that is returned after you create the MPS queue by calling the AddPipeline operation.
        request.setPipelineId("e03549796fad9d72bcb32a****");
        request.setName("update name");
        // The status of the MPS queue. Valid values: Active and Paused. A value of Active indicates that the MPS queue is enabled. A value of Paused indicates that the MPS queue is disabled.
        request.setState("Active");
        //request.setNotifyConfig("{\"Topic\":\"mts-topic-1\"}");

        return client.getAcsResponse(request);
    }

    /**
     * DeletePipeline
     * @param client
     * @return
     * @throws Exception
     */
    public static DeletePipelineResponse deletePipeline(DefaultAcsClient client) throws Exception {

        DeletePipelineRequest request = new DeletePipelineRequest();
        // The ID of the MPS queue. To view the ID, log on to the MPS console. In the left-side navigation pane, choose Global Settings > MPS Queue and Callback. You can also obtain the ID of an MPS queue from the response that is returned after you create the MPS queue by calling the AddPipeline operation.
        request.setPipelineId("e03549796fad9d7d82bcb32a****");

        return client.getAcsResponse(request);
    }

    /**
     * QueryPipelineList
     * @param client
     * @return
     * @throws Exception
     */
    public static QueryPipelineListResponse queryPipelineList(DefaultAcsClient client) throws Exception {

        QueryPipelineListRequest request = new QueryPipelineListRequest();
        // The ID of the MPS queue. To view the ID, log on to the MPS console. In the left-side navigation pane, choose Global Settings > MPS Queue and Callback. You can also obtain the ID of an MPS queue from the response that is returned after you create the MPS queue by calling the AddPipeline operation.
        // You can query up to 10 MPS queues at a time. Separate the IDs of MPS queues with commas (,).
        request.setPipelineIds("e03549d796fad2bcb32a****");

        return client.getAcsResponse(request);
    }

    /**
     * SearchPipeline
     * @param client
     * @return
     * @throws Exception
     */
    public static SearchPipelineResponse searchPipeline(DefaultAcsClient client) throws Exception {

        SearchPipelineRequest request = new SearchPipelineRequest();
        // The status of the MPS queues. Valid values: All, Active, and Paused. A value of All indicates all MPS queues. A value of Active indicates enabled MPS queues. A value of Paused indicates disabled MPS queues.
        request.setState("All");

        return client.getAcsResponse(request);
    }
}
            

References