gpt4 book ai didi

threadpool - 控制 Mule 中的线程数

转载 作者:行者123 更新时间:2023-12-02 00:08:37 25 4
gpt4 key购买 nike

我使用的是 Mule 3.3.1 社区版。

我有一个接受 HTTP 请求的流程。运行成功。

<flow name="TestFlow">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8088" path="test" doc:name="HTTP" mimeType="text/plain"
encoding="UTF-8"/>
<logger level="INFO" category="hello" doc:name="Logger"/>
</flow>

该服务需要是单线程的,以便严格按照接收消息的顺序处理消息。我的想法是设置 maxThreadsActive=1 和 maxBufferSize=100 以获得我想要的行为。但是,我无法控制线程的工作。

在这一点上,我只是试图让一个线程配置文件工作,而不考虑线程的数量。我在 Manning 书 Mule in Action 的当前版本中添加了一个线程配置文件,但 Mule 拒绝它作为“无效内容”并且不会运行。

<flow name="TestFlow">
<threading-profile maxBufferSize="100" maxThreadsActive="20" maxThreadsIdle="10"
threadTTL="60000" poolExhaustedAction="RUN" />

<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8088" path="test" doc:name="HTTP" mimeType="text/plain"
encoding="UTF-8"/>
<logger level="INFO" category="hello" doc:name="Logger"/>
</flow>

我将其注释掉并移至配置 block 。

<configuration>
<default-threading-profile maxThreadsActive="20" maxBufferSize="100"
poolExhaustedAction="RUN" />
</configuration>

<flow name="TestFlow">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8088" path="test" doc:name="HTTP" mimeType="text/plain"
encoding="UTF-8"/>
<logger level="INFO" category="hello" doc:name="Logger"/>
</flow>

Mule 接受了这个,但是服务不再返回;客户端只是挂起等待响应。

如何配置我的流以便我可以控制线程池大小,并且一旦完成,池中只有一个线程可用?

最佳答案

您需要配置 HTTP 连接器的 receiver-threading-profile:

<http:connector name="httpConnector">
<receiver-threading-profile maxThreadsActive="1" />
</http:connector>

关于threadpool - 控制 Mule 中的线程数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16822268/

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