gpt4 book ai didi

java - 过滤可轮询 channel

转载 作者:行者123 更新时间:2023-11-30 08:16:10 24 4
gpt4 key购买 nike

我有一个可轮询 channel 和其下游的过滤器。是否可以使用过滤器轮询此类 channel ,或者我应该在两者之间使用一些中间组件(我检查了服务激活器。它至少可以接受可轮询 channel ,但也许有更好的选择,例如某些网关):

    <task:executor id="task-executor" pool-size="10" queue-capacity="100"/>

<int:channel id="inputChannel">
<int:queue capacity="100" />
</int:channel>

<!--The filter is never triggered. The flow goes from input-channel preSend fight to its postSend-->
<int:filter id="mailFilter" input-channel="inputChannel"
output-channel="outputChannel" expression="@mailFilter.acceptMail(payload)"
auto-startup="true" discard-channel="error-handler">
<int:poller task-executor='task-executor' fixed-delay='500'>
</int:poller>
</int:filter>

最佳答案

当然,后发送紧接在预发送之后 - 将消息转储到队列中的速度非常快。

过滤器是在任务执行器线程而不是发送线程上调用的。

您将看到 preReceive 日志(处于 TRACE 级别)和 postReceive 处于 DEBUG 级别。

编辑:

我刚刚进行了测试,没有任何问题...

<int:channel id="foo">
<int:queue/>
</int:channel>

<int:filter input-channel="foo" output-channel="toRabbit" expression="true">
<int:poller fixed-delay="2000" />
</int:filter>


10:29:53.792 TRACE [task-scheduler-1][org.springframework.integration.channel.QueueChannel] preReceive on channel 'foo'
10:29:53.795 DEBUG [task-scheduler-4][org.springframework.integration.endpoint.SourcePollingChannelAdapter] Poll resulted in Message: [Payload String content=xxx][Headers={id=9b5bf399-a137-daec-58bd-7cf7216d3dfc, timestamp=1429090193794}]
10:29:53.795 DEBUG [task-scheduler-4][org.springframework.integration.channel.QueueChannel] preSend on channel 'foo', message: [Payload String content=xxx][Headers={id=9b5bf399-a137-daec-58bd-7cf7216d3dfc, timestamp=1429090193794}]
10:29:53.795 DEBUG [task-scheduler-4][org.springframework.integration.channel.QueueChannel] postSend (sent=true) on channel 'foo', message: [Payload String content=xxx][Headers={id=9b5bf399-a137-daec-58bd-7cf7216d3dfc, timestamp=1429090193794}]
10:29:53.795 DEBUG [task-scheduler-1][org.springframework.integration.channel.QueueChannel] postReceive on channel 'foo', message: [Payload String content=xxx][Headers={id=9b5bf399-a137-daec-58bd-7cf7216d3dfc, timestamp=1429090193794}]
10:29:53.795 DEBUG [task-scheduler-1][org.springframework.integration.endpoint.PollingConsumer] Poll resulted in Message: [Payload String content=xxx][Headers={id=9b5bf399-a137-daec-58bd-7cf7216d3dfc, timestamp=1429090193794}]
10:29:53.796 DEBUG [task-scheduler-1][org.springframework.integration.filter.MessageFilter] org.springframework.integration.filter.MessageFilter@2ecd0256 received message: [Payload String content=xxx][Headers={id=9b5bf399-a137-daec-58bd-7cf7216d3dfc, timestamp=1429090193794}]

关于java - 过滤可轮询 channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29643776/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com