users@websocket-spec.java.net

[jsr356-users] [jsr356-experts] Re: Concurrency questions

From: Mark Thomas <mark_at_homeinbox.net>
Date: Mon, 04 Feb 2013 10:42:41 +0000

On 04/02/2013 01:35, Danny Coward wrote:
> On 1/29/13 1:42 AM, Mark Thomas wrote:
>> All,
>>
>> As a side-effect of grappling with why some of my unit tests are failing
>> I have been thinking about concurrency issues around message sending and
>> have the following questions.
>>
>> 1) If an application sends a message using a Future or a SendHandler, is
>> it permitted to send a second message before the first has completed?
>> My current thinking is that this should not be permitted and an
>> IllegalStateException be thrown
>> My reasoning for this is that was allowed it would open up all sorts of
>> buffering requirements for the container that could get tricky to manage.
> Going back to this one, would you say the same thing if you tried to
> send a second message while you were in the middle of sending a first
> one in pieces ? For the same reason ?
>
> i.e.
>
> sendPartialString("inter", false); // not done
> sendPartialString("rupti", false); // not done
> sendString(" cow !"); <- throws IllegalStateException ?
> sendPartialString("ng ", true);
>
> Ditto for scnearios around the IO stream writers too ?

Yes. I think one message needs to finish before you try sending the next.

Mark