【问题标题】:int-http:inbound-gateway with pollable request channel具有可轮询请求通道的 int-http:inbound-gateway
【发布时间】:2015-04-13 06:39:24
【问题描述】:

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

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

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

【问题讨论】:

    标签: java spring-integration


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-21
      • 2023-04-08
      • 1970-01-01
      相关资源
      最近更新 更多