Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

Managing Flows in a Cluster Using REST APIs

The management console provides REST APIs that you can use to programmatically access much of the console’s functionality. Among the operations that you can request with the REST APIs are operations related to managing flows in a cluster. This includes finding flows in a cluster, as well as starting and stopping a flow’s endpoints.

See Using the Management Console APIs for an overview of the REST APIs, including a basic example of use, and a summary of returned status codes and error handling codes.

This page provides a brief description of each REST API for managing flows in a cluster, an HTTP method to invoke the API, and a usage example. The examples show how to invoke the API using cURL, the command line HTTP tool.

Note: The notation \{mmc base} refers to the console base address. The console base address used in the examples is http://localhost:8080/mmc and configured with the default username and password (admin:admin).

The table below summarizes the REST APIs for managing deployments:

Task Resource Description HTTP Invocation Method

Get Flows

\{mmc base}/api/clusters/<cluster>/flows

Lists all flows in a cluster

GET

Get Flow Endpoints

\{mmc base}/api/clusters/<cluster>/flows/<flowName>/<application>/endpoints

Lists all endpoints for a flow

GET

Start or Stop Endpoints

\{mmc base}/api/clusters/<cluster>/flows/<flowName>/<applicationName>/endpoints/<endpointId>/start (or stop)

Starts (or stops) an endpoint for a flow

POST

Start or Stop a Flow

\{mmc base}/api/clusters/<cluster>/flows/<flowName>/<applicationName>/start (or stop)

Starts or stops a flow

POST

All examples on this page use the cluster and data as shown below:


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{
    "data": [
        {
            "clusterStatus": "OK",
            "deployments": [],
            "groupIds": [],
            "id": "fb044ee2-f097-43e1-8e1f-4b446f703cac",
            "lastRestarted": 1314982582819,
            "location": "N/A",
            "name": "ClusterXY",
            "nodeServerIds": [
                "local$191630af-3cfa-4535-87f8-420f7eb03c0f",
                "local$2364843f-dd47-4556-97e0-105e0011ee2d"
            ],
            "nodesUpCount": 2,
            "pausedServices": 0,
            "runningServices": 0,
            "status": "2 of 2 nodes online",
            "stoppedServices": 0,
            "totalServices": 0,
            "version": "3.2.0-RC3"
        }
    ],
    "total": 1
}

Get Flows

Lists all the flows in a cluster.

HTTP Method:

GET

URL:


         
      
1
http://{mmc base}/api/clusters/{cluster}/flows

Parameters:

cluster: The name or ID of a cluster for the listed flows.

Example:

The following example shows how to list the flows for a cluster with an ID of fb044ee2-f097-43e1-8e1f-4b446f703cac:

Request:


         
      
1
curl --basic -u admin:admin http://localhost:8080/mmc/api/clusters/ClusterXY/flows

JSON Response:


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{
    "data": [
        {
            "asyncEventsReceived": 0,
            "auditStatus": "DISABLED",
            "averageProcessingTime": -1,
            "executionErrors": 0,
            "fatalErrors": 0,
            "favorite": false,
            "flowId": {
                "application": "mule-example-echo-3.2.0-RC3",
                "definedInApplication": true,
                "fullName": "EchoFlow [mule-example-echo-3.2.0-RC3]",
                "name": "EchoFlow"
            },
            "id": "fb044ee2-f097-43e1-8e1f-4b446f703cac/EchoFlow",
            "inboundEndpoints": [
                "http://localhost:65082/services/EchoUMO"
            ],
            "maxProcessingTime": 0,
            "minProcessingTime": 0,
            "processedEvents": 0,
            "clusterId": "fb044ee2-f097-43e1-8e1f-4b446f703cac",
            "status": "RUNNING",
            "syncEventsReceived": 0,
            "totalEventsReceived": 0,
            "totalProcessingTime": 0,
            "type": "flow"
        }
    ],
    "total": 1
}

Get Flow Endpoints

Lists all endpoints for a flow.

HTTP Method:

GET

URL:


         
      
1
{mmc base}/api/clusters/{cluster}/flows/{flowName}/{applicationName}/endpoints

Parameters:

  • cluster: The ID of the cluster.

  • applicationName: The application name of the flow.

  • flowName: The name of the flow.

Example:

The following example shows how to list the endpoints for a flow named EchoFlow, whose application name is test-app, in the cluster whose ID is fb044ee2-f097-43e1-8e1f-4b446f703cac:

Request:


         
      
1
curl --basic -u admin:admin http://localhost:8080/mmc/api/clusters/ClusterXY/flows/EchoFlow/test-app/endpoints

JSON Response:


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
    "data": [
        {
            "address": "http://localhost:65082/services/EchoUMO",
            "connector": "connector.http.mule.default",
            "filtered": false,
            "id": "endpoint.http.localhost.65082.services.EchoUMO",
            "routedMessages": 0,
            "status": "started",
            "synchronous": true,
            "tx": false,
            "type": "http"
        }
    ],
    "total": 1
}

Start/Stop Endpoints

Start or Stop an endpoint for a specified flow.

HTTP Method:

POST

URL:

Start:


         
      
1
http://{mmc base}/clusters/{cluster}/flows/{flowName}/{applicationName}/endpoints/{endpointId}/start

Stop:


         
      
1
http://{mmc base}/clusters/{cluster}/flows/{flowName}/{applicationName}/endpoints/{endpointId}/stop

Parameters:

  • cluster: The name or ID of a cluster.

  • applicationName: The application name of the flow.

  • flowName: The name of the flow name.

  • endpointId: The name of an endpoint to be started or stopped.

Example:

Request:

Start an endpoint:


         
      
1
curl --basic -u admin:admin -X POST http://localhost:8080/mmc/api/clusters/ClusterXY/flows/EchoFlow/test-app/endpoints/endpoint.http.localhost.65082.services.EchoUMO/start

Stop an endpoint:


         
      
1
curl --basic -u admin:admin -X POST http://localhost:8080/mmc/api/clusters/ClusterXY/flows/EchoFlow/test-app/endpoints/endpoint.http.localhost.65082.services.EchoUMO/stop

JSON Response:

A list of endpoints that have been successfully started or stopped.


         
      
1
["endpoint.http.localhost.65082.services.EchoUMO"]

Start/Stop a Flow

Starts or stops a flow in a cluster.

HTTP Method:

POST

URL:

Start:


         
      
1
http://{mmc base}/api/clusters/{cluster}/flows/{flowName}/{applicationName}/start

Stop:


         
      
1
http://{mmc base}/api/clusters/{cluster}/flows/{flowName}/{applicationName}/stop

Parameters:

  • cluster: The name or ID of a cluster.

  • applicationName: The application name of the flow.

  • flowName: The name of the flow.

Example:

Request:

Start a flow:


         
      
1
curl --basic -u admin:admin -X POST http://localhost:8080/mmc/api/clusters/ClusterXY/flows/EchoFlow/test-app/start

Stop a flow:


         
      
1
url --basic -u admin:admin -X POST http://localhost:8080/mmc/api/clusters/ClusterXY/flows/EchoFlow/test-app/stop

Response:


         
      
1
The flow started or stopped successfully