Book Image

MuleSoft for Salesforce Developers

By : Arul Christhuraj Alphonse, Alexandra Martinez, Akshata Sawant
Book Image

MuleSoft for Salesforce Developers

By: Arul Christhuraj Alphonse, Alexandra Martinez, Akshata Sawant

Overview of this book

MuleSoft for Salesforce Developers will help you build state-of-the-art enterprise solutions with flexible and scalable integration capabilities using MuleSoft’s Anypoint Platform and Anypoint Studio. If you’re a Salesforce developer looking to get started with this useful tool, look no further. This book will get you up to speed in no time, leveling up your integration developer skills. This essential guide will first introduce you to the fundamentals of MuleSoft and API-led connectivity, before walking you through the API life cycle and the Anypoint Studio IDE. Once you have the IDE set up, you’ll be ready to create Mule applications. You’ll look at the core components of MuleSoft and Anypoint Platform, and before long you’ll know how to build, transform, secure, test, and deploy applications using the wide range of components available to you. Finally, you’ll learn about using connectors to integrate MuleSoft with Salesforce and to fulfill a number of use cases, which will be covered in depth, along with interview and certification tips. By the end of this book, you will be confident building MuleSoft integrations at an enterprise scale and be able to gain the fundamental MuleSoft certification – MCD.
Table of Contents (21 chapters)
1
Part 1:Getting Started with MuleSoft
7
Part 2: A Deep Dive into MuleSoft
14
Part 3: Integration with Salesforce and Other Connectors

Introducing MuleSoft

Everything comes together. After understanding all of the previous concepts – no-/low-code technologies, integrations, and APIs – we can start talking about MuleSoft. In this section, we’ll describe what MuleSoft is, what some of its products are, how it’s useful, and how it is going to help you in your career as a Salesforce developer. First of all, MuleSoft is the name of the company that created the existing suite of products. When people talk about MuleSoft in a development context, they are referring to all of the products that this company has created. A clearer example of this can be seen now that Facebook has changed its name to Meta; we can more easily see the difference between the name of the company (Meta) and its corresponding products (Facebook, Instagram, and WhatsApp). The same is the case with MuleSoft. The name of the company is MuleSoft; it’s not the name of a product. But when we refer to MuleSoft, it encompasses all of MuleSoft’s products.

Listing MuleSoft’s products

Let’s take a look at some of the most popular products that MuleSoft has released so far (up to the time of writing this book). The suite of technologies can be broken down into three main products:

  • Anypoint Platform
  • Anypoint Studio
  • Composer

Each of these products includes its own products and functionality as well. Let’s review them in detail.

Note

There are more products on the way – such as MuleSoft Robotic Process Automation (RPA) and Anypoint Code Builder – but we will not be talking about those in this book since they’re either not publicly available yet or have been just released.

Anypoint Platform

Anypoint Platform can be accessed through your browser. If you go to anypoint.mulesoft.com, you will see the login screen. You can create a free trial account that will last 30 days. Inside Anypoint Platform, you will find the following products:

Note

We will talk more about all these products in Chapter 5, All about Anypoint Platform.

  • Anypoint Design Center: This is where you can manage your API specifications with API Designer and your Async API Specifications with AsyncAPI Designer and create quick Mule applications with Flow Designer.
  • Anypoint Exchange: You can look at this product as an app store of sorts where you can find a catalog of published assets that you can reuse in your own code.
  • Anypoint DataGraph: If you’re familiar with DataGraph, MuleSoft created its own product to help you use this technology within its suite of products.
  • Access Management: This is where mostly only the admins of the account will be able to change permissions or access for the users of the account.
  • Anypoint API Manager: As its name says, you will be able to manage your APIs from here. You can manage alerts, contracts, policies, SLA tiers, and other settings.
  • Anypoint Runtime Manager: The Mule applications are located in Runtime Manager. You can access logs, object stores, queues, schedules, and settings.
  • CloudHub: If your Mule application is running within MuleSoft’s cloud provider service, that means you’re using CloudHub. Your Anypoint Platform free account will use CloudHub by default.
  • Anypoint Visualizer: You can use this product to get a visual representation of your systems, such as autogenerated architectural diagrams or available policies, or perform some general troubleshooting of your applications.
  • Anypoint Monitoring: Here, you can generate custom dashboards or use the built-in dashboards to get a better feel for how your apps are behaving.
  • Secrets Manager: Here, you can store sensitive data such as passwords, tokens, certificates, or keys in Secrets Manager so they can be accessed and still be secured.
  • Anypoint Runtime Fabric: This is not included in your free trial account, but this is where you would be able to deploy your Mule applications to different cloud providers, such as Microsoft Azure, Amazon Web Services, or Google Cloud Platform.
  • Anypoint MQ: This is MuleSoft’s message queueing service. It is a built-in solution that includes its own connectors to use within your code with no extra drivers or settings needed.
  • Anypoint Service Mesh: This is not included in your free trial account, but with this product, you can manage non-Mule applications within the same suite of products, regardless of the programming language they’re based in.
  • Anypoint Flex Gateway: With this lightweight gateway, you can manage Mule and non-Mule applications. You can install Flex Gateway in Docker, Kubernetes, or Linux. This is included in your free trial account.
  • Anypoint API Governance: Here, you can create standards for your API specifications, Mule or non-Mule applications, security policies, and more. This is included in your free trial account.

Let’s now see the products inside Anypoint Studio.

Anypoint Studio

Anypoint Studio is MuleSoft’s IDE (based on Eclipse). You install this application on your computer and this is where you’re able to develop Mule applications. Studio has a nice GUI to find predefined connectors and use them to develop your Mule flows. Inside Anypoint Studio, you will find the following products:

  • MUnit: MuleSoft’s testing framework. MUnit is optimized to create tests visually. We can create tests using connectors such as Mock, Assert, and Spy. We will talk more about MUnit in Chapter 11, Testing Your Application.
  • APIkit: With this product, you can take your API specification and create a basic structure for your Mule application instead of doing it from scratch. We will talk more about APIkit in Chapter 8, Building Your Mule Application.
  • DataWeave: MuleSoft’s functional programming language, optimized for transformations. We will do a deep dive into this language in Chapter 6, Learning DataWeave, and Chapter 7, Transforming with DataWeave.

Let’s now see an overview of Composer.

Composer

Composer, as opposed to the other MuleSoft products, is a no-code tool. There’s no need to create an API specification or implementation. Composer was specifically designed to have clicks not code, as its slogan says. If you’re familiar with some of the no-code tools we mentioned earlier in this chapter, such as Zapier and IFTTT, Composer follows a similar approach. We will talk more about Composer in Chapter 12, MuleSoft Integration with Salesforce.

Now that we understand the variety of products MuleSoft offers, let’s look into how all of these tools are useful.

Understanding why MuleSoft is useful

We just learned about the suite of products and functionality that MuleSoft offers. Besides being a low-code technology with a smaller learning curve than a regular programming language, MuleSoft can fulfill almost all the requirements you need to cover in the development life cycle. From designing to implementing and testing, to deploying, securing, and monitoring your solutions, MuleSoft most likely has a product for your needs. The best part is that because you’re using all these products under the same sphere, they can be easily integrated or moved from one stage to the next.

Let’s review what a Mule application or an API life cycle would look like within MuleSoft’s products.

Design phase – API specification

We’re first going to review what MuleSoft products can be used in the design phase of your API. This will result in an API specification that you can use as the foundation for the next phase. This phase takes place in Anypoint Platform:

  1. API specification design: Using Design Center, you can start designing your API specification with the visual API Designer without having to know RESTful API Modeling Language (RAML) or OpenAPI Specification (OAS).
  2. API specification testing: Using the mocking service, which can be found in API Designer, you can create a mock of your current API specification and make calls to it. This is with the purpose of getting a feel for how the developers will experience your API before even implementing it. The idea is that you go back and forth between the design and testing until you feel comfortable with the specification you’ve created.
  3. API specification publishing and feedback: From API Designer, you can publish your finished specification to Exchange for others in your organization to discover. Exchange will automatically generate basic documentation based on your API specification. You can share this Exchange asset with others in order to gather feedback on your design. If you still need to adjust things, you can just go back to API Designer and modify what’s needed. After you do this, you can publish a new version of your API specification in Exchange.

We can iterate through these first three steps as long as needed until we feel comfortable that we have an API specification on which to base our implementation. Once we have the first draft, we can continue with the next phase.

Implementation phase – Mule application

Now that we have a first draft of the API specification, we can get started with the implementation. This phase takes place in Anypoint Studio:

  1. Mule application implementation: This process is where you would be using the available connectors or DataWeave to start creating your Mule application’s implementation. After you’ve finished any number of iterations and feel comfortable with the API specification you generated in the previous phase, you are now ready to start creating your Mule application. From Anypoint Studio, you can connect to your Anypoint Platform account and download the API specification from Exchange. This will generate the basic flows and error handling so you don’t have to start creating everything from scratch. This process uses APIkit to route the different types of requests to their corresponding Mule flows. In addition, any request that is not recognized by the API specification will be routed to the corresponding error handling. For example, if we refer to our previous restaurant analogy, if you were to order food that was not available on the menu, the server would respond that what you requested does not exist.
  2. Mule application testing: Once you generate the main functionality, you are ready for the next step, which is where you would start creating your unit testing using MUnit. Nothing is better than a high-quality application. Here, you can create mocks and use asserts to make sure the different scenarios for your code are indeed working as expected. A best practice is to aim for 90% of MUnit coverage, if not 100%, but this varies depending on each project.

Same as earlier, we can iterate through these steps as many times as we need to achieve good-quality code and functionality of the application. Once we’re happy with the first draft of the functioning app, we can continue with the next phase.

Deployment and managing phase – API

Now that we have a functioning Mule application, we can start the deployment and managing phase. This phase takes place in Anypoint Platform:

  1. API deployment: After you’ve implemented and tested the Mule application on your local machine, you are ready to deploy it to the cloud. You can deploy your application from Anypoint Studio directly to Anypoint Platform. Just a few clicks and we’re done. You can see the progress of this deployment from Runtime Manager. You can host your app in different cloud providers, such as Amazon, Microsoft, or Google; but for now, we’ll just focus on MuleSoft’s CloudHub.
  2. API security: Now that your application is running in CloudHub, you are ready to create API policies, contracts, SLA tiers, and so on. All of this is managed by API Manager.
  3. API monitoring: Your API is secured and running. Now it’s time to lay back and relax. You can monitor your API from Anypoint Monitoring or create alerts in case something goes wrong and you want to immediately get notified about it.

The whole life cycle doesn’t end there, of course. This is just an example of what an API life cycle could look like. After deploying the application, the cycle starts again. Once the developers get a hold of your API and start testing it, some features or bugs will be on their way to you. This is where we’ll restart the cycle from the design or implementation phase, depending on the case, and the cycle continues once again.

Now we have a better idea of what MuleSoft is and how it’s useful in the API life cycle. This book was written for Salesforce developers and architects, so let’s now see how MuleSoft is helpful for your professional career.

Analyzing how MuleSoft helps Salesforce developers

MuleSoft has long been helpful in integrating different technologies, including Salesforce. However, since Salesforce acquired MuleSoft, we can see more and more integrations between the technologies. Furthermore, the acquisitions of Slack, Tableau, and Servicetrace have also increased the use of MuleSoft throughout these platforms and vice versa. For example, there wasn’t an official Slack connector in MuleSoft before, but one was created after the official acquisition. There is also a new product in the works called MuleSoft RPA, and guess what Servicetrace is? Yes, it’s an RPA technology. We now also have Composer, which is a technology created by mixing both Salesforce and MuleSoft technologies.

While it might be true that you don’t necessarily need to know MuleSoft in order to be a Salesforce developer, the past and the present are the foundation of what we predict the future will be like. What history’s been telling us is that Salesforce will continue adding to its 360 products from other companies it acquires. We already have Composer in common between Salesforce and MuleSoft – who knows what else will be integrated in the future. But it all points to the fact that MuleSoft will be integrated more and more to the Salesforce suite.

From a professional career perspective, currently, there are not a lot of developers who are proficient in both MuleSoft and Salesforce – they are either Salesforce developers or MuleSoft developers, or they may know a little bit about the other but are not experienced developers in both. It wouldn’t be a surprise if in some years job postings started requiring proficiency in both technologies.

The following summarizes what we have discussed in this section:

  • MuleSoft is slowly being added to Salesforce’s technology suite
  • There is already a product created that combines both Salesforce and MuleSoft: Composer
  • Career-wise, it would be smart of you to get ahead of the trend and become proficient in both technologies before it becomes a requirement