Professional Documents
Culture Documents
Objectives
In this exercise, you create a batch processing system. You will:
• Control batch step processing using batch filters.
• Exchange data between batch steps using variables.
• Trigger batch processing on a schedule.
• Use watermarks to avoid duplicate processing.
• Improve performance by using batch aggregators.
• Improve performance and share data with other Mule applications using VM queues.
Scenario
The Finance department needs to audit certain transactions and needs a Mule application to
consistently retrieve data from a database and write these transactions as CSV files to a server.
To meet compliance standards, a CSV file can have no more than 50 records and the Mule
application must be deployed to a private server where the Mule application will share the same
Mule domain with other financial compliance Mule applications. You do not, however, need to
create a new Mule domain project yourself; another developer will be responsible for deploying
your project into an existing Mule domain.
Create a project that retrieves new transactions from the database using
batch
Create a new Mule application that retrieves data from the flights_transactions table in the
database using the following information:
• Host: mudb.learn.mulesoft.com
• Port: 3306
• User: mule
• Password: mule
• Database: training
• Table: flights_transactions
Schedule the main flow to automatically run every 5 seconds. Retrieve new database records
based on the value of the primary key field transactionID. Use an ObjectStore to save the
maximum transactionID processed for any batch session.
Hint: For test development, limit the query to only retrieve 10 records at a time.
Add a flow to mock the financial compliance application logic
Add a new flow to the Mule application with a VM Listener on the VM queue named validate.
Add a Transform Message component to this flow and add DataWeave code to simulate the
transactionID validation logic. It expects one record and returns the value true or false, where
true indicates that the record needs to be audited. In this simple mock flow, return a Boolean
value true if the transactionID is divisible by 4, and false otherwise:
%dw 2.0
output application/java
---
if ( mod(payload.transactionID as Number,4) == 0 )
true
else
false