gpt4 book ai didi

java - Spring集成-入站 channel 适配器是多线程的吗?

转载 作者:太空宇宙 更新时间:2023-11-04 07:52:53 25 4
gpt4 key购买 nike

我有以下 spring-integration 配置 v1.0.4。

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mail="http://www.springframework.org/schema/integration/mail"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/integration/mail
http://www.springframework.org/schema/integration/mail/spring-integration-mail-2.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd">


<util:properties id="javaMailProperties">
<prop key="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
<prop key="mail.imap.socketFactory.fallback">false</prop>
<prop key="mail.store.protocol">imaps</prop>
<prop key="mail.debug">false</prop>
</util:properties>

<mail:inbound-channel-adapter id="imapAdapter"
store-uri="imaps://user:pass@domain:993/inbox"
channel="recieveEmailChannel"
auto-startup="true"
java-mail-properties="javaMailProperties">
<int:poller>
<int:interval-trigger initial-delay="1000" interval="2000"
fixed-rate="true"/>
</int:poller>
</mail:inbound-channel-adapter>

<int:channel id="recieveEmailChannel">
<int:interceptors>
<int:wire-tap channel="logger"/>
</int:interceptors>
</int:channel>

<int:logging-channel-adapter id="logger" level="DEBUG"/>

<int:service-activator input-channel="recieveEmailChannel" ref="emailReceiverService" method="receive"/>

<bean id="emailReceiverService" class="com.mycompany.DefaultEmailReceiverUtilService">
</bean>

默认EmailReceiverUtilService

public class DefaultEmailReceiverUtilService implements
EmailReceiverUtilService
{

public void receive(Message<?> message)
{
//Processing the emails
}
}

问题:

  1. 它是多线程的吗?或者电子邮件将以串行方式处理?如果是,那么如何使其成为多线程?
  2. 当我的应用程序在 Eclipse Debug模式下运行时,我可以看到一些计时器任务线程,但每个请求都以顺序方式发送到同一计时器任务,而且我的线程(计时器任务)数量也在稳步增长。我可能会误解它。

如有错误,请指正。

最佳答案

我认为你需要的是一个队列 channel 。您的 receiveEmailChannel 应该类似于:

<int:channel id="recieveEmailChannel">  
<int:queue/>
<int:interceptors>
<int:wire-tap channel="logger"/>
</int:interceptors>
</int:channel>

我相信您会知道如何定义队列 channel 。您当前拥有的点对点 channel 是同步的,一次只能传递 1 条消息。

目前,如果您要向该 channel 添加某些内容,它将等待服务激活器完成,而使用队列 channel 时,服务激活器应在检测到队列中的某些内容后立即启动一个新线程。

关于java - Spring集成-入站 channel 适配器是多线程的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14140342/

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