有没有办法使用Mule的HttpPollingConnector轮询几个地址? [英] Is there a way to poll several addresses using Mule's HttpPollingConnector?

查看:179
本文介绍了有没有办法使用Mule的HttpPollingConnector轮询几个地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to poll several addresses (URL links) from a list that contains all these addresses using the http polling connector in Mule. Currently, I am only able to poll from one address but I would like to find a way to use this list to iterate the polling for each site. Is there anything built within Mule that provides such function?

推荐答案

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

Is composite source what you're looking for? It allows you to have more than one endpoint in the inbound.

例如。来自 http://www.mulesoft.org/documentation-3.2/display/ 32X /书店+示例

<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示例:

The following is a simple foreach example:

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

Basically, the 'tricky' part is to figure out that the payload becomes the current item in the collection you're iterating over (the docs do a wonderful job at pointing that out... well at least if you're into fishing :P).

这篇关于有没有办法使用Mule的HttpPollingConnector轮询几个地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆