Publishing and Subscribing with BackplanesBackplanes provide a way to 'publish' data under a name, enabling other parts of the system to 'subscribe' to it on the fly, without having to know about the actual component(s) the data is coming from. It is a quick and easy way to distribute or share data. Think of them like backplane circuit boards - where other circuit boards can plug in to send or receive any signals they need. Example usageA system where several producers publish data, for consumers to pick up: Pipeline( Producer1(), PublishTo("DATA") ).activate() Pipeline( Producer2(), PublishTo("DATA") ).activate() Pipeline( SubscribeTo("DATA"), Consumer1(), ).activate() Pipeline( SubscribeTo("DATA"), Consumer2(), ).activate() Backplane("DATA").run() A server where multiple clients can connect and they all get sent the same data at the same time: Pipeline( Producer(), PublishTo("DATA") ).activate() SimpleServer(protocol=SubscribeTo("DATA"), port=1500).activate() Backplane("DATA").run() More detailThe Backplane component collects data from publishers and sends it out to subscribers. You can have as many backplanes as you like in a running system - provided they all register under different names. A backplane can have multiple subscribers and multiple publishers. Publishers and subscribers can be created and destroyed on the fly. To shut down a PublishTo() component, send a producerFinished() or shutdownMicroprocess() message to its "control" inbox. This does not propagate and therefore does not cause the Backplane or any subscribers to terminate. To shut down a SubscribeTo() component, send a producerFinished() or shutdownMicroprocess() message to its "control" inbox. It will then immediately forward the mesage on out of its "signal" outbox and terminate. To shut down the Backplane itself, send a producerFinished() or shutdownMicroprocess() message to its "control" inbox. It will then immediately terminate and also propagate this message onto any subscribers (SubscribeTo components), causing them to also terminate. Implementation detailsBackplane is actually based on a Kamaelia.Util.Splitter.PlugSplitter component, and the SubscribeTo component is a wrapper around a Kamaelia.Util.Splitter.Plug. The Backplane registers itself with the coordinating assistant tracker.
PublishTo components look up the "Backplane_I_<name>" service and simply forward data sent to their "inbox" inboxes direct to the "inbox" inbox of the PlugSplitter - causing it to be distributed to all subscribers. SubscribeTo components look up the "Backplane_O_<name>" service and request to have their "inbox" and "control" inboxes connected to the PlugSplitter. SubscribeTo then forwards on any messages it receives out of its "outbox" and "signal" outboxes respectively. The PlugSplitter component's "control" inbox and "signal" outbox are not advertised as services. To shut down a Backplane you must therefore send a shutdownMicroprocess() or producerFinished() message directly to its "control" inbox. When this happens, the shutdown message will be forwarded on to all subscribers - causing SubscribeTo components to also shut down. Kamaelia.Util.Backplane.Backplaneclass Backplane(Axon.Component.component)Backplane(name) -> new Backplane component. A named backplane to which data can be published for subscribers to pick up.
Keyword arguments:
Inboxes
Outboxes
Methods defined hereWarning! You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers. childrenDone(self)Unplugs any children that have terminated, and returns true if there are no running child components left (ie. their microproceses have finished) main(self)Main loop. Kamaelia.Util.Backplane.PublishToclass PublishTo(Axon.Component.component)PublishTo(destination) -> new PublishTo component Publishes data to a named Backplane. Any data sent to the "inbox" inbox is sent to all (any) subscribers to the same named Backplane. Keyword arguments:
Inboxes
Outboxes
Methods defined hereWarning! You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers. main(self)Main loop. Kamaelia.Util.Backplane.SubscribeToclass SubscribeTo(Axon.Component.component)SubscribeTo(source) -> new SubscribeTo component Subscribes to a named Backplane. Receives any data published to that backplane and sends it on out of its "outbox" outbox. Keyword arguments:
Inboxes
Outboxes
Methods defined hereWarning! You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers. childrenDone(self)Unplugs any children that have terminated, and returns true if there are no running child components left (ie. their microproceses have finished) main(self)Main loop. FeedbackGot a problem with the documentation? Something unclear that could be clearer? Want to help improve it? Constructive criticism is very welcome - especially if you can suggest a better rewording! Please leave you feedback here in reply to the documentation thread in the Kamaelia blog. -- Automatic documentation generator, 05 Jun 2009 at 03:01:38 UTC/GMT |
Kamaelia
is an open source project originated from and guided by BBC
Research. For more information browse the site or get in
contact.
This is an ongoing community based development site. As a result the contents of this page is the opinions of the contributors of the pages involved not the organisations involved. Specificially, this page may contain personal views which are not the views of the BBC. (the site is powered by a wiki engine)
(C) Copyright 2008 Kamaelia Contributors, including the British Broadcasting Corporation, All Rights Reserved.