簡體   English   中英

Spring集成-入站通道適配器是多線程的嗎?

[英]Is Spring integration - inbound channel adapter multithreaded?

我具有以下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>

DefaultEmailReceiverUtilService

public class DefaultEmailReceiverUtilService implements
        EmailReceiverUtilService
{

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

題:

  1. 是多線程的嗎? 還是將以串行方式處理電子郵件? 如果是,那么如何使其成為多線程?
  2. 當我的應用程序以eclipse調試模式運行時,我可以看到一些Timer任務線程,但是每個請求都以順序的方式進入同一計時器任務,而且我的線程數(Timer任務)也在穩步增長。 我可能會誤解它。

如果我錯了,請糾正我。

我認為您需要的是隊列通道。 您的receiveEmailChannel應該類似於:

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

我確定您將知道如何定義隊列通道。 當前正在同步的點對點通道,一次只能傳遞1條消息。

當前,如果您要向該通道添加某些內容,它將等待服務激活器完成,而使用隊列通道時,服務激活器應在檢測到隊列中的某些內容時立即觸發新線程。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM