To Manage Data Types (Design Center)

The type of your data refers to its metadata, this is the representation of the structure of data, regardless of its format.

For example, the metadata of a message may define that the 'user' element has two child elements: 'name' and 'address'; it doesn’t matter if the message is in JSON or XML format. The metadata does not adhere to any particular format.

When the metadata information is available to another component, it is interpreted as the expected input or output, depending on where each are placed relative to each other in a flow.

Almost all components include an Input and Output tab. These tabs let you describe the types of data that enter and leave the component. The data includes specifics about the Mule Event: the payload, its properties and variables. If the component has processed any real data, it will be shown here.

Many elements you use in your projects expose their metadata automatically. There’s no need to provide this information manually. For example, when a connector is configured to carry out a specific operation, the output structure is already registered in flow designer.

Assign Existing Data Types

  1. Open a card and select the Input or Output tab on the top margin:

    to manage data types 026a6

  2. On the dropdown menu next to Show, pick the part of the Mule event you want to view: Payload, Attributes or any existing Variables.

  3. On the dropdown menu next to Data Types, select a data type that you want to assign to this part of the Mule event out of the types you’ve already designed. You can also define a new type.

Manually Define a Data Type

  1. Open a card and select its Input or Output tab

  2. On the dropdown menu next to Show, pick the part of the Mule event you want to view: Payload, Attributes or any existing Variables.

  3. Click the Add button next to the Data Type dropdown.

  4. Give your data type a unique name within the project.

  5. Select the Format of your type from the dropdown.

  6. Define your custom type by either providing an example or a schema, select one of these two options.

    Some formats only allow you to provide a schema. To provide a Schema for a CSV or Java format, you must provide the schema as a RAML file.
  7. Paste a sample or schema in the input box

  8. The preview section on the right displays the resulting structure tree.

    handling metadata in flow designer 8e17e

  9. Click Save. The data type can be referenced anywhere in your project.

Define a Data Type From Live Data

As a shortcut, instead of manually defining a data type, you can automatically create it from live data that passes through your flow when triggered.

  1. Create a basic flow that’s capable of receiving or producing the data you need. For example, if the data arrives in a HTTP Request, a HTTP Listener is enough; if the data is in a database, you could use a Scheduler component as a trigger and then a database connector.

  2. Configure all the required fields in these components.

  3. Click Deploy in the top nav bar to run your project in a design environment.

  4. If your flow starts with an HTTP connector, hit its URL to trigger it; if it starts with a Scheduler, wait for it to be triggered.

  5. Open a component that’s processing the data you’re interested in, then open its Output tab. You should now see the data of all the events it has handled.

  6. Select the part of the Mule event you’re interested in (payload, attributes or a variable).

  7. Click Add. The Custom Data Type editor opens, populated with the data you were seeing as an example.

Other Ways to Access the Custom Data Type Editor

You can reach the custom data type editor in the following ways:

  • Open the Input or Output tabs of a component, select the part of the Mule Event you want to work on and click Add.

  • Open a Transform Card, and click Set Data Type on the element you want to define.

  • On the left sidebar, click the plus sign at the very top and then select New Type

    to manage data types f40c8

Set Data Types for the Transform Card

To use the drag and drop UI of the Transform Card, your flow must have metadata for both the Input and the Output of this component.

There are several ways you can provide this required metadata:

  • Make sure that other elements in the flow are fully configured. For example, a connector can’t expose its output structure until a given operation is chosen, as its output might differ depending on the operation.

  • You can manually assign a data type to the previous component in the flow via its Input and Output tabs. This data is propagated forward and transformed as it transitions through other components.

  • You can manually define the input and output of the Transform component. For this you can either:

    • Click the Set Data Type icon to manage data types 69ae0 below either the input pane or the output pane.

    • Expand the element you want to define and click its Set data type link in the input pane.

    • Open the dropdown menu next to the Output label, and select Set Data Type in the output pane.

Note that for the input pane, you can Set Data Types for the main payload, attributes, and variables of the Mule event. For the output, you can only set the main payload in the default view. If you want to output to a different part of the Mule event:

  • Click the dropdown menu next to the Output label

  • Select Add Transformation.

  • Pick attribute or variable to output to.

to manage data types 25472

See also