This is the second of a three part series on the Salesforce Developers codeLive channel where we walk through a lift and shift of functionality from Salesfore Apex to MuleSoft Anypoint Platform.
- Part #1 - Designing the API Specification
- Part #3 - Refactoring Apex & Building Flows
In this part we build the implementation of the specification we developed in the first part. We use Anypoint Studio to build the flows that connect to the SOAP and REST services and postgres database for American Airlines. We build the individual flow for each airline (getFlights, getFlightsByDestination and getFligtByCode) and then build flows for /flights
and /flights/{code}
that combines returns results from all three services in a single call.
Agenda
- Develop the implementation with Anypoint Studio
- Create a new MuleSoft application
- Connect to the three airline datasources using SOAP, REST and Database connectors
- Deploy the application to Anypoint Platform
See this repo for all of the code and assets used in the applications.
Anypoint Studio Implementation
The flights
flow uses a Choice processor (essentially an if/then) to determine whether to return all flights or flights by destination based upon the presence of the destination varaiable. For each route we use a Scatter-Gather processor which sends a request message to multiple subflows concurrently. It collects the responses from all routes, and aggregates them into a single message.
The flightsByCode
flow also uses a Scatter-Gather processor to send the request message to multiple subflows concurrently. It collects the responses from all routes, and aggregates them into a single message.
Individual flows for Delta (SOAP)
Individual flows for United (REST)
Individual flows for American (Postgres)