Skip to content

Latest commit

 

History

History
539 lines (456 loc) · 23.2 KB

File metadata and controls

539 lines (456 loc) · 23.2 KB

Name of the variable in which you want to store message data. Names can only include numbers, characters, and underscores. For example, hyphens are not allowed in the name. Value of the data to store in the target variable. By default, the value is the message payload (payload). The field accepts any value that a variable accepts: any supported data type, DataWeave expressions, the keywords payload, attributes, and message, but not the keyword vars. See mule-runtime::target-variables.adoc in the Mule documentation.

| Encoding | encoding | Encoding of the payload that this component outputs. | Mime type | mimeType | MIME type of the payload that this component outputs. For more information, see Using Reader and Writer Properties. | Parameters | N/A | Appends a key-value pair for a reader property to the value of the outputMimeType attribute. Multiple key-value pairs are allowed. Reader properties are specific to the MIME type. For example, see the JSON reader properties for application/json. To find other reader properties, navigate to a supported format from the DataWeave format documentation, and see Using Reader and Writer Properties.

For reference documentation on specific connector and component configurations, see acb-reference.adoc.

When adding components, you can start from the canvas or the configuration XML for your app. You can configure components from their configuration panels in the canvas or from the XML.

In Anypoint Code Builder, both integrations and implementations are Mule applications.

reuse::partial$connectors/connectors-mule-apps.adoc

Built-in Anypoint connectors are available from the canvas and configuration XML for integration and implementation projects. These connectors include:

  • Anypoint Connector for Agent2Agent (A2A) (Beta) (<a2a:/>) (A2A Connector)

  • Anypoint Connector for Agentforce (<ms-agentforce:/>) (Agentforce Connector)

  • Anypoint Connector for Database (<db:/>) (Database Connector)

  • Anypoint Connector for Einstein AI (<ms-einstein-ai:/>) (Einstein AI Connector)

  • Anypoint Connector for Email (<email:/>) (Email Connector)

  • Anypoint Connector for File (<file:/>) (File Connector)

  • Anypoint Connector for HTTP (<http:/>) (HTTP Connector)

  • Java Module (<java:/>)

  • Anypoint Connector for MCP (MCP Connector) (<mcp:/>)

  • Anypoint Connector for Salesforce (<salesforce:/>) (Salesforce Connector)

  • Anypoint Connector for Salesforce Data Cloud (<sdc:/>) (Salesforce Data Cloud Connector)

  • Anypoint Connector for Sockets (<sockets:/>) (Sockets Connector)

  • Anypoint Connector for Workday (<workday:/>) (Workday Connector)

Connector XML tags start with a namespace followed by an operation, following the syntax namespace:operation, such as <db:select/> for a Select operation in Anypoint Connector for Database (Database Connector). For more information, see connectors::introduction/intro-config-use-acb.adoc.

Many other connectors are available from your Anypoint Code Builder IDE through Anypoint Exchange:

To find information about more connectors, see connectors::introduction/introduction-to-anypoint-connectors.adoc, and find documentation on all Anypoint connectors and modules.

Use the Connection Management Configuration Panel to easily configure connections to third-party systems directly from the UI.

In this panel, you can create, edit, delete, and test connections directly within the IDE interface, automatically populate connection fields using metadata provided by the connector, and save and manage connection configurations without switching to the XML view.

To open the configuration panel:

  • Select an existing component, or add a new one.

  • Click the + icon.

    This action displays the configuration panel, for example:

Configuration panel for connectors

From here, you can:

  • Configure a connection for this project.

    You can select a previously saved connection in the Connection field and the form is pre-populated with existing configuration data.

    Note
    Changes impact all components using this connection.
  • Update connection details without manually editing the XML code.

  • Test the connection directly within the panel to verify it’s correctly configured.

    The test functionality helps prevent errors by allowing users to confirm that the connection is valid before committing changes.

  • Delete an existing connection if it’s no longer needed.

    A confirmation message shows any affected components that use the connection.

  • View all components that depend on a connection.

Configure message and event processing in an integration application or API implementation. Core processors (also called Mule components) run on the Mule runtime engine.

The following examples illustrate basic configurations for adding components to your project from the canvas, and the configuration XML. The examples assume you are beginning with an empty integration project.

  1. {open-config-xml}, such as my-project-name.xml.

    Canvas showing visual representation of Mule flow and the Mule configuration file
    1. The canvas provides space for a visual representation of your Mule flows or subflows.

    2. The configuration XML editor displays the configuration file for your Mule application.

  2. Select Build a Flow from the canvas to create an empty flow within a Mule integration application.

  3. Change the default name of the flow from the canvas or from the configuration XML.

    From the canvas

    Click Flow name1 to open the configuration panel for the Flow component, change the flow name, and click the check mark to set the new name.

    Change name of flow through canvas.
    From the configuration XML

    Replace the default name of the flow (name1) with your flow name, such as getFlights, for example:

    <flow name="my-flow" >
    
    </flow>
  4. Add a component to your project from the canvas.

    For example, add the HTTP Listener component:

    1. In the canvas, click the (Add component) icon.

    2. In the Add Component panel, search for and select Listener from the HTTP results:

      Listener component highlighted in the Add Component section

      The configuration XML file now includes the XML for the HTTP Listener within the <flow/> element, for example:

      <flow name="getFlights" >
        <http:listener path="mypath" config-ref="config-ref" doc:name="Listener" doc:id="rrjiqa" />
      
      </flow>
  5. Add another component, this time using the configuration XML.

    In the configuration XML, place your cursor before the opening <flow> tag. Ensure that the cursor is not inside the <flow/> element. Add the following code:

    <http:listener-config name="HTTP_Listener_config" >
      <http:listener-connection host="0.0.0.0" port="8081" />
    </http:listener-config>
    1. Notice that the Listener component in the canvas now displays an error:

      Listener error in the canvas
    2. To determine where the error is, select the processor in the canvas.

      Anypoint Code Builder highlights its location within the configuration XML, and you can mouse over the issue for more information, for example:

      Selecting configuration reference from configuration panel
    3. To fix the error, change the value of the name attribute in http:listener-config to match the name of the config-ref value in your http:listener configuration:

      <http:listener-config name="config-ref" >
        <http:listener-connection host="0.0.0.0" port="8081" />
      </http:listener-config>

      The HTTP listener within your flow now references the HTTP listener configuration, a global connection configuration that resides outside of the flow. For more information about debugging, see anypoint-code-builder::debugging-mule-apps.adoc.

  6. Add another component to your flow.

    For example, add a Set Payload component to your HTTP Listener operation:

    1. In the canvas, click the (Add component) icon.

    2. In the Add Component panel, search for and select Set payload from the Transformer results.

    3. In the canvas, click Set payload to open its configuration panel, and add a string value, DataWeave expression, Mule variable, or configuration property.

      • To add a string, type a value such as my value. For example:

        Adding string to Set Payload
      • To add a DataWeave expression or a Mule variable as a value, such as payload, click fx (located before the field), and provide the value, for example:

        Adding expression to Set Payload

    For more information about configuring DataWeave expressions, see anypoint-code-builder::int-configure-dw-expressions.adoc.

    • To add a configuration property as a value, type a value such as ${secure::mysensitiveprop}. For example:

      Adding configuration property to Set Payload

      For more information about configuration properties, see anypoint-code-builder::int-create-secure-configs.adoc.

    Your configuration XML file now looks similar to the following:

    <http:listener-config name="config-ref" >
      <http:listener-connection host="0.0.0.0" port="8081" />
    </http:listener-config>
    
    <flow name="getFlights" >
      <http:listener path="path" config-ref="config-ref" doc:name="Listener" doc:id="rrjiqa" />
      <set-payload value="my value" doc:name="Set payload" doc:id="gecykt" />
    
    </flow>
  7. Add another component to your flow.

    For example, add the Create operation from Anypoint Connector for Salesforce to insert an Account record.

    Use this pattern when your flow receives data through an HTTP Listener and must create Salesforce records. If you completed the earlier steps that add Set payload with a fixed string, remove or replace that processor so you can shape the payload before Create.

    For more information about using Create with Account records, see salesforce-connector::salesforce-connector-examples.adoc.

    1. In the configuration XML, add a global Salesforce connection element above your <flow> element (not inside the flow).

      Use configuration properties for credentials instead of literals; for example:

      <salesforce:sfdc-config name="Salesforce_Config" doc:name="Salesforce Config">
        <salesforce:basic-connection username="${salesforce.username}" password="${salesforce.password}" securityToken="${salesforce.token}" />
      </salesforce:sfdc-config>

      For more information about connection types and authentication fields, see salesforce-connector::index.adoc.

    2. In the canvas, click the (Add component) icon after HTTP Listener.

    3. In the Add Component panel, search for Set payload, and add the component.

    4. Configure Set payload with a DataWeave expression that builds a JSON object whose fields match your HTTP API (they need not match Salesforce field names yet).

      For example, use fx to enter DataWeave with output application/json and sample fields such as companyName, industry, and phoneNumber.

      Alternatively, add Transform Message and use the same DataWeave in <ee:set-payload/>.

      For more information about Transform Message, see anypoint-code-builder::acb-component-transform.adoc.

    5. From the canvas, click the (Add component) icon after Set payload (or Transform Message).

    6. In the Add Component panel, click Connectors, select Salesforce, and select Create.

    7. In the configuration panel for Create, set:

      • Connection config: The global Salesforce configuration name (for example, Salesforce_Config).

      • Type: Account.

      • Records: A DataWeave expression that resolves to the records to create.

        If the incoming payload uses different property names than Salesforce expects, map those properties in Records, as shown in the configuration XML example that follows. If the payload is already an array of Java objects with Salesforce field names (output application/java), you can use #[payload].

      Tip

      If Type stays empty until you establish a working Salesforce connection, set type="Account" on <salesforce:create/> in the configuration XML. For more information about connector fields for this operation, see salesforce-connector::index.adoc.

      Note

      Picklist fields such as Industry must use values that exist in your Salesforce organization.

      The following configuration XML listens on /accounts, builds a JSON payload, maps it to Account fields inside <salesforce:records/>, and calls Create. Align config-ref on <http:listener/> with the name of your <http:listener-config/> (for example, config-ref from the earlier steps in this topic).

      <http:listener-config name="config-ref" >
        <http:listener-connection host="0.0.0.0" port="8081" />
      </http:listener-config>
      
      <salesforce:sfdc-config name="Salesforce_Config" doc:name="Salesforce Config">
        <salesforce:basic-connection username="${salesforce.username}" password="${salesforce.password}" securityToken="${salesforce.token}" />
      </salesforce:sfdc-config>
      
      <flow name="createSalesforceAccountFlow" >
        <http:listener path="/accounts" config-ref="config-ref" doc:name="Listener" doc:id="rrjiqa" />
        <set-payload doc:name="Set Payload" value="#[%dw 2.0
      output application/json
      ---
      {
        companyName: 'Anypoint Inc.',
        industry: 'Technology',
        phoneNumber: '415-229-2000'
      }]" />
        <salesforce:create doc:name="Create" type="Account" config-ref="Salesforce_Config">
          <salesforce:records>#[%dw 2.0
      output application/java
      ---
      [{
        Name: payload.companyName,
        Industry: payload.industry,
        Phone: payload.phoneNumber
      }]]
          </salesforce:records>
        </salesforce:create>
      
      </flow>

      If the message payload is already an array of Java objects with Salesforce field names, you can omit <salesforce:records/> and set Records to #[payload], or use a self-closing <salesforce:create/> element with that default.

      You can achieve the same result by adding Transform Message with output application/java followed by <salesforce:create type="Account" config-ref="Salesforce_Config"/> with Records set to #[payload].

Most connectors provide an operation, such as the HTTP Listener operation, that triggers the flow to start. These operations typically include connection configurations that you can test.

Test Connection from the Configuration Panel

You can test the connection from the connectors Configuration panel. For example, to test an HTTP Listener connection:

Configuration panel for connectors

  1. Click the + icon on the connector to open the configuration panel.

  2. After filling in the required fields, click Test Connection.

The status bar shows the progress:

  • Verifying connection indicates that the test is in progress.

  • Connection is valid indicates a successful connection.

  • Invalid Connection Got status code: 500 when trying to resolve a Mule Runtime operation indicates a connection error.

Test Connection from the Configuration XML

You can test the connection from the configuration XML. For example, to test an HTTP Listener connection, click Test Connection in the configuration XML:

HTTP Listener Test Connection link in the configuration XML

The status bar shows the progress:

  • Verifying connection inbound-request indicates that the test is in progress.

  • Connection is valid indicates a successful connection.

  • Invalid Connection Got status code: 500 when trying to resolve a Mule Runtime operation indicates a connection error.

    A common code 500 error is port 8081: Address already in use. For port conflicts, configure a different port, such as 8082, and retest the connection.

Before publishing, run your application in debug mode.

Anypoint Connectors provide operations for retrieving, modifying, and sending data to and from systems. In addition to the built-in connectors that Anypoint Code Builder provides, you can download many other connectors from Anypoint Exchange.

Import a Connector from the Canvas

To import a connector from Exchange and add it to your configuration:

  1. {open-config-xml}, such as my-project-name.xml.

  2. Click (Show Mule graphical mode) in the activity bar to open the UI canvas if it doesn’t open automatically.

  3. Add the connector the same way you added other components from the canvas:

    1. In the canvas, click the (Add component) icon.

    2. In the Add Component panel, click Connectors.

    3. Click the connector name and then click the operation to add, such as Publish:

      Add Publish operation from the Anypoint MQ Connector
    4. If the connector is not available locally, click the (Search in Exchange) toggle:

      Search in Exchange toggle
      1. Search locally

      2. Search in Exchange

    5. Select the connector to add to your project. You can select from connector versions that are compatible with your Mule runtime and Java version set in Project Properties.

      Exchange connectors with valid versions for the project
    6. Select the operation from the Add Component panel.

Import a Connector with a Command

To import a connector from Exchange to use later in your project:

  1. {open-config-xml}, such as my-project-name.xml.

  2. Click (Show Mule graphical mode) in the activity bar to open the canvas if it doesn’t open automatically. partial$acb-reusable-steps.adoc

  3. Select the following command:

    MuleSoft: Import Asset from Exchange
  4. Select Connector.

  5. Search for the connector name to import, such as "MQ," for example:

    "Import Anypoint MQ Connector from Exchange
  6. Select the connector.

  7. At the prompt, select the version of the connector to import, such as v4.0.3.

    Anypoint Code Builder imports the connector and makes it available in the Components list.

For more information about the connectors available on Exchange, see connectors::index.adoc. For more information about Exchange, see Exchange (US) or Exchange (EU) and exchange::index.adoc.

You can open a component and its configuration panel in the canvas from the XML editor. This feature is helpful, for example, if you want to configure the component from the UI, if a component is in another flow than the flow currently displayed in the canvas, or if the canvas is not open.

  1. From the configuration XML, place your cursor within the component’s XML.

  2. Right-click and select Configure Component in UI.

    This action displays the component in the canvas and opens its configuration panel, for example:

    Opening a component in the canvas from the XML