spring2.5 javamailsender锁定在javax.mail.service.connect中

时间:2013-09-10 08:30:47

标签: java multithreading spring email

我用spring 2.5 JavaMailSenderImpl发送邮件。当我发送超过10,000封邮件时,我的程序被阻止了。这是jstack显示的线程信息:

"pool-4-thread-6" prio=10 tid=0x000000001b94d800 nid=0x44fb runnable    [0x0000000041901000] 
   java.lang.Thread.State: RUNNABLE 
        at java.net.SocketInputStream.socketRead0(Native Method) 
        at java.net.SocketInputStream.read(SocketInputStream.java:150) 
        at java.net.SocketInputStream.read(SocketInputStream.java:121) 
        at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:97) 
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:235) 
        at java.io.BufferedInputStream.read(BufferedInputStream.java:254) 
        - **locked** <0x00000000e6e2d170> (a java.io.BufferedInputStream) 
        at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:75) 
        at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1440) 
        at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1260) 
        at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370) 
        at javax.mail.Service.connect(Service.java:275) 
        at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.ja 
va:389)  
        at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java 
:342) 
        at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java 
:338) 

也许这个程序被阻止了邮件连接,但我在spring配置文件中部署了out-time:

    <property name ="javaMailProperties"> 
                 <props> 
                 <prop key="mail.smtp.connectiontimeout">25000</prop>   
                <prop key="mail.smtp.timeout">25000</prop> 
             </props> 
</property > 

程序应该在时间超过时抛出异常。但它仍然会被阻止!! 谁知道原因?

1 个答案:

答案 0 :(得分:0)

我认为,也可能是因为SMTP服务器的限制。为防止发送垃圾邮件,许多SMTP服务器允许在给定时间范围内发送有限的电子邮件。

在这种情况下,流程可能只是等待并且看起来被阻止。检查您的SMTP管理员是否存在这些限制。