1

次のスプリング統合構成 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 デバッグ モードで実行されている場合、いくつかのタイマー タスク スレッドが表示されますが、各要求は同じタイマー タスクに順番に送信され、スレッド (タイマー タスク) の数も着実に増加しています。私はそれを誤解しているかもしれません。

間違っている場合は修正してください。

4

1 に答える 1

1

必要だと思うのは、キューチャネルです。receiveEmailChannel は次のようになります。

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

キュー チャネルを定義する方法を知っていると思います。現在持っているポイントツーポイントチャネルは同期的で、一度に 1 つのメッセージしか渡すことができません。

現在、そのチャネルに何かを追加すると、サービス アクティベーターが終了するまで待機しますが、キュー チャネルでは、サービス アクティベーターはキュー内で何かを検出するとすぐに新しいスレッドを起動する必要があります。

于 2013-01-03T14:19:19.050 に答える