The use case we will be walking through here is very straightforward and simplified for the sake of the demo and yet practical enough to be used as a starting point for production-grade integrations.
- When a new order is activated in Salesforce, it must be delivered to IBM i ERP in near real-time
- When the ERP order status is changed, the status must be propagated back to Salesforce in near real-time
Below is the high-level process diagram
The article title implies a direct connection between IBMi and Salesforce, which is correct at the high level but represents a typical integration anti-pattern of tightly coupling systems together via point-to-point integration. Instead, we follow a simplified API led connectivity approach here, decoupling the Salesforce and AS400 facing components and achieving a reasonable degree of reuse, while directly connecting one System API to another. To further evolve the design for more heterogeneous environments, it would be worth introducing the mediation/process layer between Salesforce and AS400 System APIs, that could implement more generic services such as routing, mapping, and orchestration.
Salesforce API Implementation
Salesforce acquired Mulesoft back in 2018, and as you’d expect most Salesforce integrations can be easily performed with the help of the feature-rich SFDC connector.
SFDC Order Poller
For the sake of simplicity, we choose to poll Salesforce for new activated orders. Alternatively, we could have implemented the near real-time streaming of order status events using platform events or push topics, both of which are supported out of the box with Mulesoft SFDC connector streaming source operations.
SFDC Order Status Update
This demo includes a simplified flow that retrieves SFDC order ID using ERP ID as a key and updates the status of that order in Salesforce.
AS400 API Implementation
IBMi (AS400) is a modern, secure, stable and highly sophisticated platform that offers one of the lowest total costs of ownership for running diverse workloads. There are various integration options provided out of the box and available from third-party vendors. For current or prospective Mulesoft customers, the easiest option is to leverage the AS400 connector. It does not require any additional components to manage on AS400 or other platforms, and development teams can execute AS400 business logic and work with Data Queue messages directly from Mulesoft environments, with little to no AS400 special knowledge required.
Create AS400 Order
We used AS400 Gateway for Mulesoft’s Program Call operation to directly execute the ERP program CRTORDERS from Mulesoft flow.
Program call must be defined with the correct parameters that match exactly the order, data type and size definitions of the back-end program or service program. Other than that, the Mulesoft developer does not have to have any knowledge of AS400 program internals or underlying database structures.
AS400 Order Status Listener
We used AS400 Data Queues for communicating the ERP change events. When an order is changed, the ERP creates a new data queue entry that contains the order ID, new status and other relevant information. The Mulesoft listener process retrieves the data queue entry in near real-time and calls SFDC System API to update the order status. Once the call completes successfully, the Mulesoft process will send the order status acknowledgement message to the response data queue, to notify ERP that the event has been processed.
Salesforce and IBMi (AS400) are both powerful, mature and feature-rich platforms that offer a variety of connectivity options. The modern integration platforms such as Mulesoft Anypoint help decouple the systems, maximize the reuse, and reduce the niche skill requirements for connecting IBM i (AS/400) to Salesforce. The integration developers don’t need to have special training or experience integrating with AS400 servers, and with the help of AS400 Gateway can execute the back-end ERP business logic directly from the integration platform.
The source code for this demo application can be accessed here: https://bitbucket.org/infoviewsystems/as400-salesforce-demo