? Salesforce Integration with External Systems using MuleSoft

Shen Yifeng

salesforce enthusiast,sfdc developer, consultant

MuleSoft Onhands Experience

1. The Scenario

MuleSoft is an excellent exterprise ESB product, and is increasingly being adopted by more and more customers. So let's give a sample to explain its powerness integrating with salesforce. Sometimes, we need fetch additional information when creating records in salesforce. For example when adding opportunity product on opportunity, in some cases there is a requirement to first check the inventory status of the product in SAP. In the meantime, also the unit price should be recalculated in some areas for adding extra fees. Here we assume SAP is the MDM of inventory and another external system as the SOR of the product price since some prices are being constantly changing.

Considering the above scenario, what need to do is pulling out both the inventory data and price data from two different external systems and bring a re-generated response info back to salesforce. Since there are thousands of products(opportunity line items) might being creating on opportunities at the same time, communicating ESB using platform event would be a better method than Restful API.

So, how should the proper design looks like? Here is a diagram that shows the whole story using MuleSoft Anypoint Studio.

Note the above steps No.3 and No.4, they should be running simultaneously and their results should be gattered together and re-produced in the ESB and then sending back the formatted result in one payload to salesforce. I implemented it using MuleSoft anypoint studio and the whole Mule flow processws well under control.

2. The implementation

So, here the Mule Scatter-Gather component is an essential part in order to running the asynchronous processing. And also, I use the JMS message queue in the flow to publish and comsume the Mule internal events(We can use VM connector instead here).

This application includes exceptional handling like writing products info to a file in it not exist in the MDM or SOR.

3 Test Result

Normal Pattern

Abnormal Pattern

Here, when creating the response message back to salesforce, we can update the specific fields like this:

The following are key points in implementing this experiment:

  • Salesforce Platform Event
  • Mule processors management
  • Mule Anypoint interacting with other systems
  • JMS Queue, VM Connector,etc

References:

MuleSoft : Speed up IT project delivery with a comprehensive toolset for integration, APIs, and automation.

This post is crafted by myself.