MuleSoft Connectors

Connectors are MuleSoft's pre-built components for connecting to external systems. Instead of writing custom code to integrate with Salesforce, a database, or an FTP server, you drag a connector onto the canvas and configure it. Connectors handle the technical details of the connection so you can focus on the business logic.

What Is a Connector

Think of a connector as a universal remote control. Each button on the remote corresponds to an operation you can perform on the target system. The Salesforce Connector has buttons for "Query Records," "Create Record," "Update Record," and "Delete Record." You pick the button you need and configure the details.

Connector in a Flow

Without a Connector (manual code):
Developer writes hundreds of lines of Java code to:
  - Open HTTP connection to Salesforce
  - Handle OAuth token refresh
  - Build SOAP/REST request
  - Parse Salesforce response
  - Handle errors and retries

With a Connector (MuleSoft):
[Salesforce Connector: Query]
  Object: Contact
  Query: SELECT Id, Name WHERE Email = 'alice@example.com'
Done. Three fields to fill in. Connector handles everything else.

Types of Connectors

Core Connectors

Core connectors come pre-installed with Anypoint Studio. They handle the most common integration needs:

  • HTTP Connector: Send and receive HTTP/HTTPS requests. Used in nearly every application.
  • File Connector: Read, write, copy, move, and delete files on the local filesystem.
  • Scheduler: Trigger a flow at fixed intervals or on a cron schedule, like every day at 6 AM.
  • Logger: Write messages to the application log for debugging and monitoring.
  • Set Payload / Set Variable: Modify the message payload or store values in variables.
  • Transform Message (DataWeave): Convert data from one format to another.

Technology Connectors

Technology connectors work with widely used protocols and platforms:

  • Database Connector: Execute SQL queries against MySQL, Oracle, PostgreSQL, Microsoft SQL Server, and other databases.
  • JMS Connector: Send and receive messages using the Java Message Service protocol (ActiveMQ, IBM MQ).
  • SFTP / FTP Connector: Transfer files over FTP or SFTP protocols.
  • Email (SMTP/IMAP) Connector: Send emails via SMTP and read emails via IMAP or POP3.
  • Anypoint MQ Connector: Use MuleSoft's built-in cloud message queue service.

Application Connectors

Application connectors integrate with specific third-party software products:

  • Salesforce Connector: Create, read, update, and delete Salesforce records. Subscribe to Salesforce events.
  • SAP Connector: Call SAP BAPIs, IDocs, and RFCs.
  • ServiceNow Connector: Create and update incidents, changes, and other records.
  • Workday Connector: Integrate with Workday HR and Finance modules.
  • Slack Connector: Post messages to Slack channels from a Mule flow.

Connector Operations

Each connector provides a set of operations. An operation is one specific action the connector can perform. The Database Connector, for example, has these operations:

Database Connector Operations

Database Connector
   |
   +-- Select        (Run a SELECT query, get results)
   |
   +-- Insert        (Run an INSERT statement)
   |
   +-- Update        (Run an UPDATE statement)
   |
   +-- Delete        (Run a DELETE statement)
   |
   +-- Stored Procedure  (Call a stored procedure)
   |
   +-- Bulk Insert   (Insert many rows at once from a list)

Connector Configuration

Every connector needs a configuration that defines how to connect to the target system. The configuration is created once and reused by all instances of that connector in your application. Think of the configuration as a saved contact in your phone — you configure the number once and call it by name whenever you need it.

HTTP Connector Configuration Example

Connector Configuration: "HTTP_Config"
  Protocol: HTTPS
  Host: api.example.com
  Port: 443
  Connection Timeout: 30 seconds

Flow 1: [HTTP Request: config=HTTP_Config, path=/customers, method=GET]
Flow 2: [HTTP Request: config=HTTP_Config, path=/orders, method=POST]
Flow 3: [HTTP Request: config=HTTP_Config, path=/products, method=GET]

All three flows reuse the same HTTP_Config. Change the host in one place 
and all three flows pick up the change automatically.

Installing a Connector

Core connectors are already available in the Mule Palette. Application connectors like the Salesforce Connector need to be added to your project first.

Method 1 — From the Mule Palette:

  1. Click the search icon in the Mule Palette
  2. Type the connector name
  3. If it appears with an "Add to Project" button, click it
  4. Studio downloads and adds the connector to your project

Method 2 — From the pom.xml:

  1. Open the pom.xml file in your project
  2. Add the connector dependency with its group ID, artifact ID, and version
  3. Save the file. Maven downloads the connector automatically

pom.xml Dependency for Salesforce Connector

<dependency>
  <groupId>com.mulesoft.connectors</groupId>
  <artifactId>mule-salesforce-connector</artifactId>
  <version>10.18.0</version>
  <classifier>mule-plugin</classifier>
</dependency>

Connection Pooling

Many connectors support connection pooling. A connection pool keeps a set of open connections ready to use instead of opening a new connection for every request. This speeds up processing significantly for high-volume applications.

Connection Pool Diagram

Without Pool:
Request 1 --> Open Connection --> Query --> Close Connection  (slow)
Request 2 --> Open Connection --> Query --> Close Connection  (slow)
Request 3 --> Open Connection --> Query --> Close Connection  (slow)

With Pool (5 connections pre-opened):
Pool: [Conn1] [Conn2] [Conn3] [Conn4] [Conn5]

Request 1 --> Borrow Conn1 --> Query --> Return Conn1  (fast)
Request 2 --> Borrow Conn2 --> Query --> Return Conn2  (fast)
Request 3 --> Borrow Conn3 --> Query --> Return Conn3  (fast)

In the Database Connector configuration, set Min Pool Size and Max Pool Size to control connection pooling. Start with 5 minimum and 10 maximum for typical applications.

Testing a Connector

Every connector configuration has a Test Connection button. Click it after entering connection details to verify the credentials and connectivity before running your flow. A green checkmark means the connection works. A red error message tells you what is wrong — wrong password, unreachable host, or missing permissions.

Leave a Comment

Your email address will not be published. Required fields are marked *