Contact Us 1-800-596-4880

Propagate Metadata to Other Flows

Studio enables you to propagate metadata in your source flow to other, target flows referenced within your application. Depending on metadata already in the target flow, you might need to configure the specific metadata to propagate from the source flow.

Propagate Metadata to a Flow Without Custom Metadata

When you add a Flow Reference component to your source flow and reference a target flow with no custom metadata configured, Studio automatically propagates the metadata in your source flow as custom metadata in your target flow.

  1. In the taskbar at the top of the Anypoint Studio display, select File > New > Mule Project.

  2. Type a name for your new project and select Finish.

  3. Drag two flow components to your empty canvas and name them flow-1 and flow-2:

    Two diagrams illustrating different flows, each with a source, process, and error handling step
  4. Drag a Set Payload component to flow-1 and configure the payload:

    {
      "value": {
        "ID": 1,
        "departureDate": "2016/12/20",
        "emptySeats": 200,
        "plane": {
          "type": "Boeing 747",
          "totalSeats": 400
        }
      }
    }
    A configuration window with a code block displaying JSON data
  5. Drag a Logger component to flow-2 and configure it to log payload:

    A Logger configuration with a payload message
  6. Drag a Flow Reference component to the end of flow-1 and configure it to reference `flow-2`:

    A dialog box displays an error message and a text field for entering a flow name
  7. Note that the metadata tab in flow-2 is now populated with autogenerated metadata, and the input tab in the metadata explorer reflects the payload format that the Set Payload component determines in flow-1:

    A screenshot displaying a message flow with metadata and an object featuring ID, departure date, empty seats, and plane fields

Propagate Metadata When Extracting an Operation From Your Flow to a New Flow

When you extract an operation from your source flow to propagate to a new target flow or subflow, Studio enables you to configure the metadata that you want to propagate to the newly created flow:

  1. In the taskbar at the top of the Anypoint Studio display, select File > New > Mule Project.

  2. Type a name for your new project and select Finish.

  3. Drag a flow component to your empty canvas and name it flow-1.

  4. Drag a Set Payload component to flow-1 and configure the payload:

    {
      "value": {
        "ID": 1,
        "departureDate": "2016/12/20",
        "emptySeats": 200,
        "plane": {
          "type": "Boeing 747",
          "totalSeats": 400
        }
      }
    }
    A form with fields for MIME type, metadata, notes, and help, including a text box labeled Value with code inside
  5. Drag a Logger component to the end of flow-1 and configure it to log #[payload.value.departureDate]:

    A message with a payload value and departure date
  6. Right-click your Logger component and select Extract To…​ > Flow:

    A menu with options for a flow, including extracting the flow to a sub-flow
  7. Name your target flow flow-2.

  8. Select Metadata Preferences to configure the input and output metadata.
    Note that Studio automatically recognizes the metadata of your flow.

    A window displays the input and output metadata for a message flow, which includes an object with attributes for ID, departure date, empty seats, and plane
  9. Select OK.

  10. Your Logger component is now in flow-2, the metadata tab is populated with autogenerated metadata, and the input tab in the metadata explorer reflects the payload format that the Set Payload component configures in flow-1:

    A message flow with a metadata section and an input-output view that displays a message payload with object and value attributes

Propagate Metadata to a Flow with Custom Metadata Already Configured

When you add a Flow Reference component to your source flow and reference another, target flow that has custom metadata already configured, Studio prompts you to select the metadata that you want to propagate:

  1. In the taskbar at the top of the Anypoint Studio display, select File > New > Mule Project.

  2. Type a name for your new project and select Finish.

  3. Drag two flow components to your empty canvas and name them flow-1 and flow-2:

    Two diagrams illustrating different flows, each with a source, process, and error handling step
  4. Drag a Set Payload component to flow-1 and configure the payload:

    {
      "value": {
        "ID": 1,
        "departureDate": "2016/12/20",
        "emptySeats": 200,
        "plane": {
          "type": "Boeing 747",
          "totalSeats": 400
        }
      }
    }
    A configuration window with a code block displaying JSON data
  5. Create a JSON file with the name `arrival-type-example.json` in your src/main/resources/examples directory with the following format:

    arrival-type-example.json
    {
      "value": {
        "ID": 1,
        "arrivalDate": "2016/12/20",
        "plane": {
          "type": "Boeing 747",
          "totalSeats": 400
        }
      }
    }
  6. Select flow-2 > Metadata tab > Add Metadata:

    A screenshot displays a message flow with a button to add metadata
  7. Select Input: Payload > Edit:

    An arrow points to an icon for editing metadata
  8. Select Add, create a new metadata type called `arrivalType`, and select Create type:

    A window containing a form for the creation of a new metadata type, including a type ID field and a 'Create Type' button
  9. Select the type JSON > Example and select the …​ button to browse to src/main/resources/examples/arrival-type-example.json:

    A window with options to select a metadata type, including JSON and a text field for an example
  10. Click Select.

  11. Drag a Logger component to flow-2 and configure it to log payload:

    A Logger configuration with a payload message
  12. Drag a Flow Reference component to the end of flow-1 and configure it to reference `flow-2`:

    A dialog box displays an error message and a text field for entering a flow name
  13. Select the Flow Reference component Metadata tab, and select Set Metadata:

    A screenshot of a flow reference panel with the option to add metadata

    Studio warns you that setting the metadata from flow-1 will overwrite the existing arrivalType metadata type configured for flow-2:

    A dialog box labeled Custom metadata inquires if you wish to replace the existing flow-2 metadata
  14. Select Customize to configure the desired metadata to propagate to the flow.

    Note that Studio recognizes the actual metadata as that set in flow-1, and the expected metadata as that configured in flow-2.

    A window that displays input and output metadata, with checkboxes for expected object values

    Customizing the actual and expected metadata for a referenced flow is helpful if you want to define a specific set of metadata to propagate.