Publish subscribe model overviewPresentation Transcript
Publish-Subscribe Model Overview Presented by: Ishraq Fatafta
AgendaO Introduction.O Publish-Subscribe model overview.O Publish-Subscribe a database perspective: O Expressions. O Continuous query. O XML.O Conclusion
IntroductionO Traditional system-centric approach O Request/Response query of data. O Data volume and response time.O Data-centric approach O Publishers O Subscribers O Notification system
Introduction Cont.O Publish-Subscribe model advantages: O Enhanced response time. O Enhanced results. O Database resources utilization and increased capacity. O Loosely coupled relationship between publishers and subscribers. O Scalability.
Publish-Subscribe Model OverviewO Described as events or pattern of events produced by publishers that subscribers interested in and notified when they are available.O Information has been referred to as Notifications in this paradigm.O Subscribers can continue their tasks until the notification service delivers notifications.
Publish-Subscribe Basic Model Overview
Publish-Subscribe Basic Model Overview Cont. O Decoupling types between publishers and subscribers: O Space decoupling: in which publishers and subscribers do not need to know each other. O Time decoupling: in which publishers and subscribers do not need to be running at the same time. O Synchronization decoupling: in which publishers and subscribers operations and tasks are not halted during publishing and receiving notifications. O Scalable system that fits well in distributed systems.
Publish-Subscribe Model Overview Cont.O Other communication models existed aside from publish-subscribe model: O Message passing: O Relies on messages for establishing communication between the sender and the receiver. O Message production done Asynchronously. O Message consumption done Synchronously. O Both need to be available in the same time. O Not decoupled in terms of time and space
Publish-Subscribe Model Overview Cont.O Other communication models existed aside from publish-subscribe model: O Remote call procedure (RPC): O Intends to make remote interactions looks the same as local interactions. O Coupled in time, space and synchronization. O Notifications: O Notifications sent by client to the server including callback arguments. O Notifications sent by server to the client including the result. O Coupled in time and space.
Publish-Subscribe Model Overview Cont.O Other communication models existed aside from publish-subscribe model: O Shared space: O Based on tuple-space: ordered collection of tuples accessed by all parties. O Adding and deleting tuples from tuple-space Synchronously. O Decouple time and space. O Message queuing: O Uses tuple-space, queues are provided with messages from producers and additional transactional, ordering and timing functionalities are provided by the message queue. O Same as Shared space.
Subscription modelsO Topic-based subscription model O Also referred to as Subject-based models. O subscriber shows interest in a particular topic and receives notifications filtered based on that. O Similar to joining to a group but more dynamic. O Hierarchy based. O Limited amount of expressions provided for subscribers to filter and limit their interested criteria. O Subscribe to more than one topic in a single subscription.
Subscription models Cont.O Content -based subscription model O Bound to the content of events themselves rather than external criteria. O Subscription language is used for filtering O CarBrand = „Mercedes‟ and Price <= 20,000 O StockName = „T*‟ and change > 3 O Needs more expressive criteria to determine which will generate a lot of traffic on the network. O More advanced and complex notification system to be able to filter each event and extract subscriptions
Subscription models Cont.O Type-based subscription model O Built using concepts from Object-Oriented. O Events are objects that can hold attributes and methods and notifications are objects of specific type. O Subscribers of specific object types will only receive instances of that type or its sub-types. O Performance issues when a large amount of events that need to be processed all at runtime.
Subscription related characteristicsO Push and PullO Time driven and data drivenO Full update and incremental updateO Broadcast and unicast data delivery
Quality measures of publish- subscribe servicesO Quality measures and metrics when designing any publish-subscribe model: O Reliability. O Security. O Priority. O Latency.
Publish-Subscribe model: Database PerspectiveO Publish-subscribe with expressions.O Continuous Query.O XML.
Publish-subscribe with expressionsO Boolean expression used to specify subscribers‟ interest in an event by filtering their criteria using name-value, comparison operators (=, >, >=, <, <=) and regular expressions.O We will use SQL and relational database.
Publish-subscribe with expressions Cont.O Example: Interested in cars for saleO Brand Cadillac and price less than 35000O Rules : ON Car4Sale IF (Model = ‘Cadillac’ and Price < 35000) THEN notify(‘firstname.lastname@example.org’)
Publish-subscribe with expressions Cont. SubscriberI Address … Interest D … 100 Amman … Model = „Cadillac‟ and …. Price < 35000 101 Irbid … Model = „Mercedes‟ …. and Year > =2007SELECT * FROM [SUBSCRIBERS]WHEREEVALUATE(SUBSCRIBERS.Interest, <DATA ITEM>) = 1
Publish-subscribe with expressions Cont.O Queries can be simple, complex, with any type of join.O Publishers can put limitations on predicates. SELECT * FROM SUBSCRIBERS WHERE EVALUATE(SUBSCRIBERS. Interest, <CAR DETAILS>) = 1 AND SUBSCRIBERS.Address = „Amman‟ ORDER BY SUBSCRIBERS.SubscriberID DESC
Publish-subscribe with expressions Cont.O Storing expressions as Table data O Store these conditions as data in special type columns. O Metadata is needed O To store information about values stored in the condition predicates. O A list of built-in and user-defined functions referenced by the condition. O Validate values stored when new or existing columns are modified. O Indexes can be added.
Publish-subscribe with expressions Cont.O Evaluating expressions O Evaluate operator is new to SQL. O Conditional expression is translated into a WHERE condition in SQL. O Expression Metadata used to determine the structure of the FROM clause. O The result returned is 1 (true) when the condition is satisfied.
Publish-subscribe with expressions Cont. SELECT DISTINCT SUBSCRIBERS.SubscriberID, (CASE WHEN SUBSCRIBERS.annual_income > 100000 THEN notify_salesperson (SUBSCRIBERS.PhoneNumber) ELSE create_email_msg (SUBSCRIBERS.EmailAddress ) FROM SUBSCRIBERS, INVENTORY WHERE EVALUATE(SUBSCRIBERS.Interest, <car details FROMINVENTORY>) = 1 AND Sub_DISTANCE(SUBSCRIBERS.Address,:DealerLoc,‟distance=50‟) = ‟TRUE‟ Group BY SUBSCRIBERS.SubscriberID
Continuous QueryO Queries constructed only once and stored for continuous use over the database.O Used over Append-Only databases.O First used to support Tapestry systems.O Uses time-based approach rather than triggers.O Uses a language called TQL (Tapes-try query language).
Continuous Query Cont.FOREVER DO Execute Query Q Return results to userSleep for some period of time.ENDLOOP
Continuous Query Cont.O Continuous query suffers some dis-efficiency: O Non-deterministic results. O Duplicate. O Inefficiency of the systemO To overcome this: O Incremental queries which run periodically. O Has two timestamps: last execution time (t) and current time (T). O Only results in the period (T-t) are returned.
Continuous Query Cont.O Incremental queries: Set T. –∞ FOREVER DO set t:= current time Execute query Q (z, t) Return result to user set T:= t Sleep for some period of time ENDLOOP
Continuous Query Cont.O To overcome duplicates, queries are transformed into Monotone queries.O Queries whom results are not increased as new tuples added to the database SELECT * FROM tbl WHERE tbl.field = “test” AND tbl.ts < t SELECT m.msgid FROM m WHERE NOT EXISTS( SELECT * FROM m ml WHERE ml.inreplyto = m.msgid AND t< ml.ts + 2 weeks )
XMLO Importance of XML as a standard information exchange mechanism.O Its capabilities of encoding structural information in documents.O Using XML in creating user profiles.O Using XFilters, which is a mechanism that matches XML documents to user profiles and relational databases, matched documents are returned using XPath to interested users .
XML Cont.O XPath query is decomposed into a set of path nodes using XPath parser.O Tags are extracted from these nodes and stored in a TagPath table.O linear path is extracted from user subscription XPath profile and stored in the LinearPath table.O TagPath table is used to match linear paths in users‟ subscriptions with TagPath from XML documents.
XML Cont.O SQL query can perform any DML operation on them.O SQL query is ran recursively to match XML messages with subscriptions.O Values of stored path tags are used as predicates in the join
ConclusionO Publish-subscribe system consists of: O publishers, who wish to disseminate messages in a form of events to interested users, O Subscribers, who wish to be notified with these events by subscribing to them. O Notification management system that maintains a database with all publishers and subscribers.
Conclusion Cont.O Database is used to match events and subscriptions by evaluating events based on: O Expressions provided by subscribers in a form of queries stored in the database. O Continuous queries that target Append-only databases using a time-based approach. O XML that uses XFilters to match XML documents against user profiles, filter and return them using SQL queries in relational databases and XPath queries.