Mule provides two different kinds of HTTP connectors based on the runtime version. For anything below 3.6 the HTTP connector is an endpoint based connector and runtime 3.6 and above contains HTTP operation based connector.
Endpoint-based Connector
An Endpoint based connector is used to connect flows and like any endpoint configuration, it has ability to embed message processors in it. Below are some of the features available using this type:
- Embed Transformers within the endpoint
- Embed Splitters within the endpoint
- Embed Aggregators within the endpoint
- Embed Filters within the endpoint
- Embed Customer Message Processors within the endpoint
- Embed Security Filters within the endpoint
- Use of Global Configuration Reference
There are two different types of endpoints:
- http:inbound-endpoint – For listening to incoming requests
- http:outbound-endpoint – For sending data to other http(s) service
Although the endpoints are different for listening/sending data, the connector configuration remains the same. The endpoints hold values for host/port and the connector configuration doesn’t need to know about this. This helps while sharing the same connector configuration with inbound and outbound endpoints.
To me, this is one important difference with the Operation-based connector as in the operation-based connector, the connector configuration cannot be shared and would need you to create two different connector configurations for listening and sending data.
Below is sample configuration for a simple flow built with mule runtime 3.5. Note that both inbound and outbound endpoints are using the same connector configuration
[xml]<http:connector name="HTTP_HTTPS" cookieSpec="netscape" validateConnections="true" sendBufferSize="0" receiveBufferSize="0" receiveBacklog="0" clientSoTimeout="10000" serverSoTimeout="10000" socketSoLinger="0" doc:name="HTTP-HTTPS"/>
<flow name="http35Flow">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" connector-ref="HTTP_HTTPS" doc:name="HTTP"/>
<http:outbound-endpoint exchange-pattern="request-response" host="differenthost" port="8082" connector-ref="HTTP_HTTPS" method="POST" doc:name="HTTP"/>
</flow>
Operation-based Connector
For Mule 3.6 and above the HTTP endpoint based connector configuration is deprecated and a new Operation based connector is introduced. This looses some of the abilities like embedding transformers within the connector. However, it adds some of the other features not available in endpoint based connector like ability to auto throw exceptions based on status code, adding headers and response settings.
There are two different types of connectors required for sending and receiving data
- http:listener – For listening to incoming requests
- http:request – For sending data to other http(s) service
In this case, we can’t share the same connector configuration between the listener and request connectors. Also, the connector configurations hold control on host, port unlike the endpoint based connectors. Connector configuration controlling the host/port has pros and cons as although it gives a clear separation, it now forces the user to create different connector configurations for each request call being made. This is little annoying as now you can’t place all the request connector configurations within domains as you no longer will be truly sharing the configuration.
Below is a sample application built with mule runtime 3.6. Notice how the http:listener and http:request connectors are using two different connector configurations and also the connector configuration specifying the host/port values:
[xml]<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<http:request-config name="HTTP_Request_Configuration" host="anotherhost" port="8082" doc:name="HTTP Request Configuration"/>
<flow name="http36flow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<http:request config-ref="HTTP_Request_Configuration" path="/" method="POST" doc:name="HTTP"/>
</flow>
Please refer to below links for complete set of properties available for these two connector types:
Old Connector: https://docs.mulesoft.com/mule-user-guide/v/3.7/http-connector-deprecated
New Connector: https://docs.mulesoft.com/mule-user-guide/v/3.7/http-connector