Adding Resources

To make your integration flow more organized and flexible, you can use resources files and flow variables.

For some Apache Camel components, such as "JSONata", it is necessary to use scripts stored in separate files. These files can be created in Resources, regardless of the file extension. This way, you can reference them directly within the main flow, ensuring they are used during the execution of the integration flow.

All the files added to the Resources folder are automatically added to the integration’s classpath and should be referenced using classpath locators, according to each component documentation.

In the example below, we reference the resource file extractTotal.jsonata in the Resource Uri field of the JSONata component:

- to:
  uri: jsonata:classpath:extractTotal.jsonata
  parameters:
    inputType: JsonString

Creating a resource file

Resource files can be created in both the Diagram and Source Code tabs.

In the Diagram tab:

resources diagram

  1. Click on the resources icon icon resources in the left corner of the canvas.

  2. Click on the + button.

  3. Click the file and specify the file name and extension: for example, jsonata.yaml, test.txt, etc.

  4. Add the content of the file in the text editor.

  5. Save the resource file, by clicking SAVE.

In the Source Code tab, in the folder structure Source > Resources:

resources source code

  1. Click on the + button, to the right of the Resources folder.

  2. Specify the file name and extension: for example, jsonata.yaml, test.txt, etc.

A yellow dot icon on the right side of the file name indicates that the file has not been saved.
Whereas a red dot icon indicates that there are errors in the file.

File name requirements

The file name must meet the following criteria:

  • Maximum size: 100 characters.

  • Allowed characters: alphanumeric,-,_, and ..

  • Uniqueness: each file name must be unique, but you can have, for example, test.yaml and test.json.

Extension Types

  • If the file extension is .yaml, .json or .xml, it will be formatted with colors and layout. If the structure is incorrect, a notification will be displayed.

  • If the file extension is different from those mentioned, the file will not be validated. However, you can create your script normally.

Limits

  • There is no limit to the number of files the folder can contain.

  • A file can have a maximum size of 1 MB.

Thanks for your feedback!
EDIT

Share your suggestions with us!
Click here and then [+ Submit idea]