Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring integration 从Spring XD源轮询JMS队列以进行限制_Spring Integration_Spring Jms_Throttling_Spring Xd - Fatal编程技术网

Spring integration 从Spring XD源轮询JMS队列以进行限制

Spring integration 从Spring XD源轮询JMS队列以进行限制,spring-integration,spring-jms,throttling,spring-xd,Spring Integration,Spring Jms,Throttling,Spring Xd,我正在尝试使用XDJMS源从activeMq队列读取数据并记录它。 我的要求是只在特定的时间间隔读取队列,尝试实现节流。我需要我的流每秒只处理1条消息,队列中可能有任何速率的消息,即每秒20条消息等 现成的JMS源代码实现了消息驱动的通道适配器,它可以立即从队列中读取数据。 因此,我创建了一个自定义模块(polledJms),其中包含以下内容: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi=

我正在尝试使用XDJMS源从activeMq队列读取数据并记录它。 我的要求是只在特定的时间间隔读取队列,尝试实现节流。我需要我的流每秒只处理1条消息,队列中可能有任何速率的消息,即每秒20条消息等

现成的JMS源代码实现了消息驱动的通道适配器,它可以立即从队列中读取数据。 因此,我创建了一个自定义模块(
polledJms
),其中包含以下内容:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:int="http://www.springframework.org/schema/integration"
    xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
            http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
    <import resource="../../../common/jms-${provider}-infrastructure-context.xml"/>
    <int:channel id="output"/>
    <int-jms:inbound-channel-adapter id="jmsPolledSource"
            channel="output"
            destination-name="${destination}"
            connection-factory="connectionFactory">
    <int:poller fixed-rate="5000"/>
    </int-jms:inbound-channel-adapter>
我甚至尝试了xml中的cron表达式,而不是固定速率,在轮询器中每隔10秒读取一次,仍然可以看到相同的行为

我的自定义模块是在JMS队列上实现节流的正确方法,还是XD提供了一种开箱即用的功能,而我忽略了这一点。请提供帮助。

具有
max messages per poll
选项,默认情况下该选项为
Integer.MIN\u VALUE
,意思是“在消息源中读取消息”

从另一个角度看,固定费率意味着“在上一次开始之后,在该时间之后启动一个新的轮询任务”

为了使它“可延迟”,你应该考虑使用<代码>固定延迟< /代码>。在这种情况下,新的轮询任务将仅在前一个任务完成后的这段时间内启动

否则,您的自定义模块看起来不错

从另一方面,您甚至可以在
outputChannel
前面配置一个现有的
jms
源代码

更新

固定延迟
表示:
在前一个轮询任务完成后的一段时间内启动新的轮询任务
。由于轮询器读取消息并将其发送到同一
线程中的通道
,因此应为
轮询任务持续时间
添加消息处理时间。因为轮询线程正忙。因此,是的:您的邮件可能不会每秒被轮询


另一方面(使用
固定速率
),您应该记住Spring Integration默认使用
TaskScheduler
10
池大小。您可以使用
META-INF/spring.integration.properties
spring.integraton.taskScheduler.poolSize
属性来更改它。如果队列中有
100
条消息,并且
10条
固定速率的并发线程
。我改为
,在q上发送了100条信息。我希望每秒阅读1条消息,但没有看到它发生。我不太清楚poller是如何工作的。我的理解是,如果我有
,它将每1秒获取一条消息,但这似乎没有发生。你能给我指出正确的方向吗?给我的答案增加了更多的解释
"polledJms --destination=readQ | log"