|
Claims  |
|
|
What is claimed is:
1. A method of routing an event in a data processing system including a plurality of interconnected hubs, between a publisher, which publishes events, and a subscriber, which
subscribes to events, where the publisher is connected to a publisher hub and the subscriber is connected to a subscriber hub, the method comprising the steps of:
providing a data structure in a memory of at least the publisher hub and the subscriber hub, where each hub containing the data structure is termed a current hub and all hubs connected to a current hub are neighbor hubs of the current hub, the
data structure being created by the current hub in accordance with information about physical hub connections, event types, advertisements, routes, and subscriptions of the system to form thereby a chain of subscriptions from the publisher hub to the
subscriber hub; and
sending the event, by the publisher hub, to one of its neighbor hubs, the data structure in the publisher hub indicating that the neighbor hub is part of the chain of subscriptions extending from the publisher hub to the subscriber hub.
2. The method of claim 1, wherein the event is initially defined using OMG's Interface Definition Language (IDL).
3. The method of claim 2, further including the steps of:
compiling the IDL to yield source code in the C programming language that includes a declaration of a type for the event and that further includes source code for creating and accessing the event; and
incorporating the declaration and the source code into source code for the publisher and source code for the subscriber.
4. The method of claim 1, further comprising the steps of:
receiving the event from the publisher hub, by a neighbor hub of the publisher hub; and
sending the event, by the neighbor hub of the publisher hub, to a neighbor hub of the neighbor hub, the data structure in the neighbor hub of the publisher hub indicating that its neighbor hub is on the least-cost path to the subscriber.
5. The method of claim 1, further comprising the step of:
receiving the event, by a hub that is not connected to the subscriber;
determining, by the hub that is not connected to the subscriber, in accordance with that hub's data structure, that a neighbor hub is connected either directly or indirectly on the least-cost path to the subscriber; and
sending, by the hub not connected to the subscriber, the event to its neighbor hub, so that the event can be forwarded to the subscriber.
6. The method of claim 1, wherein the sending step includes the step of:
sending an event, by the publisher hub, to one of its neighbor hubs when the publisher hub indicates that the subscriber subscribes to events having values found in the event.
7. The method of claim 1, further including the step of:
sending an event, by the neighbor hub, to one of its neighbor hubs when the neighbor hub indicates that the subscriber subscribes to events having values found in the event.
8. The method of claim 1, wherein cost is measured in terms of the expense of sending information between two hubs.
9. The method of claim 1, wherein cost is measured in terms of the time required to send information between two hubs.
10. The method of claim 1, wherein cost is measured in terms of the convenience of sending information between two hubs.
11. The method of claim 1, further including the steps, performed by the subscriber, of:
registering as a subscriber with the subscriber hub;
registering subscriptions with the subscriber hub; and
setting up a call-back routine that will be invoked when the subscriber hub receives an event for the subscriber.
12. The method of claim 1, further including the steps, performed by the publisher, of:
determining whether it is time to publish an event;
providing an event data structure;
filling the event data structure with data; and
publishing the event by sending the event to the publisher hub.
13. The method of claim 1, wherein the publisher hub adds an envelope data structure containing information about the event to the event before the event is sent.
14. The method of claim 1, wherein the publisher hub adds a routing block to the event before the event is sent, a plurality of the routing blocks of the event defining a route that the event has taken from the publisher hub to the current hub.
15. The method of claim 1, further comprising the step of:
receiving the event, by a hub that is not connected to a second subscriber;
determining, by the hub that is not connected to the second subscriber, in accordance with that hub's data structure, that a neighbor hub is connected either directly or indirectly on the least-cost path to the second subscriber; and
sending, by the hub not connected to the second subscriber, the event to its neighbor hub, so that the event can be forwarded to the second subscriber.
16. A method of routing an event in a data processing system having a plurality of interconnected hubs, between a publisher, which publishes events, and a subscriber, which subscribes to events, where the publisher is connected to a publisher
hub and the subscriber is connected the method comprising the steps, of:
distributing information, among the plurality of hubs, about the interconnections among the plurality of hubs;
distributing information, among the plurality of hubs, identifying event types of events that the publisher may publish;
distributing, among the plurality of hubs, advertisements that describe events that the publisher may publish;
distributing, among the plurality of hubs, about routes among the plurality of hubs;
informing the plurality of hubs that the subscriber has subscribed to a type of event; and
creating a data structure in at least the publisher hub and the subscriber hub, where each hub containing the data is termed a current hub and all hubs connected to a neighbor hubs of the current hub, the data structure indicating which neighbor
hub is on a oath between the subscriber's hub, the data structure being including information about physical hub connections, event types, advertisements, routes, and subscriptions related to the plurality of hubs.
17. The method of claim 16, further comprising the step of:
sending the event, by the publisher hub, to one of its neighbor hubs, the data structure in the publisher hub indicating that the neighbor hub is on the least-cost path to the subscriber.
18. The method of claim 17, further comprising the step of:
receiving the event, by the hub connected to the subscriber;
determining, by the hub connected to the subscriber, in accordance with that hub's data structure, that the subscriber has subscribed to the event; and
sending, by the hub connected to the subscriber, the event to the subscriber.
19. A system for routing an event in a data processing system having a plurality of interconnected hubs, comprising:
a publisher connected to a publisher hub of the plurality of hubs, which publishes event;
a subscriber connected to a subscriber hub of the plurality of hubs, which subscribes to events;
a memory containing a data structure, located in at least the publisher hub and the subscriber hub, where each hub containing the data structure is termed a current hub and all hubs connected to a current hub are neighbor hubs of the current hub,
indicating which neighbor hub is on a path of hubs between publisher's hub and the subscriber's hub, the data structure including information about physical hub connections, event types, advertisements, routes, and subscriptions of the system;
a sending portion, in the publisher hub, configured to send the event to one of the publisher hub's neighbor hubs, the data the publisher hub indicating that the neighbor hub is on the path to the subscriber; and
a receiving portion, in the subscriber hub, configured receive the event from a neighbor hub;
a determining portion, in the subscriber hub, in accordance with that subscriber hub's data structure, that the subscriber has subscribed to the event; and
a sending portion, in the subscriber hub, configured to send the event to the subscriber.
20. A computer usable medium having computer embodied therein for routing an event between a publisher and a subscriber in a network of interconnected hubs, the program product comprising:
computer readable program code devices configured to cause a computer to effect provision of a data structure in a memory of at least the publisher hub and the subscriber hub, where the data structure is termed a current hub and all hubs to a
current hub are neighbor hubs of the current hub, the data indicating which neighbor hub is on a path between the publisher's hub and the subscriber's hub, the data structure including information about physical hub connections, event types,
advertisements, routes, subscriptions of the system;
computer readable program code devices configured a computer to effect sending the event, by the publisher hub, to of its neighbor hubs, the data structure in the publisher hub indicating the neighbor hub is on the path of the subscriber; and
computer readable program code devices configured to cause a computer to effect receiving the event, by the subscriber hub;
computer readable program code devices configured computer to effect determining, by the subscriber hub, with the hub's data structure, that the subscriber has subscribed to the event; and
computer readable program code devices configured computer to effect sending, by the hub connected to the subscriber, the event to the subscriber. |
|
|
|
|
Claims  |
|
|
Description  |
|
|
APPENDICES
Appendix A, which is a part of this specification and is herein incorporated by reference, contains a summary of exemplary system events that can be passed between hubs in a preferred embodiment of the present invention.
FIELD OF THE INVENTION
This application relates to an information publishing system and more particularly, to an object oriented system for making information available via a networked system of publishers and subscribers.
BACKGROUND OF THE INVENTION
Certain conventional systems use a "transactional" model for exchanging information between nodes of a data processing system. In a conventional transactional model two applications initiate a synchronous "transaction" that is maintained for as
long as information is being exchanged between the nodes. The transactional model requires that a transaction be defined for each business activity. When nodes on widely disparate portions of a network attempt to communicate via the transaction model,
it is often difficult to define a transaction that works well on all parts of the system. Moreover, a transaction can only involve the nodes that began the transaction. Another node cannot join the transaction in the middle. This scheme is unsuited
for a system in which nodes do not know about all other nodes in the system.
Many commercial enterprises still use software that was developed long ago and is no longer supported by its manufacturer. Such software is called "legacy software." It is not always possible or desirable to modify existing legacy software to
operate with a new networked system. The legacy software may be very complex, making it difficult and expensive to modify. A company may be wary of making modifications to a stable system that is working consistently. Moreover, there may not be any
computer programmers at a company who understand the legacy system in enough detail that they can make modifications to it. Lastly, a company may not have the source code for a legacy application if it purchased the application from a commercial vendor. What is needed is a way to integrate legacy software into a networked system.
SUMMARY OF THE INVENTION
A preferred embodiment of the present invention is implemented as a type of system software called "middleware." Middleware is software that is located between an application program and a control-level program. Middleware is "network centric"
and does not concentrate on a specific user interface or on the organization of a specific database. The described embodiment includes a plurality of "publisher" entities, who publish information, and a plurality of "subscriber" entities, who request
and use the information. Publishers and subscribers are connected to each other through a network. The network is a "store and forward" network whose routing is "content-based." In a content-based routing system, information is routed based on the
content of the information, and not on the addresses of publishers or subscribers in the system. In the described embodiment, information is distributed to many subscribers in parallel.
In the described embodiment, the basic quanta of information is called an "event". Publishers publish events and subscribers subscribe to events that match criteria defined by the subscriber. In the described embodiment, events are represented
by data structures in the C programming language, although any appropriate representation can be used.
Publication and subscription are performed asynchronously. Publishers and subscribers do not have direct knowledge of each other. The system receives published event from a publisher and routes the event to all appropriate subscribers. Each
subscriber is guaranteed to receive all events published on the system if, and only if, they match the subscription criteria specified by the subscriber.
The described embodiment includes an Application Programming Interface (API) for publishers and for subscribers. The API defines a plurality of procedures that allow respective publishers and subscribers to interface to the system. Thus,
various types of publishers and subscribers can be connected to the system, as long as they use the interface procedures defined in accordance with the API. The described embodiment also includes support for a plurality of software elements such as
common databases, installation and administration tools, and logging facilities. Thus, the described embodiment is termed an "enterprise system" because it can be used throughout the entirety of a commercial enterprise.
The described embodiment of the present invention makes it easy to integrate legacy systems, legacy applications, and legacy hardware into the system and attempts to minimize the amount of information that a user must learn to use the system.
Because communication within the system is based on asynchronous "events," the present invention can be implemented on a heterogeneous network that includes both PCs and mainframes executing under various operating systems and running various types of
applications. The described embodiment utilizes a distributed-object environment and a preferred embodiment of the present invention implements the Common Object Request Broker (CORBA) standard.
In accordance with the purpose of the invention, as embodied and broadly described herein, the present invention relates to a method of facilitating the routing an event in a data processing system, between a publisher, which publishes events,
and a subscriber, which subscribes to events, the data processing system having a plurality of interconnected hubs, where the publisher is connected to a publisher hub and the subscriber is connected to a subscriber hub, the method comprising the steps,
performed by the data processing system of providing a data structure in a memory of at least the publisher hub and the subscriber hub, where each hub containing the data structure is termed a current hub and all hubs connected to a current hub are
neighbor hubs of the current hub, the data structure indicating which neighbor hub is on a least-cost-path between the publisher's hub and the subscriber's hub, the data structure being created by the current hub in accordance with information about
physical hub connections, event types, advertisements, routes, and subscriptions of the system; sending the event, by the publisher hub, to one of its neighbor hubs, the data structure in the publisher hub indicating that the neighbor hub is on the
least-cost path to the subscriber; receiving the event, by the subscriber hub; determining, by the subscriber hub, in accordance with that hub's data structure, that the subscriber has subscribed to the event; and sending, by the hub connected to the
subscriber, the event to the subscriber.
In further accordance with the purpose of this invention, as embodied and broadly described herein, the present invention relates to a system that facilities routing an event in a data processing system having a plurality of interconnected hubs,
comprising: a publisher connected to a publisher hub of the plurality of hubs, which publishes event; a subscriber connected to a subscriber hub of the plurality of hubs, which subscribes to events; a memory containing a data structure, located in at
least the publisher hub and the subscriber hub, where each hub containing the data structure is termed a current hub and all hubs connected to a current hub are neighbor hubs of the current hub, the data structure indicating which neighbor hub is on a
least-cost-path between the publisher's hub and the subscribers hub, the data structure being created by the current hub in accordance with information about physical hub connections, event types, advertisements, routes, and subscriptions of the system;
a sending portion, in the publisher hub, configured to send the event to one of the publisher hub's neighbor hubs, the data structure in the publisher hub indicating that the neighbor hub is on the least-cost path to the subscriber; and a receiving
portion, in the subscriber hub, configured to receive the event from a neighbor hub; a determining portion, in the subscriber hub, in accordance with that subscriber hub's data structure, that the subscriber has subscribed to the event; and a sending
portion, in the subscriber hub, configured to send the event to the subscriber.
Objects and advantages of the invention will be set forth in part in the description which follows and in part will be obvious from the description or may be learned by practice of the invention. The objects and advantages of the invention will
be realized and attained by means of the elements and combinations particularly pointed out in the appended claims.
BRIEF DESCRIPTION OF THE DRAWINGS
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate several embodiments of the invention and, together with the description, serve to explain the principles of the invention.
FIG. 1 is a block diagram of a networked computer system in accordance with a preferred embodiment of the present invention.
FIG. 2 is a flow chart showing steps performed to install an application, such as a publisher, on a hub of FIG. 1.
FIG. 3 is a flow chart showing steps performed by a publisher of FIG. 1 to publish events.
FIG. 4 is a flow chart showing steps performed by a subscriber of FIG. 1 to subscribe to events.
FIG. 5 is a block diagram showing details of a hub of FIG. 1.
FIG. 6(a) is a diagram showing data structures stored in a memory of the hub of FIG. 5.
FIG. 6(b) is a listing of details of the data structures of FIG. 6(a).
FIG. 7 is a diagram of additional data structures stored in the memory of the hub of FIG. 5 for the purpose of storing information about clients of the hub.
FIG. 8 shows a format of an envelope data structure of an event.
FIG. 9 shows a format of a routing block of an event.
FIG. 10 is a flow chart showing details of steps performed by the hubs of FIG. 1 to populate the data structures of FIG. 6(a).
FIG. 11 is a diagram showing examples of the data structures of FIG. 6(a) populated with data.
FIG. 12 is a flow chart showing details of steps performed by the hubs of FIG. 1 to send published events to subscribers.
FIG. 13 is a block diagram of a data base application incorporated into the network of FIG. 1.
FIG. 14 is a flow chart showing steps performed when the data base is a subscriber.
FIG. 15 is a flow chart showing steps performed when the data base is a publisher.
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
Reference will now be made in detail to the preferred embodiments of the invention, examples of which are illustrated in the accompanying drawings. Wherever possible, the same reference numbers will be used throughout the drawings to refer to
the same or like parts.
I. Overview
FIG. 1 is a block diagram of a networked computer system 100 in accordance with a preferred embodiment of the present invention. Networked computer system 100 includes a plurality of publishers 102, 110, and 116 and a plurality of subscribers
104, 112, and 118. Publisher 102 and subscriber 104 are connected to a network 120 through a hub 106. Publisher 110 and subscriber 112 are connected to network 120 through a hub 108. Publisher 116 and subscriber 118 are connected to network 120
through a hub 114. Hub 106 and its connected publishers and subscribers are in a first territory 130. Hubs 108 and 114 and their connected publishers and subscribers are in a second territory 140. Other territories (not shown) also exist in network
120. "Hubs," "publishers," "subscribers," and "territories" are discussed below in turn.
As indicated by dotted lines in FIG. 1, each publisher, subscriber, and hub can be located in separate computers (102, 104, and 106), in the same computer (108, 110, and 112) or in some combination of separate computers and the same computer
(114, 116, and 118). Hubs can have zero or more publishers and zero or more subscribers. Hubs can also be directly connected to other hubs.
It will be understood by persons of ordinary skill in the art that each computer (represented in FIG. 1 by dotted lines) includes a CPU, a memory, and input/output lines. These elements are not shown in the figure for the sake of clarity of
example. Each computer can also include numerous other elements, such as disk drives, keyboards, display devices, network connections, additional memory, additional CPUs, etc. The publishers, subscribers, and hubs preferably are implemented as software
instructions stored in a memory and executed by a processor of a computer system. Usually, the publisher, subscriber, and hub software is executed by a processor of the computer in which the software is stored, although a processor of another computer
system could also execute the software.
A preferred embodiment of the invention runs under the Solaris operating system, Version 2.4. Solaris is a trademark of a registered trademark of Sun Microsystems, Inc. in the United States and other countries and is based on the Unix operating
system. Unix is a registered trademark in the United States and other countries, exclusively licensed through X/OPEN, Ltd. Networked computer system 100 uses a network communication protocol, such as TCP/IP, although any appropriate protocol can be
used to implement the present invention.
In the described embodiment, a "publisher" publishes events of certain types on the network 120 and a "subscriber" subscribes to events of certain types. The publisher and subscriber operate asynchronously and are unaware of each other's
existence. Use of a "publish and subscribe" model insulates applications from the network and from each other. Publishing can be thought of as broadcasting an event. The event type is analogous to a radio station. Applications interested in a
particular station subscribe (or tune in to) a specific event type. Just as in radio broadcasting, where all parties involved must agree in advance on a set of possible frequencies, applications in the described embodiment must agree in advance on a
predetermined set of event types.
The described embodiment of the present invention uses "subscription by content." Subscribers specify what they want based on an event type and on the content of the event. The described embodiment makes use of "store and forward" techniques for
events. This term means that the system buffers event, so that, even if a publisher is off-line, a subscriber can still retrieve events. Similarly, a publisher can publish events even if a subscriber is off-line.
The described embodiment is managed in units of hubs. A hub, such as hub 106, is a local connection point for a publisher and/or a subscriber. Both publishers and subscribers are called "clients" of hubs. A publisher uses an "advertisement" to
tell the system what types of events it intends to publish and how it intends to publish them (e.g., daily, as each event trigger occurs, etc). Advertisements are registered with the hub connected to the publisher during the installation of the
publisher. An advertisement must have a unique name. In addition to containing a name of an event type to be published, an advertisement contains other information about the publisher. This information can include the priority level for the published
events, for how long the events are valid, etc. Hubs transmit advertisements to all potential subscribers. Hubs transmit published events to all subscribers who have subscribed to events of that type, whose content matches the subscriber's subscription.
II. Publishers and Subscribers
The following paragraphs describe the steps required to create an application (either a publisher or a subscriber) and to install it on a hub. The following paragraphs further describe the steps performed by an example publisher to publish
events and by an example subscriber to subscribe to events. The described embodiment allows a programmer to write software for applications (publishers and subscribers) in a high level language and to interface with the hub using routines defined in an
API and using event manipulation routines generated for each user-defined event type.
FIG. 2 is a flow chart showing steps performed to install an application, e.g., a publisher, on a hub. FIG. 3 is a flow chart showing steps performed by an installed publisher to publish an event. FIG. 4 is a flow chart showing steps performed
by a subscriber of FIG. 1 to subscribe to events of a certain type and content. As discussed above, both publishers and subscribers preferably are implemented as software programs executed by a processor.
The described embodiment is centered around the sending (publication) and receiving (subscribing) of events. Before a publisher can publish events, the publisher must define and advertise the events that it will publish. In order for the events
to make sense, publishers and subscribers need to understand each other. For this reason, the described embodiment uses a standard specification language to define events. In step 202 of FIG. 2, the publisher defines one or more events that can be
published by that publisher. The described embodiment of the described embodiment allows definition of events using an industry standard Interface Definition Language (IDL). IDL is a standard interface propagated by the Object Management Group (OMG),
although any applicable syntax for describing the structure of the event could be used in conjunction with the described embodiment. In step 204, the OMG IDL definitions of the events are translated into data structures in the C programming language.
Assume, for example, that an application publishes "SalesOrder" events. Before the application could be added to the system, and assuming that no other applications dealing with SalesOrder events already existed, a programmer would define a
"SalesOrder" event using OMG IDL as follows:
______________________________________ //filename: order:ddl interface SalesOrder { struct Address { string street; string city; string state; unsigned long zip; }; attribute string customer.sub.-- name; attribute Address customer.sub.--
address; }; ______________________________________
The above syntax defines an event as an "interface" and defines the data members in the event as "attributes."
After one or more events have been defined, the events are translated into structure definitions of the C programming language. Preferably, this translation is performed by an OMG IDL compiler, which generates a header file and a code file for
each event. The generated header file contains simple C-language structures that represent the event declarations for the typed functions defined in the code file. The C structure definition generated for the above example event of type SalesOrder is:
______________________________________ typedef struct SalesOrder.sub.-- Address { nxsString street; nxsString city; nxsString state; nxsULong zip; } SalesOrder.sub.-- Address; typedef struct SalesOrder { nxsString customer.sub.-- name;
SalesOrder.sub.-- address customer.sub.-- address; } SalesOrder; ______________________________________
A person of ordinary skill in the art will easily understand how the IDL of the example translates into the C programming language structure definitions shown above.
The code file generated from the event definition contains procedures for manipulating events of the defined type (here, for the SalesOrder event). The procedures perform at least the following operations:
For use by a publisher:
Create event of type SalesOrder,
Publish event of type SalesOrder,
Destroy event of type SalesOrder
For use by a subscriber:
Print contents of event of type SalesOrder,
Register Subscription for event of type SalesOrder,
A person of ordinary skill in the art will understand that, although the above plurality of procedures is generated for each defined event, the operation of the procedures differ due to the differences in the structures of the event. The
procedures also differ due to the fact that the described embodiment uses typed function to prevent programming errors.
The process of installing a process application in a hub includes storing one or more advertisements in the hub, as shown in step 206. These advertisements define types of events that the hub knows about An advertisement includes the name of the
advertisement, a description of the event that a publisher publishes (e.g., a SalesOrder event), a description of how the publisher publishes its events (e.g., daily, when an event trigger occurs, etc.), the name of the event type, the priority level of
the events, and the expiration time on the events (also called "time-to-live"). Although not shown in the Figure, the described embodiment also allows access control permissions for the various event types to be set.
The described embodiment also includes predefined routines in an API which are available to the publisher and subscriber software and which include routines to perform at least the following functions:
Register a client,
Reestablish a client with an existing session,
Unregister a client,
Registering intent to publish,
Unregistering a publication,
Publishing an event,
Subscribing to an event,
Reactivating an active subscription to an event, and
Cancelling a subscription,
Other APIS in accordance with the present invention may include somewhat different API functions. In addition, the API preferably includes a "can.sub.-- subscribe" routine and a "can.sub.-- publish" routine that return a Boolean value indicating
whether the calling application can subscribe to or publish events of a certain type. The API also includes a "get.sub.-- current.sub.-- " envelope routine that returns information about the publisher of an event and how the event was published. (This
routine can only be called from the call-back procedure). A call-back procedure is called, e.g., when a subscriber receives an event. FIG. 8 shows a format of an envelope data structure for an event, which is discussed below in connection with event
routing.
It will be understood that when the event description for a publisher or a subscriber is initially translated into, e.g., C, the event header file, whose generation is discussed above, is included within the application software source code.
Thus, in the example, the publisher has access to the definition of the SalesOrder event. The translation also links the event manipulation routines and API routines into the application at this time. The hub, along with other hubs, transmits a notice
of the advertisement existence to potential subscribers, as discussed below.
Once a publisher is installed in a hub, it is free to publish advertisements and events. FIG. 3 is a flow chart showing steps performed by a publisher of FIG. 1 during operation of the publisher. Steps involving a call to the event manipulation
routines that are created by compiling the IDL are indicated by an asterisk in the Figure.
As shown in step 302 of FIG. 3, the publisher first registers itself as a client with the hub to which it is connected. The publisher next advises the hub of which "advertisement" it will use when publishing. An advertisement represents an
"intent to publish" and tells the hub what type of event the publisher will be publishing. To advise the hub in step 302, the publisher tells the hub the name of an advertisement that has been previously installed in the hub (see FIG. 2).
In step 304, the publisher waits until it is time to publish an event. Some publishers, such as in the example above, publish each event at the time that it occurs. Other publishers wait until a specified time, such as once a day, and publish
all unpublished events at that time. For example, a first publisher may publish an event whenever a human operator enters a sales order into the system. A second publisher may publish the same type of event on an hourly basis. Once the publisher
determines that an event is to be created, it calls (in step 306) one of the event manipulation routines that creates a C structure having the proper format for the event to be published.
In step 308, the publisher calls one of the event manipulation routines to publish unpublished events as discussed below in more detail. In step 310, the publisher calls one of the event manipulation routines to destroy the published event. (In
general, in the described embodiment, whatever entity is responsible for allocating an event is also responsible for destroying that event.)
In step 312, the publisher determines if it should cease execution. If not, control returns to step 304. If so, in step 314, the publisher unregisters itself with the hub and ceases execution. Advertisements are kept in the hub to indicate
that a publisher could execute and send those events. This information is needed to build routes to subscribers, as described below. Although not shown in the Figure, other publishers connected to the same hub may operate asynchronously with the steps
of FIG. 3.
Subscribers subscribe to events of particular event types. FIG. 4 is a flow chart showing steps performed by a subscriber of FIG. 1 during operation of the subscriber. The subscriber first registers itself as a client of the hub. Then for each
subscription, it registers a "call-back" procedure.
As shown in step 402, the subscriber next registers itself as a client with the hub to which it is connected. The subscriber then registers a "subscription" for the event type that it wishes to receive through the hub. (The subscriber can look
at the hub to see what types of events are advertised.) A subscription specifies a type of event, and can further specify a "filter" indicating that the subscriber wishes to receive only events of a certain type that also have certain values in certain
fields.
In step 404, for each subscription, the publisher defines a predetermined "call-back" procedure. The call-back procedure will be initiated by the hub whenever the hub determines that the subscriber has received an event of a certain type. The
format of the callback may be different for each operating system on which the present invention is implemented and the call-back procedure can be practically any procedure that is performed when an event is received. For example, in step 406 of FIG. 4,
the call-back procedure could print the contents of the event (using one of the event manipulation procedures designed to print an event of that type). Because a call-back procedure is defined for each subscription, a call-back procedure must be defined
for each type of event to which the subscriber plans to subscribe. In the described embodiment, an event passed into a call-back procedure is destroyed when the call-back procedure returns. Thus, if the subscriber wants to keep any information of the
event, the information should be copied out of the event within the call-back procedure.
The subscriber loops until it is time to cease execution (see step 408). The call-back procedure may be activated zero, one, or many times during this loop, as events of the specified type and values are received by the hub. If an event
subscribed to by the subscriber is received, the call-back procedures is executed in step 406. If, in step 408, the subscriber determines that it is time for it to quit, the subscriber optionally unregisters its subscription, unregisters itself with the
hub, and ceases execution. Subscriptions can also be retained in the hub, to receive future events while disconnected. The hub will queue events arriving for the subscriptions. Although not shown in the Figure, other subscribers connected to the same
hub may perform steps asynchronously with the steps of FIG. 4.
The following examples are written in the C programming language and show example software for a publisher and subscriber.
______________________________________ /* * publish.c */ #include <nexus.h> #include "nxs.sub.-- output/order.sub.-- nxs.h" int main() SalesOrder *event; nxsClientID id; nxsPublicationID pub.sub.-- id; /* Register the client and
the publication */ nxsCreateClient ("order publisher", NULL,NULL, 0, &id); nxsRegisterPublication (id, "order.sub.-- advertisement", &pub.sub.-- d); /* Create the event */ event = nxsCreate.sub.-- SalesOrder(); event->customer.sub.-- name = "Jim
Nexus"; event->customer.sub.-- address.street = "12345 Anistreet"; event->customer.sub.-- address.city = "Mountain View"; event->customer.sub.-- address.state = "CA"; event->customer.sub.-- address.zip = "95000"; /* Publish Event */
nxsPublish.sub.-- SalesOrder (id,pub.sub.-- id,event,0,0); /* Clean up */ nxsDestroy.sub.-- SalesOrder(event); /* Unregister the publication and client */ nxsUnregisterPublication (id,pub.sub.-- id); nxsDestroyClient (id); return (0); } /* *
subscribe.c */ #include <nexus.h> #include "nxs.sub.-- output/order.sub.-- nxs.h" /* Callback function to be called when each event is received */ void event.sub.-- callback ( nxsClientID id, nxsSubscriptionID sub.sub.-- id, nsxULong
seq.sub.-- num.sub.-- high, nsxUlong seq.sub.-- num.sub.-- low, SalesOrder *the.sub.-- event, void *client.sub.-- data { char *st; printf("Event received!.backslash.n"); st = nxsStringify.sub.-- SalesOrder(the.sub.-- event); printf(st); free(st); } int main(int argc, char **argv) { Sales Order *event; nxsClient ID id; nxsSubscriptionID sub.sub.-- id; /* Register Client and subscription */ /* (Only subscribe to specific ZIP codes) */ nxsCreateClient ("order subscriber",NULL,NULL, 0,&id);
nxsRegisterSubscription SalesOrder(id, "customer.sub.-- address.zip == 95000", event.sub.-- callback,NULL,&sub.sub.-- id); /* Mainloop */ nxsMainLoop(id); /* Unregister subscription and client */ nxsUnregister Subscription(id,sub.sub.-- id);
nxsDestroyClient(id); return(0); } ______________________________________
III. Hubs
FIG. 5 is a block diagram showing details of hub 106 of FIG. 1. Hubs 108 and 114 of FIG. 1, and indeed all other hubs in the described embodiment, have a similar structure. Hub 106 is connected to remote hubs 108 and 114 via network 120 (or
directly) and to zero or more publishers 102 and zero or more subscribers 104. Hub 106 also receives information 530 relating to hub administration, information 532 relating to management of its clients (publishers and subscribers), and information 536
relating to system event management.
All input and output to and from hub 106 is queued. For example, events received by hub 106 from remote hub 108 and from publisher 102 are stored in event priority order in respective event queues 502, 504 until hub 106 has time to process them. As a further example, events to be sent by hub 106 to remote hub 114 and to subscriber 104 are stored in event priority order in respective event queues 506, 508 in memory until hub 106 has time to send them. Hubs distribute events using a first-in,
first-out policy. This means that all events having a same priority level will be delivered by hub 106 in the order that they are accepted from the publisher. All events with a higher priority level are delivered earlier than waiting events with a
lower priority level. The described embodiment guarantees to keep the ordering of like-events from a single publisher as the events move though the system. This is important, for example, in transaction processing where an order of updates must be
maintained. Inter-publisher ordering is not guaranteed, since it depends on routing and availability issues.
FIG. 5 also shows the following functional blocks inside hub 106: client management block 510, event management block 512, preprocessor block 514, store block 516, match block 518, and remote administration block 520. Client management block 510
deals with registering and unregistering clients. Event management block 512 deals with managing system events, such as receipt of new connections, types, routings, advertisements, and subscriptions. Pre-process block 514 performs tasks such as adding
envelope information to an event. Store block 516 is a memory of the hub. Match block 518 adds routing information to events, filters events in a manner described below in connection with event routing, and routes events to appropriate other connected
hubs. Remote administration block 520 performs system administration tasks.
FIG. 7 is a diagram of data structures stored in a memory 690 of hub 106 of FIG. 1 that is accessible by all the functional blocks of FIG. 5. The data structures include a table of installed advertisements 700, a table of registered clients 730,
a table of registered publications 760, and a table of registered subscriptions 770. Data is placed in the data structures of FIG. 7 as the publisher and subscriber perform the various steps of FIGS. 2, 3, and 4 as follows.
Step 202 of FIG. 2 fills entries of installed advertisements table 700.
Steps 302 and 402 of FIGS. 3 and 4 fill entries of registered clients table 730. The user name field 734 and user password field 736 may have a NULL value to indicate that the current user ID should be used. Hub name 737 and territory name 740
can be set to NULL to indicate use of a default hub and territory. Flags 742 include, for example, a Boolean value "call-back-on-any-thread," which indicates that event call-backs come on new threads.
Step 302 of FIG. 3 also fills entries of registered publications table 760.
Advertisement name 764 is the name of an advertisement that has been installed in the hub. Step 404 of FIG. 4 also fills entries of registered subscriptions table 770. Content filters 774 are discussed below. A name of a callback procedure is
kept locally in the subscriber (by the C API). The API finds the callback from the subscription ID. A client data field, which is also kept by the APL allows information associated with the subscription to be passed back with each event callback The
information that is passed back has meaning to the subscribing application.
The following paragraphs describe the various types of content filters that can be specified by a subscriber when it registers a subscription. As shown in the above example, subscribers can request that the hub filter the incoming flow of events
and only pass events to the subscribers that match certain criteria. A filter preferably is specified as a expression string sent by the subscriber as a parameter to the routine for registering subscriptions. The expression string syntax for a content
filter in the described embodiment is as follows. (Of course, any appropriate syntax could be used):
______________________________________ symbol meaning types allowed for ______________________________________ = equal to all basic types != not equal to all basic types > greater than numeric and string types >=, <= greater than or
equal numeric and string types and logical AND expressions or Booleans or logical OR expressions or Booleans not logical NOT expressions or Booleans ______________________________________
Event attribute names are used to denote which field in the event should be compared. Sub-fields (those inside structures) are specified using dot notation Names can also be enumerated types, as is known to persons familiar with the C
programming language. Once a content filter has been specified, it is used during event routing as described below in connection with FIGS. 8-12. Information describing each content filter for a subscription is stored in field 774 of FIG. 7.
FIG. 6(a) is a diagram showing data structures stored in a memory 690 of hub 106 of FIG. 5. All hubs contain similar data structures. The described implementation uses a distributed objects model but any appropriate organizational structure
could be used. Details of the data structures of FIG. 6(a) are listed in FIG. 6(b). Ideally, the data structures of FIG. 6(a) describe all advertisements in the system and indicates a neighbor hub to which the current hub should send events of certain
types. FIGS. 10 and 12, respectively, describe the steps to populate the data structures of FIG. 6(a) and to use to the data structures of FIG. 6(a) to route events among the hubs. FIG. 11 shows an example of the data structures populated with data.
Hub 106 (the "current hub") includes data objects representing: each client of the current hub that is a subscriber (indicated by "Client" 684 and "S" 695) and each neighboring hub connected to the current hub ("Neighbor A" 696 and "Neighbor B"
697). The current hub keeps track of the subscription objects of its neighbor hubs. Subscription objects "S" 650 represent all subscribers that can be reached through the respective neighbors. Each neighbor object has two associated cost values:
"mycost" and "theircost". "Mycost" represents a cost of sending information from the current hub to the neighbor. "Theircost" represents a cost of sending information from the neighbor to the current hub. "Theircost" used to define a route, as
described below. The subscribing hub will ask the publishing hub with the lowest "theircost" to forward the events. "Mycost" preferably is only used to inform the neighbors of how much it would cost to the current hub to send information through that
link. A "cost" may be figured in a number of ways. For example, a cost may represent a financial cost, a cost in units of time, a cost as a measure of convenience, or any other appropriate cost.
Hub 106 contains a ("RemoteAd") object for each advertisement that has been registered in the system (i.e., for each intent to publish, step 202 of FIG. 2). Each RemoteAd object points to one or more "AdSource" objects, each of which represents
a path between the current hub and the hub on which the publisher of the ad resides. Each AdSource object stores a cost associated with its path to the original publisher of the ad. Thus, the "cost" value for each AdSource contains the total cost for
sending an event from its source to the neighbor of the current hub or, alternately, to the current hub.
Each AdSource object has an associated list of "sink objects." (SinkCa and sinkNb preferably are located in a single list, although not shown that way in the Figure.) Each sink object has an associated list of subscriptions. For example, SinkCa
has a list 505 of all subscriptions of Client 694 that matched to the advertisement of RemoteAd 510. Similarly, SinkNb has a list 515 of all subscriptions of Neighbor B (and of all subscriptions that can be reached through Neighbor B) that have matched
the advertisement of RemoteAd 510.
Each neighbor object also has an associated AdSourceRef list that points to AdSources for all paths between a publisher and the neighbor. The paths are used for routing system events between hubs, as described below.
IV. Event Routing Between Hubs
FIG. 10 is a flow chart showing details of steps performed by hubs 106, 108, and 114 of FIG. 1 to populate the data structures of FIG. 6(a). These steps are performed, for example, when the network is first initialized. Subsequently, various
hubs may issue "system events" to tell other hubs that changes have occurred in hub connections, event types, advertisements, routings, subscriptions, etc. Appendix A, which is a part of this specification and is herein incorporated by reference,
contains a summary of exemplary system events that can be passed between hubs in the described embodiment.
In FIG. 10, the name of the system event of Appendix A that affects a step in the flow chart is shown next to the step. In step 1002, hubs send system events to each other to define the physical connections between hubs in the network. Each hub
creates neighbor objects representing physical connections to its neighbor hubs (see FIG. 6(a)). In step 1004, the hubs send system events to each other to define the types of events for which advertisements can be published. Each hub makes sure it
knows all the events. This step is performed when adding a hub to a territory. In step 1006, hubs that are connected to a publisher send system events to other hubs, which are forwarded among the hubs, to distribute advertisements among the hub. For
example, the system event NXS.sub.-- SYS.sub.-- EVENT.sub.-- CREATE.sub.-- NEW.sub.-- ADVERTISEMENT of Appendix A causes the creation of RemoteAd objects in the hubs (see FIG. 6(a)).
In step 1008, hubs that are connected to a publisher send system events to other hubs. T | | |