In simple words Integration is all about connecting two or more systems/applications to work together. This need started from the day when organizations start using applications to run their day to day business. With time Integration has developed and moved from initial Point-to-Point integration to Enterprise Service Bus (ESB).
MuleSoft Integration Patterns mainly talk about following two mechanisms.
1. How easily we can take care of integration maintenance, enhancement and performance when we choose a right integration pattern to build a robust integration.
2. Focus more on Strong Cohesiveness and Loose Coupling – this help where we don’t want to end up writing monolithic applications.
Below are the different design patterns we have in MuleSoft space.
1. Migration Integration Pattern
2. Broadcast Integration Pattern
3. Bi-Directional Sync Integration Pattern
4. Correlation Integration Pattern
5. Aggregation Integration Pattern
6. Reliability Integration Pattern
7. JMS Messaging Integration Pattern
We can define migration in following steps
Migration Pattern Example
Source to hold
Enrichment and Transformation – Batch Step – Accept Policy (ALL)
Error Handling – Batch Step – Accept Policy (ONLY_FAILURES)
Reporting – On Complete
<?xml version="1.0" encoding="UTF-8"?> <mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:batch="http://www.mulesoft.org/schema/mule/batch" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/batch http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd"> <file:config name="File_Config1" doc:name="File Config" doc:id="c954c938-773d-4317-8a32-c24c04ddd037" > <file:connection workingDir="D:\" /> </file:config> <flow name="batch-job-processing-sample-schedular-flow" doc:id="f7693791-2b1a-44e6-946c-db03b2f6579e" > <scheduler doc:name="Scheduler" doc:id="a385b53e-907e-4124-8672-effa2c476611" > <scheduling-strategy > <fixed-frequency /> </scheduling-strategy> </scheduler> <logger level="INFO" doc:name="If event Source System API call" doc:id="41906c24-561d-415d-8547-d149a4e6f1b1" /> <flow-ref doc:name="batch-job--processing-sample-flow" doc:id="ea2720d8-f067-4c39-958a-b7407d875e43" name="batch-job-processing-sample-flow"/> </flow> <flow name="batch-job-processing-sample-polling-flow" doc:id="e3d0d63f-c5eb-4555-93e0-728e062b59d1" > <file:listener doc:name="On New or Updated File" doc:id="05d17c0b-f21c-4b8e-818b-72bd96de6870" config-ref="File_Config1"> <scheduling-strategy > <fixed-frequency /> </scheduling-strategy> </file:listener> <flow-ref doc:name="batch-job-processing-sample-flow" doc:id="7ab3cf18-2cae-40ad-ab20-ac3651cb1ae2" name="batch-job-processing-sample-flow" /> </flow> <flow name="batch-job-processing-sample-flow" doc:id="cb383444-7c1a-48d3-a4be-077893e07c14" > <batch:job jobName="batch-job-processing-sampleBatch_Job" doc:id="e33f8a3e-2c7d-44ad-ac26-43bd18714878" > <batch:process-records > <batch:step name="Enrichment_Batch_Step" doc:id="a23e07c9-c17c-4404-a32d-4792af442bf6" > <logger level="INFO" doc:name="Enrichment Logic" doc:id="90ef724c-893d-4c56-8e75-ac3cb8522ec8" /> </batch:step> <batch:step name="Transformation_Target_System_Batch_Step" doc:id="62e174d0-d518-4619-aea9-4630e49cc7dd" > <logger level="INFO" doc:name="Transformation Logic" doc:id="f9363864-c376-4c11-b5ce-d70a0aa28721" /> <logger level="INFO" doc:name="Target System API call" doc:id="07711bea-b7ac-4d8b-98bd-c69fd2aefeb4" /> </batch:step> <batch:step name="Error_Handling" doc:id="1ae5bcb6-970d-41a3-a30e-4d8c2a6fd647" > <logger level="INFO" doc:name="For Every Failed Record" doc:id="e50f3c17-d97b-4355-8cc3-a2401a50889f" /> <batch:aggregator doc:name="Batch Aggregator" doc:id="ea6bbb15-65fb-4cc4-ad37-2dfe1fd290ed" streaming="true"> <logger level="INFO" doc:name="For All Failed Record" doc:id="017e5405-5eb9-4a21-999d-d27b877b01be" /> </batch:aggregator> </batch:step> </batch:process-records> <batch:on-complete > <logger level="INFO" doc:name="Send Migration Report" doc:id="7547871f-5ad8-48c7-9cb8-1839c63cbed4" /> </batch:on-complete> </batch:job> </flow> </mule>
MULE_HOME is set to D:\Software\AnypointStudio\plugins\org.mule.tooling.server.4.2.2.ee_7.3.5.202001031809\mule MULE_BASE is set to D:\Software\AnypointStudio\plugins\org.mule.tooling.server.4.2.2.ee_7.3.5.202001031809\mule --> Wrapper Started as Console Copyright (C) 1999-2018 Tanuki Software, Ltd. All Rights Reserved. http://wrapper.tanukisoftware.com Licensed to MuleSoft Inc. for Mule Runtime Enterprise Edition Launching a JVM... Starting the Mule Container... WrapperManager: Initializing... Running Mule in testing mode INFO 2021-09-10 20:48:42,025 [WrapperListener_start_runner] org.mule.runtime.core.internal.logging.LogUtil: ********************************************************************** * * * ((((((((((((((((((( * * ((((( ((((# * * &((( *((( * * &((( ((( * * ((( (((% (((# ((( * * (( ((((((( ((((((( ((( * * (( ((((((((( ((((((((( (( * * (( #((((((((((( #((((((((((( ((( * * #(( (((((((((((((( (((((((((((((( (( * * (( (((((( /((((((( ((((((( /(((((( (( * * (( (((((( (((((((&((((((( (((((( (( * * (( ((((( ((((((((((((* (((((( (( * * (( (((((( *((((((((( (((((( (( * * (( (((((( ((((((( (((((( ((( * * (( (((((( (((((( (( * * ((# ((((((# ((((((( (( * * ((# (((((((( (((((((( ((( * * ((( ((((((( ((((( ((. * * (( ((( ((( #(( * * /(( ((( * * ((( &((( * * *((((& &(((( * * ((((((((((((((/ * * * * ___ ___ _ ______ _ _ * * | \/ | | | | ___ \ | | (_) * * | . . |_ _| | ___ | |_/ / _ _ __ | |_ _ _ __ ___ ___ * * | |\/| | | | | |/ _ \ | / | | | '_ \| __| | '_ ` _ \ / _ \ * * | | | | |_| | | __/ | |\ \ |_| | | | | |_| | | | | | | __/ * * \_| |_/\__,_|_|\___| \_| \_\__,_|_| |_|\__|_|_| |_| |_|\___| * * * * * * Mule Runtime and Integration Platform * * Version: 4.2.2 Build: e790fb3a * * MuleSoft, Inc. * * For more information go to * * https://www.mulesoft.com/platform/soa/mule-esb-enterprise * * * * Server started: 9/10/21 8:48 PM * * JDK: 1.8.0_41 (mixed mode) * * JDK properties: * * - java.vendor = Oracle Corporation * * - java.vm.name = OpenJDK Client VM * * - java.home = D:\Software\java-se-8u41\jre * * OS: Windows 8.1 - (6.3, x86) * INFO 2021-09-10 20:48:54,549 [WrapperListener_start_runner] org.mule.runtime.core.internal.logging.LogUtil: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Mule is up and kicking (every 5000ms) + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ INFO 2021-09-10 20:48:54,597 [WrapperListener_start_runner] org.eclipse.jetty.server.AbstractConnector: Started ServerConnector@1e2e45b{HTTP/1.1,[http/1.1]}{0.0.0.0:64281} INFO 2021-09-10 20:48:54,600 [WrapperListener_start_runner] org.mule.runtime.core.internal.logging.LogUtil: ********************************************************************** * - - + DOMAIN + - - * - - + STATUS + - - * ********************************************************************** * default * DEPLOYED * **********************************************************************
Target systems don’t have to send any response back to the Source system (Customer Web Portal).
We can define Broadcast pattern in following steps
Note: Every case has its pros and cons, let’s see
Case 1 – Source system send notification along with data
Case 2 – Source system send only notification and MuleSoft will pull the actual data from the source system
Case 3 – Scheduler will invoke the MuleSoft integration after certain time interval and MuleSoft will pull the actual change data from source system
It aggregates the data from different systems and merge them before processing the response.
Here, response can be inserted e.g. Reporting or as Response e.g. HTTP response in Database from different Source Systems to a Target system.
To make this reliable we can introduce a connector (which support transaction) to divide the transactional and non-transactional activities as below.
<?xml version="1.0" encoding="UTF-8"?> <mule xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd"> <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="7d4397c7-ad40-41d2-bb54-6ec0d3466baa"> <http:listener-connection host="0.0.0.0" port="8081" /> </http:listener-config> <vm:config name="VM_Config" doc:name="VM Config" doc:id="5db475fe-978a-4b58-9325-9e2bb2c424fb"> <vm:connection /> <vm:queues> <vm:queue queueName="reliableVM" /> </vm:queues> </vm:config> <flow name="reliability-pattern-services-non-transactional-flow" doc:id="1220980b-c57e-4fa7-8f6c-10ace31885d0"> <http:listener doc:name="Listener" doc:id="9e9d2e91-1f07-45a0-ac68-2abecff0ff98" config-ref="HTTP_Listener_config" path="reliable" /> <vm:publish doc:name="Publish" doc:id="10cecc00-4bc2-4351-942f-c16d4bd87a98" config-ref="VM_Config" queueName="reliableVM" /> </flow> <flow name="reliability-pattern-services-transactional-flow" doc:id="b8a07c5a-caa6-4c13-83ff-bd1dd670e4b0"> <vm:listener doc:name="Listener" doc:id="f3fdfde1-f1c5-43b9-aeef-da9fed8cb854" config-ref="VM_Config" queueName="reliableVM" /> <logger level="INFO" doc:name="DB Insert - 1" doc:id="9e325dc1-581d-48c0-9906-615010953373" /> <logger level="INFO" doc:name="DB Insert - 2" doc:id="675fe923-8ba6-4f41-86ef-aa154bd87ba7" /> </flow> </mule>
INFO 2021-09-10 22:11:01,521 [WrapperListener_start_runner] org.mule.runtime.core.internal.logging.LogUtil: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Mule is up and kicking (every 5000ms) + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ INFO 2021-09-10 22:11:01,559 [WrapperListener_start_runner] org.eclipse.jetty.server.AbstractConnector: Started ServerConnector@11e88b1{HTTP/1.1,[http/1.1]}{0.0.0.0:61097} INFO 2021-09-10 22:11:01,561 [WrapperListener_start_runner] org.mule.runtime.core.internal.logging.LogUtil: ********************************************************************** * - - + DOMAIN + - - * - - + STATUS + - - * ********************************************************************** * default * DEPLOYED * **********************************************************************
Here, we can have one or multiple senders and only one receiver.
Key points to remember
It uses JMS Topic for communication between Senders and Receivers. Here, we can have multiple publishers and subscribers. Copy of message is send to all the subscribers.
Key points to remember
Keep Learning. Have, a great day :). In case of any query please do post.