Contact Us 1-800-596-4880

Ajax Connector

ajax icon

The Ajax Connector creates a transport channel to send messages asynchronously to and from an Ajax server, which communicates with external Web resources. Ajax is an acronym for Asynchronous JavaScript and XML, a cluster of related technologies that facilitate the creation of asynchronous Web applications. The Ajax Connector can be configured as an inbound or outbound endpoint.

In Anypoint Studio, the Ajax connector is called the CometD connector and is pre-installed in Anypoint Studio.

Exchange: CometD Connector

Typically, the Ajax endpoint connects your Mule flow to an external web page, which can exchange information with a user somewhere in the Cloud. A JavaScript client attached to the webpage listens for user input, which it sends through the Ajax endpoint to your flow for processing.

Typically, the channel that the Ajax server and the Ajax endpoint use for communication is configured though a Global Element template known as a Connector Configuration.

General Configuration

Configuration of an Ajax endpoint typically requires two steps:

  1. Decide where you want to place the Ajax endpoint within your Mule flow, then drag it from the Palette to the appropriate place in the sequence of processors that make up your Mule flow.

    1. If you place the Ajax endpoint at the beginning of the flow, it acts as an inbound endpoint (that is, a message source for your application).

    2. If you place the Ajax connector in the middle or end of the flow, it serves as an outbound endpoint.

  2. Configure the Ajax endpoint (and the Connector Configuration it depends on to define its transport channel) by providing values for the fields on the various tabs on the Ajax endpoint properties editor, which you open by double-clicking the Ajax icon on the Message Flow canvas.

Configure the tabs as shown.

General Tab

Studio-ajax-gen
Property Description

Display Name

Defaults to the generic endpoint name, which in this case is Ajax. Change the display name, which must be alpha-numeric, to reflect the endpoint’s specific role, such as Interactive Opinion Poll Connection.

Channel

Specify the channel over which your Ajax endpoint communicates with the client web page. For example, /services/echo.

Connector Configuration

Use the dropdown list to select a previously configured connector configuration for this endpoint. If you have not created a connector configuration for this type of endpoint, you can do so from this window by clicking Add. Click Edit to modify a previously created global element.

Advanced Tab

Studio-ajax-outbound-adv
Property Description

Address

Enter the address for this endpoint, such as http://localhost:8081/file.

Response timeout

Specify how long the endpoint must wait for a response (in ms). The default is 1000 ms.

Encoding

Choose from a drop-down list the character set used for message data. (such as UTF-8).

Disable Transport Transformer

Check this box if you do not want to use the endpoint’s default response transport.

MIME Type

Select from the dropdown list one of the formats this endpoint supports.

Cache Messages

(Applies to outbound Ajax endpoint only). Check this box to enable the dispatcher to cache messages. Messages will only be cached if no clients are subscribed to the channel.

Message Cache Size

(Applies to outbound Ajax endpoint only). Enable Cache Messages, then select the cache size. Default cache size is 1024.

Connector Endpoint

Use the drop-down list to select a previously configured global endpoint template, if any exist. If you have not created a global element for this type of endpoint, you do so by clicking Add and completing the fields on the pane that appears. Click Edit to modify a previously created global element.

Enable default events tracking

Enable default business event tracking for this endpoint.

Transformers Tab

Studio-ajax-trans
Field Description

Transformers References: Request

Enter a list of synchronous transformers that will be applied to the request before it is sent to the transport.

See Also

  • For details on setting the properties for an Ajax endpoint using an XML editor, see the Ajax Transport Reference discussion in the Mule Runtime documentation.

View on GitHub