mule global elements

18
Mule Global Elements

Upload: cong-thanh-nguyen

Post on 16-Apr-2017

212 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Mule global elements

Mule Global Elements

Page 2: 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

Page 3: Mule global elements

Advantages

• Provide a number of benefits to you as a Mule application developer

Page 4: Mule global elements

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

Page 5: Mule global elements

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

Page 6: Mule global elements

Flexibility

• Can apply a global element’s configuration exactly as defined, or compliment the global configuration properties

Page 7: Mule global elements

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

Page 8: Mule global elements

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

Page 9: Mule global elements

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>

Page 10: Mule global elements

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">

Page 11: Mule global elements

Global Element Examples

Page 12: Mule global elements

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

Page 13: Mule global elements

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

Page 14: Mule global elements

Example 2 - Global Element for an HTTP Listener

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

Page 15: Mule global elements

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

Page 16: Mule global elements

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">

Page 17: Mule global elements

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

Page 18: Mule global elements

Question and answer