Global Elements 

A Global Element is a reusable object containing parameters that any number of elements in a flow can share. You typically reference a global element from Anypoint Connectors in your Mule app project.

Use the global element to apply configuration details to multiple local elements in flows. Create one global element that details your connection, configuration or transport details. Simply reference the global element from any flow element that should use those same parameters. That way you can ensure consistency across flow elements.

When the parameters of the applicable flow elements must change, just change the details from the global element they reference.


Before venturing further into this topic, review the features of the Anypoint Studio Visual Editor to learn more about developing Mule applications using the Anypoint Studio graphical user interface and to understand the context in which we use these "global elements".


Global elements provide a number of benefits to you as a Mule application developer.


You can configure a global element just once, and share that configuration among building blocks of the same type. This is particularly useful when you have to define the connection details and login credentials for an external source, such as a SaaS application or database.


Rather than changing the same configuration multiple times within many like building blocks (for example, multiple connectors that hook into the same service, using one set of credentials) throughout the Mule flow, you can change the configuration once in the global element, and the changes apply to all Mule flow elements that reference the global element.


An element in a Mule flow can apply a global element’s configuration exactly as defined, or compliment the global configuration properties.

How to Create a Global Element

Some components require their properties be stored in a global element. In any case, we recommend you use global elements for the Advantages listed in the previous section.

  1. In the Anypoint Studio Visual Editor, click the Global Elements tab at the base of the canvas to access a list of all global elements in an application.


  2. Click Create to add a new global element.

  3. In the Choose Global Type wizard, navigate the directories or use the filter to select the type of global element you wish to create, then click OK.

  4. Define the configurable parameters of your global element in the Global Element Properties window that appears, then click OK to save.

    To create a new global element from within a local element you placed in your flow:

    1. Click one of the pieces of your flow whose global element you want to create/configure. A box should appear around the element in the flow — take for instance, an IMAP connector that has been clicked on:

      imap example selected

    2. In the properties pane that appears below the canvas, click the plus icon next to the Connector Configuration or similar reference field dropdown menu. (Click the Edit icon to edit an existing global element you may have already created.)


    3. Fill in the required fields for the type of global element you set out to create.

  1. In the XML Editor in Studio, or other text editor, open your XML configuration file for your Mule application.

  2. Create a global element for your Mule flow element above and outside any <flow> you may have defined already in your application.

  3. Define the attribute values that your local element will reference, within the global element you create.

  4. To configure a local element in the flow to reference a global element, add a config-ref or connector-ref attribute inside the local element, which appears inside the <flow>. The example below has a global element for the Salesforce connector (sfdc:config)

  5. The flow includes a Salesforce connector (sfdc:create) that references the global Salesforce element, named "Salesforce1": <sfdc:create config-ref="Salesforce1" type="" doc:name="Salesforce Connector">

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;mule xmlns:data-mapper="" xmlns:sfdc="" xmlns:file="" xmlns:tracking="" xmlns="" xmlns:doc="" xmlns:spring="" xmlns:xsi="" xsi:schemaLocation=""&gt;
    &lt;sfdc:config name="Salesforce1" username="username" password="password"  doc:name="Salesforce" securityToken="IQZjCdweSF45JD90Me2BWLLVDo"&gt;
        &lt;sfdc:connection-pooling-profile initialisationPolicy="INITIALISE_ONE" exhaustedAction="WHEN_EXHAUSTED_GROW"/&gt;
    &lt;flow name="Contacts_to_SFDC" doc:name="Contacts_to_SFDC"&gt;
        &lt;sfdc:create config-ref="Salesforce1" type="" doc:name="Salesforce Connector"&gt;
            &lt;sfdc:objects ref="#[payload]"/&gt;

Name Attribute for Security Manager Global Element

Although not required by the Mule runtime, the name attribute for the security manager global element is now required in Anypoint Studio as of version 6.0.0. If you are coding by hand in Anypoint Studio, be sure to define the name attribute on the security-manager element to suppress errors that may be reported by Studio.

Global Element Examples

Example 1 - Global Element to Append a String

If you find that you need to append the same string multiple times at various points in a flow, you might store such a piece of functionality inside a global element for a Transformer of type Append String, where the Message field would be where you store your string to append.

example ge for append string

Example 2 - Global Element for an HTTP Listener

Let’s see how to configure a global element for a typical HTTP listener you might test in an app you run locally in Studio, using its embedded Mule runtime engine.

  1. Drag the HTTP listener onto the Anypoint Studio canvas to begin creating its global element. Select it with your mouse.

    http listener snapshot

  2. After clicking the HTTP listener in the flow, you see the HTTP listener pane at bottom. From there, focus in and click the plus sign.


  3. Configure the HTTP listener to listen for HTTP requests; in this case, localhost, port 8081

    global elements c1536

  4. Returning to the main HTTP listener pane, we see our HTTP listener references the global element by name in the Connector Configuration dropdown.

    global elements 1259f

In reality an app would not suffice with only an HTTP listener, however it is a widely used piece of functionality in Mule applications that you will naturally get used to setting up.

XML View

Global element XML structure for the HTTP listener is as follows. The required fields for this connector’s global element are name, host and port.

<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration">
If you are coding by hand, notice the global element is defined outside and above the <flow> that references it.

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="" xmlns="" xmlns:doc="" xmlns:spring="" xmlns:xsi="" xsi:schemaLocation="">
    <http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration">
        <http:worker-threading-profile threadWaitTimeout="1500" maxBufferSize="10"/>
    <flow name="myNewProjectFlow1" doc:name="myNewProjectFlow1">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP Connector"/>

See Also