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


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

Re: read messages that are both async & sync from one inputstream

Path csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: read messages that are both async & sync from one inputstream
Date Tue, 20 Aug 2019 19:58:09 +0200
Organization A noiseless patient Spider
Lines 26
Message-ID <qjhcbk$2d1$1@dont-email.me> (permalink)
References <e601f9ed-292b-4494-b6b3-0f32d6269c79@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
Injection-Date Tue, 20 Aug 2019 17:58:12 -0000 (UTC)
Injection-Info reader02.eternal-september.org; posting-host="b27f3dd73036fd99922345bcbda5483d"; logging-data="2465"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+g8eu5vTGBcx5Da1suUPmt"
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0
Cancel-Lock sha1:6knguyKFiRH1S21Q1xBmrbEUW/0=
In-Reply-To <e601f9ed-292b-4494-b6b3-0f32d6269c79@googlegroups.com>
X-Antivirus-Status Clean
Content-Language en-US
X-Antivirus AVG (VPS 190820-0, 08/20/2019), Outbound message
Xref csiph.com comp.lang.java.programmer:39116

Show key headers only | View raw


On 2019-08-20 17:35, mike wrote:
> Hi,
> 
> I have an application that sends/receives output from a product using NETCONF protocol. We basically have 3 types of messages:
> 
> 1. Configuration messages which is a write/read ( synchronous)
> 2. KeepAlive messages which is also a write/read ( synchronous ) Done every 10 seconds.
> 3. Notification messages from the product read-only ( asynchronous )
> 
> All of then are running in separate threads.
> 
> All output from product is read from an inputStream. The problem we are facing is that the notification messages are cut of for some reason. I can sometimes see that the KeepAlive read() gets the same message ( it checks the format of the message and decides it is not a KeepAlive response message but rather a notification. So looks like KeepAlive "eats" part of the message and then notification reader is reads what is left.
> 
> Any ideas of how to solve this without the mess of multiple thread sync?
> 
> //mike
> 

You can't read with multiple threads from the same InputStream.

And multiple thread sync is not a mess, it's art.

You need a single-threaded read + multi-threaded dispatch.

-- 
DF.

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


Thread

read messages that are both async & sync from one inputstream mike <mikaelpetterson@hotmail.com> - 2019-08-20 08:35 -0700
  Re: read messages that are both async & sync from one inputstream Eric Douglas <e.d.programmer@gmail.com> - 2019-08-20 08:53 -0700
  Re: read messages that are both async & sync from one inputstream Eric Sosman <esosman@comcast-dot-net.invalid> - 2019-08-20 13:17 -0400
  Re: read messages that are both async & sync from one inputstream Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2019-08-20 19:58 +0200
  Re: read messages that are both async & sync from one inputstream Eric Douglas <e.d.programmer@gmail.com> - 2019-08-20 11:04 -0700

csiph-web