gpt4 book ai didi

java - 内部 http :inbound-gateway with pollable request channel

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:20:48 25 4
gpt4 key购买 nike

我正在查看一些基于 spring 集成的代码,我注意到所有 int-http:inbound-gateways 都使用可轮询的请求 channel :

<int-http:inbound-gateway id="someId"
request-channel="queue-channel"
reply-channel="reply-channel"
request-payload-type="java.lang.String"
supported-methods="POST"
path="/rest/notifications"
auto-startup="true" />

<int:channel id="queue-channel" datatype="java.lang.String">
<int:queue capacity="100" />
</int:channel>

在配置中指定了一个显式轮询器:

<int:poller id="mainSystemPoller" default="true" fixed-delay="500" max-messages-per-poll="1">
<int:transactional transaction-manager="transactionManager" propagation="REQUIRES_NEW" isolation="DEFAULT"/>
</int:poller>

因此,流上游的第一个 channel 是可轮询的。使用这种方法有什么好处?它是否只是让我们在业务流程(事务配置、队列容量等)方面具有更大的灵 active ?

最佳答案

如果没有事务配置,那么在那里使用轮询器几乎没有任何值(value),因为 http 线程无论如何都会在网关中等待回复。

但是,在您的情况下,它将启动事务并导致网关下游的所有内容都在事务中运行。但是,按照配置,这将单线程处理您的请求;您需要一个任务执行器来处理多个并发请求。

还有其他方法可以在事务中运行并发 Web 请求;您可以改用事务网关,然后流程将在 Web 容器线程上运行,并发性由您的 Web 容器管理。

关于java - 内部 http :inbound-gateway with pollable request channel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29599212/

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