Contact Us 1-800-596-4880

Anypoint Connectors

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 the middle of a flow, or they can be 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 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 an 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.

HTTP Connector Example

This example shows how an HTTP connector, which is operation-based. You can configure this connector as both a listener for receiving inbound requests or as a request connector for making outbound requests. The HTTP connector 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 Example

This example shows an endpoint-based JMS connector for the JMS transport. You can configure this connector 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 Example

This example shows a Salesforce connector, which is operation-based. You can configure this connector 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 that 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