mule global elements
TRANSCRIPT
Mule Global Elements
Instructions
• Reusable object containing parameters that you reference from any number of elements in a flow, such as Anypoint Connectors
• apply configuration details to multiple local elements in flows
• Just change the details from the global element they reference when the parameters of the applicable flow elements must change
Advantages
• Provide a number of benefits to you as a Mule application developer
Reusability
• Configure a global element just once, and share that configuration among building blocks of the same type
• Useful when you have to define the connection details and login credentials for an external source, such as a SaaS application or database
Efficiency
• Changing the same configuration multiple times within many like building blocks just change the configuration once in the global element
• Changes apply to all Mule flow elements that reference the global element
Flexibility
• Can apply a global element’s configuration exactly as defined, or compliment the global configuration properties
Create a Global Element – Using Anypoint Studio Visual Editor
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
Create a Global Element – Using Anypoint Studio Visual Editor
2. Click Create to add a new global element3. 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
Create a Global Element – Using XML Editor or Standalone
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>
Create a Global Element – Using XML Editor or Standalone
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">
Global Element Examples
Example 2 - Global Element for an HTTP Listener
1. Drag the HTTP listener onto the Anypoint Studio canvas to begin creating its global element. Select it with your mouse
Example 2 - Global Element for an HTTP Listener
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
Example 2 - Global Element for an HTTP Listener
3. Configure the HTTP listener to listen for HTTP requests; in this case, localhost, port 8081
Example 2 - Global Element for an HTTP Listener
4. Returning to the main HTTP listener pane, we see our HTTP listener references the global element by name in the Connector Configuration dropdown
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">
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
Question and answer