1.Endpoint简介
Endpoints are used to connect services. An endpoint is a specific channel on which a service can send messages and from which another service
can receive messages. For example, a purchasing component may receive an order request over HTTP. Once the order has been processed by
the component, a JMS message may be sent over a topic to notify an auditing system, and a response can be sent back over HTTP.
2.配置
(1)基本配置
<inbound-endpoint address="udp://localhost:65432"/>
<jetty:inbound-endpoint address="http://localhost:60211/mycomponent1" exchange-pattern=
"request-response" />
<outbound-endpoint address="smtp://user:secret@smtp.host"/>
<inbound-endpoint address="jms://test.queue"/>
(2).带transpor定义的endpoint配置
<file:inbound-endpoint path="./.mule/in"
comparator="org.mule.transport.file.comparator.OlderFirstComparator" reverseOrder="true"/>
<ssl:endpoint name="clientEndpoint" host="localhost" port="60198"/>
<jetty:endpoint name="serverEndpoint" host="localhost" port="60203" path="services/Foo" />
<imaps:endpoint name="global1s" host="localhost" password="secret" port="123" user="bob"/>
<rmi:endpoint name="BadType" host="localhost" port="1099" object="MatchingUMO" method="reverseString"
/>
<quartz:endpoint name="qEP6" repeatCount="10" repeatInterval="1000" jobName="job"/>
<jms:inbound-endpoint queue="test.queue"/>
(3).动态endpoint(endpoint的值可以用变量)
<outbound-endpoint address="smtp://user:secret@#[header:OUTBOUND:host]"/>
<http:outbound-endpoint host="localhost" port="#[header:INBOUND:portNumber]" path="orderService"/>
<jms:outbound-endpoint host="localhost" queue="#[mule:registry.defaultJmsQueue]"/>
(4).引用connector
<inbound-endpoint address="tcp://localhost:65432" connector-ref="tcpConnector1"/>
<tcp:inbound-endpoint host="localhost" port="65433" connector-ref="tcpConnector2"/>
transport-specific endpoints are used. It is also possible to specify a non-standard property
<!-- Standard properties -->
<quartz:endpoint name="qEP6" repeatCount="10" repeatInterval="1000" jobName="job"/>
<!-- Non-standard properties -->
<quartz:endpoint name="qEP7" jobName="job2">
<property key="actionOnTimeout" value="self-destruct"/>
<property key="precision" value="2.5"/>
</quartz:endpoint>
By default, endpoints are one-way; that is, they accept (or send) messages, but do not return (or receive) responses to those messages. To set
an endpoint to wait for a response, you set exchange-pattern="request-response". This setting is not required by HTTP/S, SSL, TCP,
and Servlet endpoints, which are request-response by default
(7).transaction 事务
<jms:inbound-endpoint queue="in">
<jms:transaction action="BEGIN_OR_JOIN"/>
</jms:inbound-endpoint>
(8).Encoding 编码
<inbound-endpoint address="tcp://localhost:65432" encoding="iso-8859-1"/>
(9).MimeType
<inbound-endpoint address="tcp://localhost:65432" mimeType="text/xml"/>
(10).transformers 转换器
As will all message processors configured on endpoints, the order in which they are configured is the order in which they are executed.
<inbound-endpoint address="file://./test-data/in" transformer-refs="globalTransformer1
globalTransformer2" responseTransformer-refs="globalTransformer2"/>
(11).Filter 过滤器
<jms:endpoint queue="in.queue">
<jms:selector expression="JMSPriority > 5"/>
</jms:endpoint>
<vm:endpoint name="fruitBowlEndpoint" path="fruitBowlPublishQ">
<message-property-filter pattern="foo=bar"/>
</vm:endpoint>
(12).Inbound Routers 入口路由器
<service name="Receiver">
<inbound>
<vm:inbound-endpoint path="inbound.channel"/>
<wire-tap-router>
<vm:outbound-endpoint path="tapped.channel"/>
</wire-tap-router>
</inbound>
<component class="com.acme.SomeService"/>
</service>
(13).Outbound Routers 出口路由器
<service name="MessageChunker">
<inbound>
<jms:inbound-endpoint queue="big.messages"/>
</inbound>
<outbound>
<message-chunking-router messageSize="10">
<jms:outbound-endpoint queue="small.chunks"/>
</message-chunking-router>
</outbound>
</service>
<service name="LenderGatewayService">
<inbound>
<inbound-endpoint ref="LenderGateway" />
</inbound>
<outbound>
<chaining-router>
<outbound-endpoint ref="LenderService" />
<outbound-endpoint ref="BankingGateway" transformer-refs="SetLendersAsRecipients
ObjectToJMSMessage" />
</chaining-router>
</outbound>
</service>
(14).Services 服务
<service name="Echo">
<inbound>
<!-- Inbound router is implicit -->
<stdio:inbound-endpoint system="IN"/>
</inbound>
<echo-component/>
<outbound>
<!-- Outbound router is explicit -->
<pass-through-router>
<stdio:outbound-endpoint system="OUT"/>
</pass-through-router>
</outbound>
</service>
(15).Catch-all Strategies
A single "catch-all" endpoint can be configured for certain types of routers. See Catch-all Strategies.
<service name="dataService">
<inbound>
<inbound-endpoint ref="dataIn">
<payload-type-filter expectedType="java.lang.String"/>
</inbound-endpoint>
<forwarding-catch-all-strategy>
<jms:outbound-endpoint queue="error.queue"/>
</forwarding-catch-all-strategy>
</inbound>
...cut...
</service>
(16).Exception Strategies 异常策略
<service name="dataService">
<inbound>
...cut...
</inbound>
<component class="com.acme.DataProcessor"/>
<outbound>
...cut...
</outbound>
<default-service-exception-strategy>
<jms:outbound-endpoint queue="error.queue"/>
</default-service-exception-strategy>
</service>
以上内容摘自 Mule ESB Guide.pdf Configuring Endpoints 这一章节.