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

标签 http mule polling mule-studio

我正在尝试使用 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>
    ....

编辑:

下面是一个简单的 foreach 例子:

<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).

关于http - 有没有办法使用 Mule 的 HttpPollingConnector 轮询多个地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18970495/

相关文章:

java - 如何使用 MULE ESB 将邮件附件传递给 POJO 对象

iphone - NSTimer - 创建了多个实例

php - PHP 如何优雅地关闭本地套接字连接...?

http - ajax.microsoft.com 与 cdn 的无 cookie 域

AngularJS $http.post() 到同一台机器上的另一个端口

http - 应用程序如何在不与浏览器冲突的情况下使用端口 80/HTTP?

mule - DataWeave 组件中的条件检查

java - Maven 着色 "Project main artifact doesnt exist"

c - 如何从另一个线程调用 Gtk API?

java - iPad/iPhone 上的 HTTP 字节范围协议(protocol)客户端行为