有没有办法使用Mule的HttpPollingConnector轮询多个地址?



我正在尝试使用Mule中的http轮询连接器从包含所有这些地址的列表中轮询多个地址(URL链接)。目前,我只能从一个地址进行轮询,但我想找到一种方法来使用此列表来迭代每个站点的轮询。Mule 中内置了什么东西可以提供这样的功能吗?

复合源是你要找的吗?它允许您在入站中拥有多个终结点。

例如,来自 http://www.mulesoft.org/documentation-3.2/display/32X/Bookstore+Example

<flow name="CatalogService">
    <composite-source>
        <!-- Public interface -->
        <inbound-endpoint address="http://0.0.0.0:8777/services/catalog" exchange-pattern="request-response">
            <cxf:jaxws-service serviceClass="org.mule.example.bookstore.CatalogService" />
        </inbound-endpoint>
        <!-- Administration interface -->
        <inbound-endpoint address="servlet://catalog" exchange-pattern="request-response">
            <!-- Convert request parameters to Book object -->
            <custom-transformer class="org.mule.example.bookstore.transformers.HttpRequestToBook" />
            <response>
                <!-- Format response to be a nice HTML page -->
                <custom-transformer class="org.mule.example.bookstore.transformers.AddBookResponse" />
                <!-- Force text/html, otherwise it falls back to request 
                    props, which have form-encoded one -->
                <transformer ref="setHtmlContentType" />
            </response>
        </inbound-endpoint>
    </composite-source>
    ....

编辑:

下面是一个简单的示例:

<flow name="foreachFlow1" doc:name="foreachFlow1">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
    <foreach collection="#[groovy:['localhost:8082', 'localhost:8083']]" doc:name="For Each">
        <http:outbound-endpoint exchange-pattern="request-response" address="http://#[payload]" method="GET" doc:name="HTTP"/>
    </foreach>
</flow>
<flow name="foreachFlow2" doc:name="foreachFlow2">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" doc:name="HTTP"/>
    <logger message="in flow2" level="INFO"/>
</flow>
<flow name="foreachFlow3" doc:name="foreachFlow3">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8083" doc:name="HTTP"/>
    <logger message="in flow3" level="INFO"/>
</flow>

基本上,"棘手"的部分是弄清楚有效负载成为您正在迭代的集合中的当前项(文档在指出这一点方面做得非常出色......好吧,至少如果你喜欢钓鱼:P)。

相关内容

  • 没有找到相关文章

最新更新