Open Beta

Create the choreography

AMPLIFY Choreography text-based command line interface (CLI) is used to create the choreography. Choreography allows the publishing service to execute the service and publish the output without having to be aware of the subscribing services. The subscribing services listen for new publish events and receive the update.

Before you start

$ amplify ace choreography list

Objectives

Use CLI commands to create a choreography that you can then define with JSON services.

Create the choreography

The choreography add command creates the choreography.

Note   You can also use choreo as a shortcut for choreography.

amplify ace choreography add --f=<filePath>

FilePath = the path to the JSON file where the choreography is defined.

Note   If a service specified in the choreography does not exist when the choreography add command is executed, the choreography will not be added and an error message is displayed.

Define the choreography

A choreography can contain one or more services. Services can be defined so that they run in parallel, or run in a parent / child relationship or in a combination of both.

When a choreography is executed, any payload passed in will be passed to all "parent" services. All parent services will run in parallel.

Child services do not receive the payload that is passed in when the choreography is executed; however, they do receive the output from their parent service as input.

Note   Services do not have to generate output (i.e. output is not enforced by the platform). The person creating the choreography must be familiar with the output of each service and the input needs of each service to ensure that the services are compatible.

Child services run after their parent service has completed.

JSON service examples

Single service

{
	"choreographyName": "Choreo_Single_Service",
	"stepChain": [{
		"serviceName": "ServiceName1",
		"serviceVersion": "1.0.0"
	}]
}

Two parents with no children service

{
	"choreographyName": "Choreo_2Parents_NoChildren",
	"stepChain": [{
			"serviceName": "testService1",
			"serviceVersion": "2.0.0"
		},
		{
			"serviceName": "testService2",
			"serviceVersion": "1.0.0"
		}
	]
}

One parent with one child service

{
	"choreographyName": "Choreo_OneParent_OneChild",
	"stepChain": [{
		"serviceName": "ServiceName1",
		"serviceVersion": "1.0.0",
		"child": [{
			"serviceName": "ServiceName2",
			"serviceVersion": "1.0.0",
			"child": [{
				"serviceName": "ServiceName3",
				"serviceVersion": "1.0.0"
			}]
		}]
	}]
}

One parent with two children service

{
	"choreographyName": "Choreo_OneParent_TwoChildren",
	"stepChain": [
		{
			"serviceName": "ServiceName1",
			"serviceVersion": "1.0.0",
			"child": [
				{
					"serviceName": "ServiceName2",
					"serviceVersion": "2.0.0"
				},
				{
					"serviceName": "ServiceName3",
					"serviceVersion": "3.0.0"
				}
			]
		}
	]
}

Related Links