[Embedlets-dev] [arch] JavaOS event model -> pub/sub & peer-to-peer
Status: Alpha
Brought to you by:
tkosan
|
From: Ted K. <tk...@ya...> - 2003-02-22 08:31:52
|
Andrzej stated:
>One of the beauties of pub/sub is the publisher usually doesn't
>care who is getting the events (decoupled messages), which defines
>"filtering" from the perspective of the consumer only (all the
>producer does is "tag" the message with properties that consumers
>might want to use for filtering purposes). This provides for a
>very dynamic, self-configurable, and easily extensible environment
>(eg. to add logging of a particular event type, you just drop in a
>logging Embedlet that registers interest in receiving that particular
>event, and the producer neither cares nor knows that a new consumer
>was added). But there are situations (maybe for security reasons)
>that the producer might want to specify what consumers are eligible
>to receive a particular event. Or maybe we'll need filtering at
>both consumer and producer ends.
I have not yet been able to get my mind around the concept of a 100%
publish/subscribe system. For example, lets say that one has a toggle switch
hooked up to a JAPL input bit and then there is an Embedlet which holds a
reference to this JAPL peripheral and it polls it once per second.
If the Embedlet produces SwitchEvents, does this mean that every other Embedlet
in the application that consumes SwitchEvents will be forced to subscribe to
this event source?
What if one had 10 JAPL input bits that were being polled by 10 Embedlets which
all generated SwitchEvents? Would all SwitchEvent consumers in the application
be forced to subscribe to all of these event sources?
JavaOS uses a publish/subscribe event model, but it also includes peer-to-peer
event capabilities in order to solve this problem. Here is an excerpt from
'Inside the JavaOS Operating System' that talks about this:
Suppose that an event consumer wants to receive events from one or more
specific producers. In other words, the consumer does not want to register to
receive events by type, it wants to receive events from particular producers.
To find a registered producer from which to receive events, the consumer class
retrieves an OSEventProducerEnumerator object from the event manager by calling
the producers() method. Next, the consumer calls the nextElement() method of
this class to retrieve a reference to each producer object in the list. When
the consumer locates the producer it wants to work with, it calls the static
connectConsumer() method in OSEventProducer with a reference to the producer
object. The consumer then will receive events from that producer alone. The
consumer can specify whether it wants to be the exclusive consumer of events
from that producer. Again, this is useful for security reasons.
In a similar fashion, a registered consumer can be located by first
retrieving [snip]
Oh heck, here is the complete events chapter:
http://tkosan.javadevices.org/misc/embeddedjava/JavaOS_Events.html
There is so much good material here related to what we are doing that I suppose
one can not do it justice by just copying 'sound bites' from it.
I especially like the following sections:
3.3.2 Producer Classes
3.4.3 Peer-to-Peer Registration
3.5 Bidirectional Events
Ted
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/
|