DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Implementing API Design First in .NET for Efficient Development, Testing, and CI/CD
  • Build a Simple REST API Using Python Flask and SQLite (With Tests)
  • How to Create a Successful API Ecosystem
  • MCP Servers: The Technical Debt That Is Coming

Trending

  • The Smart Way to Talk to Your Database: Why Hybrid API + NL2SQL Wins
  • Enforcing Architecture With ArchUnit in Java
  • How To Build Resilient Microservices Using Circuit Breakers and Retries: A Developer’s Guide To Surviving
  • The Future of Java and AI: Coding in 2025
  1. DZone
  2. Data Engineering
  3. Databases
  4. Mule API: Experience, Process, System

Mule API: Experience, Process, System

This article explains how to define and understand the basic API layers in Mule.

By 
Ankur Bhuyan user avatar
Ankur Bhuyan
·
Updated Feb. 13, 19 · Tutorial
Likes (10)
Comment
Save
Tweet
Share
58.4K Views

Join the DZone community and get the full member experience.

Join For Free

This article explains how to define and understand the basic API layers in Mule. I have prepared this demo to explain the layer differences and their implementations. This example is mainly for beginners.

The purpose of this tutorial is to process a valid CSV file and store it into a database. The Experience API lets you expose the API to the end user. The Process API lets you validate the file extension as .csv or not. A system API will carry out the system level processes, such as validating the file contents and processing them to the database.

API Projects Definitions

Image title

Experience API

The Experience API is defined to expose the end user to the API. So, we should define and implement the high-level logic in the API. The purpose of this API is to interact with the Process API and process the output to the end user with the process status.

Step 1: Define the global definitions for the http connectors in the "csv-export-domain" project. 

csv-export-domain.xml

Step 2: Define the RAML definition for the Experience API.

Image title

Image title

Step 3: To generate the flow, right-click on the api.raml file and choose "Mule -> Generate Flows from REST API."

Step 4: Once the api.xml generates the call, see the Process API flow.

Image title

Step 5: Define "initiate-process-api-call" flow for the Process API call. Here is the xml view of the flow.

Image title

Process API

In the Process API, we are doing file extension validation. Except for the .csv file, this API will not process any files. Once the validation is successful, extract the contents of the CSV file and send them to the System API for further processing.

Step 6: Define the RAML definition for the Process API.

Image title

Image title

Step 7: Repeat step 3 and call the System API call.

Image title

Step 8: Define the "initiate-system-api-call" flow for the Process API call. Here is the xml view of the flow. 

Image title

Image title

System API

The System API is for low-level processes. Once we get the JSON input from the Process API, we will validate the content one by one with the Mule validator. If any validation fails, the API will get the actual reason for the validation and reject the flow and pass the reason to the Experience API through the Process API. If the validation of all the content succeeds, process the data for the database to insert/update the record.

Step 9: Define the RAML definition for the System API.

Image title

Step 7: Repeat step 3 and call the "process-file" flow of the System API for content validation and store it into the database (the database part is not complete here).

Image title

Image title

CustomValidationException.java: This custom exception class lets you catch the exception thrown by the validator flow.

Image title

Sample CSV File

Valid content:

Image title

Invalid Content:

Image title

Let me know your thoughts in the comments.

API

Opinions expressed by DZone contributors are their own.

Related

  • Implementing API Design First in .NET for Efficient Development, Testing, and CI/CD
  • Build a Simple REST API Using Python Flask and SQLite (With Tests)
  • How to Create a Successful API Ecosystem
  • MCP Servers: The Technical Debt That Is Coming

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!