Publish and Subscribe

2,995 views

Published on

Presentation on Publish and Subscribe from Drupalcamp Timisoara 2010.

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,995
On SlideShare
0
From Embeds
0
Number of Embeds
37
Actions
Shares
0
Downloads
29
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
















  • Publish and Subscribe

    1. 1. Publish / Subscribe Alexandru Badiu
    2. 2. Me Alexandru Badiu Drupal user and contributor since 2003 Adulmec LLC Drupal Romania Drupal.ro
    3. 3. We’re goning to talk about What is Pub/Sub Pub/Sub in Drupal Basic usage Advanced features Integration with 3rd party modules Case study: Urbo.ro
    4. 4. What is Pub/Sub? Messaging paradigm Sibling of Message queues Publisher, Subscriber, Broker Decoupled Topic based Content based Push Pull
    5. 5. What is Pub/Sub? Advantages Loosely coupled Scalable Disadvantages Not so scalable on large deployments Loosely coupled
    6. 6. What is Pub/Sub?
    7. 7. Pub/Sub in Drupal Not pure Pub / Sub Content synchronization (tightly coupled) Content propagation (loosely coupled) Domain module alternative A hybrid system (topic and content based) The content are nodes Supports Pull and Push Uses XML-RPC
    8. 8. Pub/Sub in Drupal Topics are defined by views Content filtering is done via filters node_save() and alternatives Supports private channels Token based security Works with most CCK field types (no userreference) Syncs taxonomy terms Syncs files uploaded to nodes Deletion propagation
    9. 9. Basic usage - Demo Set up taxonomies Set up a publisher and a channel Set up a subscriber to that channel Add some nodes into the queue Push Pull
    10. 10. Advanced usage - Demo Using the filters Node reference Deletion propagation Syncing uploaded files Excluding nodes Tying nodes together
    11. 11. Integration hook_publish_prepare(&$node) publish_node_was_changed($nid) hook_subscribe_presave(&$node) hook_subscribe_postsave(&$node)
    12. 12. Integration hook_publish_prepare(&$node) function flag_pub_sub_publish_prepare(&$node) { $flag = flag_get_flag(FLAG_PUB_SUB_FLAG_NAME); if ($flag == null) { return; } if (!$flag->is_flagged($node->nid)) { return; } $node->flag_pub_sub = array( FLAG_PUB_SUB_FLAG_NAME => true, ); }
    13. 13. Integration hook_subscribe_postsave(&$node) function flag_pub_sub_subscribe_postsave(&$node) { $flag = flag_get_flag(FLAG_PUB_SUB_FLAG_NAME); if ($flag == null) { return; } if ($node->flag_pub_sub[FLAG_PUB_SUB_FLAG_NAME]) { $flag->flag('flag', $node->nid); } }
    14. 14. Integration publish_node_was_changed($nid) _bulk_media_update_statistics($nid); if (module_exists('publish')) { publish_node_was_changed($nid); }
    15. 15. Case study: Urbo.ro ‣We use Pub / Sub to sync nodes ‣Custom modules for extra data ‣21 channels and subscriptions ‣57 k nodes managed
    16. 16. Thanks andu@ctrlz.ro http://ctrlz.ro / http://corporate.adulmec.ro Photo credit: Flickr users Gl3am, nidhug and scattered sunshine.

    ×