From the technical center of excellence of Massil Technologies, our technology leaders make it easy to understand the complex situations you come across in Mule ESB from the experience of Massil Technologies to have countered them in their experience of working on client projects in real time. This blog talks about all you need to know about DataWeave Flat File Schemas in Mule ESB. This blog is a part of series of blogs being authored and published by Massil Technologies for the benefit of the IT community globally.
According to Mulesoft website, DataWeave allows you to process several different types of data. For most of these types, you can import a schema that describes the input structure to have access to valuable metadata at design time. See To Define Input and Output Structure of a Transformation. DataWeave uses a YAML format called FFD (for Flat File Definition) to represent flat file schemas. The FFD format is very flexible to support a range of use cases but is based on the concepts of elements, composites, segments, groups, and structures.
Schemas must be written in Flat File Schema Language, with a .ffs extension. This language is very similar to EDI Schema Language (ESL), which is also accepted by Anypoint Studio. n DataWeave, you can bind your input or your output to a flat file schema through a property. See below for instructions on how to do this through the Studio UI.
Here’s a quick step by step example of how – once you have built out your full schema – you can easily apply it to the input metadata of a Transform Message component. This example uses a flat file schema that describes a Cobol Copybook format.
Download the sample schema file here.
In Anypoint Studio click File > New > Mule Project to create a new project, give it whatever name you wish and click Finish.
Drag an HTTP Connector from the palette to your empty canvas, then a Transform Message Component.
Click on the HTTP Connector to open its properties editor, then click the green arrow icon to create a new configuration for it. Leave all of the fields by default and click OK.
Select the Metadata tab and click the Set Metadata button.
Click the Edit icon that appears next to the Payload element
Click the green plus icon to add a new metadata type and name it ‘my-flat-file-type’
Select Flat File as the type, on the Schema field point it to the location of your schema file. Then click Select to use this Metadata type.
Note that if you open the Transform Message component, the input section should show the fields that will be present in the incoming payload.
in logger write #[message.payload]
Run your Mule project.
For more information visit https://docs.mulesoft.com/mule-user-guide/v/3.8/dataweave-flat-file-schemas
Send csv using postman to the project
The output will be grouped accordingly.
Hence, we have gone through the step by step process to depict the way Massil Technologies team has addressed. Hope this article from Massil Technologies was useful for you. If you have any further queries on this topic, please reach out to email@example.com.