Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #26433

Re: java mail and thread

From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.java.programmer
Subject Re: java mail and thread
Date 2013-10-26 13:07 +0200
Message-ID <bd1m45Fme69U1@mid.individual.net> (permalink)
References <6615a997-f18f-42b0-812e-de1cbadf8341@googlegroups.com> <1tainohfwpuj1.1v1jokfkdmezh.dlg@40tude.net>

Show all headers | View raw


On 25.10.2013 13:45, Joerg Meier wrote:
> On Thu, 24 Oct 2013 14:28:49 -0700 (PDT), andros976@gmail.com wrote:
>
>> I noticed that this statement takes a bit of seconds before releasing
>> flow and therefore are unable to use the other functions of the application . I thought , therefore, to use a technology where each object of the class that sends the email implements Runnable and then i use it like a thread.
>> I noticed , however, that there are problems because sometimes 20 over 50 emails fail and the instruction that give me the error is
>
>> Transport.send (msg ) ;
>
>> java.net.SocketException : Connection closed by remote host
>
> Possibly the remote server doesn't allow multiple (or more than 2 or 3)
> connections at the same time. I recommend writing a thread class that keeps
> an internal list of mails to send, and sends them one by one. That way,
> when you send two mails at the same time, the 2nd gets added to the list
> and sent after the first finishes, instead of at the same time.

Or create a thread pool with as many threads as concurrent connections 
are allowed.  Then feed send requests through a queue.

Cheers

	robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

java mail and thread andros976@gmail.com - 2013-10-24 14:28 -0700
  Re: java mail and thread Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2013-10-24 15:07 -0700
  Re: java mail and thread lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-10-25 12:30 +0100
  Re: java mail and thread Joerg Meier <joergmmeier@arcor.de> - 2013-10-25 13:45 +0200
    Re: java mail and thread Robert Klemme <shortcutter@googlemail.com> - 2013-10-26 13:07 +0200
    Re: java mail and thread andros976@gmail.com - 2013-10-27 01:46 -0700

csiph-web