Contact Us 1-800-596-4880

Anypoint Connectors

Mule Runtime Engine versions 3.5, 3.6, and 3.7 reached End of Life on or before January 25, 2020. For more information, contact your Customer Success Manager to determine how you can migrate to the latest Mule version.
connectors

Anypoint Connectors receive or send messages between Mule and one or more external sources, such as files, databases, or Web services. Connectors can act as message sources by working as inbound endpoints, they can act as a message processor that performs an operation in middle of a flow, or they can fall at the end of a flow and act as the recipient of the final payload data.

Connectors in Mule are either endpoint-based or operation-based. Endpoint-based connectors follow either a one-way or request-response exchange pattern and are often (but not always) named and based around a standard data communication protocol, such as FTP, JMS, and SMTP. Operation-based connectors follow an information exchange pattern based on the operation that you select and are often (but not always) named and based around one or more specific third-party APIs.

Endpoint-Based Connectors

Endpoint-based connectors are configured as either inbound or outbound endpoints in a flow. Inbound endpoints serve as a message source for a flow. Outbound endpoints can occur mid-flow or at the end of flows, and send information to external systems.

endpointbased

Operation-Based Connectors

When you add an operation-based connector to your flow, you immediately define a specific operation for that connector to perform.

operationbased

The XML element of the connector differs according to the operation that you select, taking the form <connectorName>:<operation>. For example, sfdc:query or sfdc:upsert-bulk. The remaining configuration attributes or child elements are determined by the operation that you select.

Global Connector Configuration

Some connectors require that connection information such as username, password, and security tokens be configured in a global element rather than at the level of the message processor within the flow. Many connectors of the same type in one application can reference the connector configuration at the global level. For operation-based connectors, the global connector configuration is mandatory, but for most endpoint-based connectors it is optional.

Note that the global element that you configure in Anypoint Studio is called a Connector Configuration. The corresponding XML tags are <connectorName>:config for operation-based connectors and <connectorName>:connector for endpoint-based connectors. See the examples below.

Examples

HTTP Connector

This example shows how an HTTP connector, which can be configured both as a listener (for receiving inbound requests) or as a request connector (for making outbound requests). The HTTP connector always requires a global connector configuration that specifies its connection attributes.

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">


    <http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081"  doc:name="HTTP Listener Configuration"/>
    <http:request-config name="HTTP_Request_Configuration" host="localhost" port="8082"  doc:name="HTTP Request Configuration"/>

    <flow name="httpexampleFlow1" >
        <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
        <set-payload value="foo" doc:name="Set Payload"/>
        <logger message="#[payload]" level="INFO" doc:name="Logger"/>
        <http:request config-ref="HTTP_Request_Configuration" path="/" method="POST" doc:name="HTTP"/>
    </flow>

</mule>

JMS Connector

This example shows a JMS connector, which is endpoint-based, configured as an inbound endpoint in a flow. The JMS endpoint includes a mandatory reference to a global connector configuration which contains the connection parameters.

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd

http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd

http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd">

    <jms:activemq-connector name="Active_MQ" username="test" password="test" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>

    <flow name="myNewProjectFlow1" doc:name="myNewProjectFlow1">
        <jms:inbound-endpoint queue="test" connector-ref="Active_MQ" doc:name="JMS Endpoint"/>

...
    </flow>

</mule>

Salesforce Connector

This example shows a Salesforce connector, which is operation-based, configured to create a new contact in Salesforce based on the payload pulled from a file endpoint. The Salesforce connector includes a mandatory reference to a global connector configuration which contains the connection parameters.

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:sfdc="http://www.mulesoft.org/schema/mule/sfdc" xmlns:file="http://www.mulesoft.org/schema/mule/file"
    xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/sfdc http://www.mulesoft.org/schema/mule/sfdc/current/mule-sfdc.xsd">

    <sfdc:config name="Salesforce" username="test" password="test" securityToken="test" doc:name="Salesforce"/>

    <flow name="newprojectFlow1" doc:name="newprojectFlow1">
        <file:inbound-endpoint responseTimeout="10000" doc:name="File" path="/Users/AaronMacbook/Desktop/Input"/>
        <sfdc:create config-ref="Salesforce" type="contact" doc:name="Salesforce">
            <sfdc:objects ref="#[payload]"/>
        </sfdc:create>

    </flow>

</mule>

See Also