Logo

dev-resources.site

for different kinds of informations.

Hello Mule (Mulesoft)

Published at
12/21/2023
Categories
integration
apachecamel
mulesofthackathon
springintegration
Author
rofako
Author
6 person written this
rofako
open
Hello Mule (Mulesoft)

This post is the first of a series of articles about system integration in the enterprise. We will approach the topic from first principles and gradually expand into real world scenarios.

What is System Integration?

System integration is everything. Anytime 2 "things" need to communicate with eachother, they are actually "integrating" with one another. Over the years, system integration has come to mean the process of integrating heterogeneous systems. These are systems that have clear boundaries between eachother, usually built by different teams to address different concerns, but need to talk to eachother by exchanging messages. A data warehouse system (DWS) may need to be aware of all the items that were ordered during the day for analytics purposes. An oder-management system (OMS) will then have to report the relevant data to the DWS. There need to be a way to exchange messages between the 2 systems in a reliable and robust way. One tried and tested solution is the use of files as exchange mechanism. Here we have an inbox directory, in which the OMS will drop the files with the list of items sold during the day, and the DWS will read them for processing.

Image description

In the next section, we will implement a solution to this simple yet intricate process. We will start with a local file exchange and then continue with a SFTP Server.

Mule

System Integration is difficult to implement right. There are a lot of great tools available on the market to help make the task of the system integrator easy. Some of the tools will be touched in this blogs serie, but the main focus will be on Mule, and sometimes we will compare the Mule solution with Apache Camel or Spring Integration.

Hello Mule

File exchange is the "helloworld" of system integration. Let's implement files exchange with Anypoint Studio
If you have ever worked with eclipse before, you will feel right at home because anypoint studio is based on the eclipse platform.
Let's jump right into it:

Go to
File -> New -> Mule Project

Image description

In the "Mule Palette", enter "File" in the search box.

Image description
You will get the list of file connectors available. The one we are going to use, is the "On new or Updated File". This connector will monitor a directory for any new or updated file and trigger processing. Drag and drop it on the blank canvas
Image description

Select the connector to activate its configuration:

Image description

Under "Basic Settings", add a new connector configuration by clicking the + button.

Image description

Choose a working directory on your machine and click "Ok". I have created mine under C:\dev\Mulesoft\tutorial
In the "General" configuration panel, set the directory to "inbox", the Matcher to "Edit inline" and the filename pattern to "*.txt"

Image description

Mule will be watching for *.txt files in the directory C:\dev\Mulesoft\tutorial\inbox. You have to make sure that you have created the inbox directory.

Scroll down and locate the Scheduling Strategy. Make sure it is "Fixed frequency". Leave "Frequency" to 1000 and TimeUnit to MILLISECONDS. Mule will be monitory the inbox directory every 1000 milliseconds (1 second).

Image description

Scroll down to the "Post processing action" section and enter directory to move the *.txt files to. Make sure that directory exists.

Image description

We are almost ready to test our application. What is missing is a processor that will process the files as they are being read from the inbox directory. We are going to add a simple Logger which purpose is to output the content of the file that are being loaded by mule.
In the "Mule Palette", enter "logger"

Image description

Select the "Logger" processor and drag and drop into the flow after the file connector.

Image description

Right click the canvas and select Run project. Wait until the application has been deployed by looking in the Console.

Image description

Create a file test.txt and drop it into the inbox directory. The file will be moved automatically to the outboxdirectory by the mule application.
In the console window, observe how the Logger processor is logging the file read from the inbox directory.

If you have made it to this point, congratulations. In the next posts, we will look into unit testing the application with MUnit. We will also show how to read the content of the file.
Stay tuned.

mulesofthackathon Article's
30 articles in total
Favicon
Top Use Cases of MuleSoft API Manager
Favicon
Introducing Sowoe Creative Agency: Crafting Bold, Impactful Stories for Your Brand
Favicon
Download the song Kar from the past work
Favicon
How the Kellogg Innovation Network is Transforming Collaboration and Innovation
Favicon
How a Tech Company in Pakistan is Driving Innovation
Favicon
Unlocking the Power of Integration with MuleSoft
Favicon
Transform Your Body at Home: Effective Weight Loss Exercises Without a Gym
Favicon
Hello Mule (Mulesoft)
Favicon
Best practices for Mulesoft SAP integration
Favicon
Learn MuleSoft Training to become a Master in Anypoint Studio
Favicon
Mulesoft Training Interview Questions and Answers 2023
Favicon
Updating Record in Salesforce With Mulesoft
Favicon
What does MuleSoft Composer let you do?
Favicon
Why businesses should consider resorting to MuleSoft?
Favicon
Working of Mulesoft?
Favicon
Where to Learn Mulesoft?
Favicon
Mulesoft external API for custom alerts creation, automatic application restart and Jira ticket creation - Mule version 4
Favicon
Everyday is an API day with Jotto 2020
Favicon
Missing kids alerting system
Favicon
Slack Bot for Support Personnel build with API Led Connectivity
Favicon
Movid - An Alexa skill that provides Covid-19 symptom checking and real time information.
Favicon
Share your Dinosaurs
Favicon
Everyday is an API day with BlackJack
Favicon
TravelZoom- Mule Integration With Everyday API's
Favicon
IoT + MuleSoft - Sense room temperature and send message to mobile
Favicon
Cloud Hub Alexa Skill Set -Command your IAAS to work for you
Favicon
Control Your Mule Infra Via Bot
Favicon
Good Sleep: Controlling the temperature in a remote room through IOT devices and MuleSoft!
Favicon
Talk to your Toaster with Mule
Favicon
Subscription Model for News and Stocks via MuleSoft and Kafka

Featured ones: