Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #39115
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: read messages that are both async & sync from one inputstream |
| Date | 2019-08-20 13:17 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <qjha03$ke7$1@dont-email.me> (permalink) |
| References | <e601f9ed-292b-4494-b6b3-0f32d6269c79@googlegroups.com> |
On 8/20/2019 11:35 AM, 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?
Could you please try to describe your problem more precisely?
Some points that are confusing (to me, at least):
- What does "synchronous" mean? Ordinarily it means that the
timing or occurrence of each event is "synchronized" with one or
more other events: A speaks while B listens, then B speaks while A
listens, that sort of thing. But what does "synchronous" mean to you?
- Similarly for "asynchronous," which usually means that an event's
occurrence or timing is not influenced by other (visible) events. For
example, maybe C interrupts out of the blue while A and B are calmly
taking turns; C's message would be "asynchronous" to those of A and B.
But what do you mean by the term?
- What is a "read/write message?" I am not NETCONF-schooled, but
from the Wikipedia description it appears that each message carries a
complete XML document. Do you modify the document and send it back to
its origin, or what? And why is this "read/write" cycle any different
from any other "read/reply?"
- What do you mean by "running in separate threads?" I can easily
see that there could be many transmitting threads, but if there's more
than one receiver it's hard to imagine how confusion is avoidable. (In
a traditionally-synchronous protocol it might be possible to "know"
which kind of message will be forthcoming next, but then you'd need some
way to "arm" the proper thread to receive it -- this sounds sort of like
the "mess" you want to avoid, and would be completely unable to handle
traditionally-asynchronous utterances.)
Perhaps (only "perhaps!") what you need is a single receiver that
catches *all* incoming messages, decides what type they are, and stuffs
each onto a type-appropriate queue for the other threads to process.
Yes, this involves you in "multiple thread sync," but there's very
little "mess" to worry about. If that's not helpful, please give more
detail.
--
esosman@comcast-dot-net.invalid
Five hundred nineteen days to go.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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