SlideShare a Scribd company logo
Publish /
Subscribe
Alexandru Badiu
Me
Alexandru Badiu
Drupal user and contributor since 2003
Adulmec LLC
Drupal Romania
Drupal.ro
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
What is Pub/Sub?
 Messaging paradigm
 Sibling of Message queues
 Publisher, Subscriber, Broker
 Decoupled
 Topic based
 Content based
 Push
 Pull
What is Pub/Sub?
 Advantages
   Loosely coupled
   Scalable
 Disadvantages
   Not so scalable on large deployments
   Loosely coupled
What is Pub/Sub?
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
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
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
Advanced usage - Demo
 Using the filters
 Node reference
 Deletion propagation
 Syncing uploaded files
 Excluding nodes
 Tying nodes together
Integration
 hook_publish_prepare(&$node)
 publish_node_was_changed($nid)
 hook_subscribe_presave(&$node)
 hook_subscribe_postsave(&$node)
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,
        );
      }
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);
        }
      }
Integration
         publish_node_was_changed($nid)



         _bulk_media_update_statistics($nid);
         if (module_exists('publish')) {
           publish_node_was_changed($nid);
         }
Case study:
Urbo.ro
‣We use Pub / Sub to sync nodes
‣Custom modules for extra data
‣21 channels and subscriptions
‣57 k nodes managed
Thanks
                 andu@ctrlz.ro
http://ctrlz.ro / http://corporate.adulmec.ro
     Photo credit: Flickr users Gl3am, nidhug and scattered sunshine.

More Related Content

PPTX
Publish subscribe model overview
PPTX
Mule mel 5_tips
PPT
Notes On Networking 1
PDF
MuleSoft DataWeave data transformation language
PPTX
Mule data weave_10
PPT
Networking and socket
PDF
Expressive Design (in 20 minutes)
DOCX
Primitive data types
Publish subscribe model overview
Mule mel 5_tips
Notes On Networking 1
MuleSoft DataWeave data transformation language
Mule data weave_10
Networking and socket
Expressive Design (in 20 minutes)
Primitive data types

Similar to Publish and Subscribe (20)

ODP
This upload requires better support for ODP format
PPT
Mongo-Drupal
PDF
AngularJS Basic Training
PDF
Dependency injection in Drupal 8
PDF
Opencast Admin UI - Introduction to developing using AngularJS
PDF
Osiąganie mądrej architektury z Symfony2
PDF
Multilingualism makes better programmers
PDF
2023 - Drupalcon - How Drupal builds your pages
PDF
Drupalcon 2023 - How Drupal builds your pages.pdf
ODP
Best practices tekx
PPT
Zend framework 03 - singleton factory data mapper caching logging
PDF
Gradle in a Polyglot World
PDF
Web applications with Catalyst
PDF
Drupal 8: What's new? Anton Shubkin
PDF
Plugin-based software design with Ruby and RubyGems
PPTX
Drupal 8 migrate!
PPTX
PDF
The state of hooking into Drupal - DrupalCon Dublin
PDF
Perl web frameworks
PDF
Curscatalyst
This upload requires better support for ODP format
Mongo-Drupal
AngularJS Basic Training
Dependency injection in Drupal 8
Opencast Admin UI - Introduction to developing using AngularJS
Osiąganie mądrej architektury z Symfony2
Multilingualism makes better programmers
2023 - Drupalcon - How Drupal builds your pages
Drupalcon 2023 - How Drupal builds your pages.pdf
Best practices tekx
Zend framework 03 - singleton factory data mapper caching logging
Gradle in a Polyglot World
Web applications with Catalyst
Drupal 8: What's new? Anton Shubkin
Plugin-based software design with Ruby and RubyGems
Drupal 8 migrate!
The state of hooking into Drupal - DrupalCon Dublin
Perl web frameworks
Curscatalyst
Ad

More from Alexandru Badiu (14)

PDF
Behavior Driven Development with Drupal
PDF
Drupal 8
PDF
Drupal as a first class mobile platform
PDF
Cloud to the rescue? How I learned to stop worrying and love the cloud
PDF
REST Drupal
PDF
Cloud to the rescue? How I learned to stop worrying and love the cloud
ZIP
Using Features
ZIP
Learning the basics of the Drupal API
ZIP
What's new in the Drupal 7 API?
ZIP
Drupal, Android and iPhone
PPT
Using Features
PDF
Concepte de programare functionala in Javascript
PDF
Drupal and Solr
PDF
Prezentare Wurbe
Behavior Driven Development with Drupal
Drupal 8
Drupal as a first class mobile platform
Cloud to the rescue? How I learned to stop worrying and love the cloud
REST Drupal
Cloud to the rescue? How I learned to stop worrying and love the cloud
Using Features
Learning the basics of the Drupal API
What's new in the Drupal 7 API?
Drupal, Android and iPhone
Using Features
Concepte de programare functionala in Javascript
Drupal and Solr
Prezentare Wurbe
Ad

Recently uploaded (20)

PDF
Encapsulation theory and applications.pdf
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
project resource management chapter-09.pdf
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Hybrid model detection and classification of lung cancer
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
Tartificialntelligence_presentation.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
A Presentation on Touch Screen Technology
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
WOOl fibre morphology and structure.pdf for textiles
Encapsulation theory and applications.pdf
1 - Historical Antecedents, Social Consideration.pdf
MIND Revenue Release Quarter 2 2025 Press Release
project resource management chapter-09.pdf
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Hybrid model detection and classification of lung cancer
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Tartificialntelligence_presentation.pptx
Programs and apps: productivity, graphics, security and other tools
NewMind AI Weekly Chronicles - August'25-Week II
A Presentation on Touch Screen Technology
DP Operators-handbook-extract for the Mautical Institute
Zenith AI: Advanced Artificial Intelligence
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
OMC Textile Division Presentation 2021.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Group 1 Presentation -Planning and Decision Making .pptx
WOOl fibre morphology and structure.pdf for textiles

Publish and Subscribe

  • 2. Me Alexandru Badiu Drupal user and contributor since 2003 Adulmec LLC Drupal Romania Drupal.ro
  • 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. What is Pub/Sub? Messaging paradigm Sibling of Message queues Publisher, Subscriber, Broker Decoupled Topic based Content based Push Pull
  • 5. What is Pub/Sub? Advantages Loosely coupled Scalable Disadvantages Not so scalable on large deployments Loosely coupled
  • 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. 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. 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. Advanced usage - Demo Using the filters Node reference Deletion propagation Syncing uploaded files Excluding nodes Tying nodes together
  • 11. Integration hook_publish_prepare(&$node) publish_node_was_changed($nid) hook_subscribe_presave(&$node) hook_subscribe_postsave(&$node)
  • 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. 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. Integration publish_node_was_changed($nid) _bulk_media_update_statistics($nid); if (module_exists('publish')) { publish_node_was_changed($nid); }
  • 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. Thanks andu@ctrlz.ro http://ctrlz.ro / http://corporate.adulmec.ro Photo credit: Flickr users Gl3am, nidhug and scattered sunshine.