What is a flow?

Overview

A Flow defines the interaction between Micro Services, - A workflow that controls how messages gets sent from one service to another.

You create Flows by going to the Flow page using the menu or by using the short-key CTRL+R and type “flow”. Clicking the “Create new” button on the top of the page takes you to the a page where give your flow a name and description. Clicking the “Create” button takes you to the Flow details page.

Each flow can have two itineraries, - one for Stage and one for Production. While “Flow” is the grouping object, “itineraries” are the process instruction that is going to be passed along with the message. Have a look at the "How it works" section further down this page

Design your flow

When the Flow detail page opens, the designer for the Stage itinerary automatically opens, and you can start designing your first Flow. To get started, browse through the toolbox to find the services you need, drag them out on the designer canvas and connect them using the connectors on the services.

Important: Connect the services from the source to the destination service. The message is passed in the order of how you connect the services.

Sometimes the connectors overlap each other, or other services. Although this has no effect on the execution of the flow, it makes your flow harder to read and understand. In the top right corner there is an options button for the designer, which opens a new dialog letting you show a grid and use “flexible connectors”. The “Show grid” options presents a grid on the canvas enabling the “snap to grid” option. Flexible connectors give you more control of how the connectors appears.

Variables

Variables can be used in the Flow to store information for later use.

Validating and Saving your Flow

All Micro Services have one or more properties you need to set. Some properties are mandatory, such as the Node. Clicking the “Validate” button will instantly show you any errors you may have.

When you’re done, you click the “Save” button. This action will validate and save the flow. It will also create any nodes you have not already created. For instance, if you set the Node property of a service to “MyNode”, this node will get created unless you created it before saving the Flow.

Important: Any running Nodes that were used in the Flow will get restarted when you click “Save”. This is to force the Node to pick up any new or updated Flows.

Environments

When you create your service, you automatically get a Stage Itinerary. When you’ve tested the flow and made sure everything is working, you can click the “Copy to Prod” link next to the Stage Itinerary. This is going to copy the Itinerary to a Production flow.

Important: On the Node detail page you can set the “Bind to” property. If you have a Stage Itinerary with a node called “node1”, which has a “Bind to” property set the “node2”, all services using “node1”, are replaced with “node2” when copying the Itinerary to Prod.

How it works

When the node starts up it will download all Itineraries from the Hub. It will examine each Itinerary and find all Services specified to run on this particular Node. It will then start all Services.

Messages are always created by Inbound Services, and when a message is created the Itinerary gets attached with the message and the payload. From this point forward, while this instance of the Flow is still processing, - the Itinerary is immutable. It will not get updated, although you’d change it in the portal.

To better explain this, imagine a scenario where you’d create an Itinerary with an Inbound File service receiving a file and creating a message. The message gets passed to an Outbound SQL service, which stores the message in a database.

You deploy the Itinerary and stops the node running the Outbound SQL service. -Files gets dropped in to the Inbound File service (which is running). At this point all messages targeting the Outbound SQL service gets persisted in a queue until the Outbound SQL service comes online again.

Before starting the Outbound SQL service, you change the Itinerary in the portal, adding an Outbound Email service to send out confirmation from the SQL service. You save the Itinerary, and start the Node running the Outbound SQL service.

As the second Node starts up, it will receive the all the enqueued messages, with the original Itinerary attached. -This is the Itinerary that is going to be used for any further processing, hence the Outbound Email service is not receiving any of these messages.

Related posts: