Overview
The notification channel APIs provide developers with an easy-to-use,
high-performance, event-driven system in C++, Java, and Python. The API
is based on a push event channel model where event suppliers push
events onto the channel and event consumers process these
asynchronously. It is also a many-to-many publishing model whereby
multiple suppliers send events to multiple consumers on the same
channel. There are only two classes developers need to be concerned
with: SimpleSupplier and SimpleConsumer. SimpleSupplier was designed so
that events could be published in the simplest manner possible without
exposing any CORBA to the developer. Essentially all that needs to be
known is the channel’s name and the IDL structure being published. With
the SimpleConsumer class, the developer is responsible for providing
the channel’s name as well as associating event types with functions
that will handle them.
High-level Guide
- Determine whether or not the ACS event channel API is suitable
for your needs:
- Will more than one piece of code be interested in the data
being sent? If not, considering using Callbacks.
- Is the data being sent very large? If so, considering using
Bulk Data Transfer.
- Is the data being sent on a very low frequency? If so, considering using
normal CORBA client invocations.
- Define a struct in IDL to serve as your event. The name of this
struct should have "Event" appended to it.
- Determine the pre-existing channel (defined by a string) your
event should be published on or come up with a new channel name
defined as const string in IDL with "CHANNEL" appeneded to it.
-
To publish an event, instantiate an ACS Supplier or
Supplier-derived object and utilize the Supplier's publishEvent
method. Details on doing this can be found here.
-
To subscribe to an event, instantiate an ACS Consumer or
Consumer-derived object and utilize the Consumer's addSubscription
method. addSubscription requires the developer to provide the
event type and also a function or method capable of consuming
that particular type of event. Details on doing this can be found here.
Special Notes
- Events are defined as IDL structs and the name of the IDL struct should have “Event” appended to it.
- Consumers and suppliers locate channels by name. These names
are defined as const strings in IDL and the static variable defining
the name should have “CHANNEL” appended to its own name.
- There is no SimpleConsumer class in Java although Consumer performs the same functionality.
- Supplier and Consumer are to be used in Python because SimpleSupplier and SimpleConsumer do not exist there.
- Callbacks are a more appropriate form of asynchronous
communication when there will only be one supplier sending events to a
single consumer object.
- A tool has been developed which is capable of monitoring all events. Look for ‘eventbrowser’ in the Related Documents section.
Examples in the ALMA CVS Repository
ACS/LGPL/CommonSoftware/acsexmpl/ws/include/acsexmplFridgeImpl.h (C++ Supplier)
ACS/LGPL/CommonSoftware/acsexmpl/ws/src/acsexmplFridgeImpl.cpp (C++ Supplier)
ACS/LGPL/CommonSoftware/acsexmpl/ws/src/acsexmplClientFridgeNC.cpp (C++ Consumer)
ACS/LGPL/CommonSoftware/jcontexmpl/src/alma/demo/EventSupplierImpl/ (Java Supplier)
ACS/LGPL/CommonSoftware/jcontexmpl/src/alma/demo/EventConsumerImpl/ (Java Consumer)
ACS/LGPL/CommonSoftware/acspyexmpl/src/acspyexmplFridgeNCSupplier.py (Python Supplier)
ACS/LGPL/CommonSoftware/acspyexmpl/src/acspyexmplFridgeNCConsumer.py (Python Consumer)
|
Keywords: Notification Service, Supplier, Consumer, Event, Channel, IDL, C++, Java, Python