SlideShare una empresa de Scribd logo
1 de 16
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.

Más contenido relacionado

Similar a Publish and Subscribe

Dependency injection in Drupal 8
Dependency injection in Drupal 8Dependency injection in Drupal 8
Dependency injection in Drupal 8
Alexei Gorobets
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalyst
svilen.ivanov
 
Drupal 8: What's new? Anton Shubkin
Drupal 8: What's new? Anton ShubkinDrupal 8: What's new? Anton Shubkin
Drupal 8: What's new? Anton Shubkin
ADCI Solutions
 
Curscatalyst
CurscatalystCurscatalyst
Curscatalyst
Kar Juan
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
diego_k
 

Similar a Publish and Subscribe (20)

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

Más de Alexandru Badiu

Más de Alexandru Badiu (14)

Behavior Driven Development with Drupal
Behavior Driven Development with DrupalBehavior Driven Development with Drupal
Behavior Driven Development with Drupal
 
Drupal 8
Drupal 8Drupal 8
Drupal 8
 
Drupal as a first class mobile platform
Drupal as a first class mobile platformDrupal as a first class mobile platform
Drupal as a first class mobile platform
 
Cloud to the rescue? How I learned to stop worrying and love the cloud
Cloud to the rescue? How I learned to stop worrying and love the cloudCloud to the rescue? How I learned to stop worrying and love the cloud
Cloud to the rescue? How I learned to stop worrying and love the cloud
 
REST Drupal
REST DrupalREST Drupal
REST Drupal
 
Cloud to the rescue? How I learned to stop worrying and love the cloud
Cloud to the rescue? How I learned to stop worrying and love the cloudCloud to the rescue? How I learned to stop worrying and love the cloud
Cloud to the rescue? How I learned to stop worrying and love the cloud
 
Using Features
Using FeaturesUsing Features
Using Features
 
Learning the basics of the Drupal API
Learning the basics of the Drupal APILearning the basics of the Drupal API
Learning the basics of the Drupal API
 
What's new in the Drupal 7 API?
What's new in the Drupal 7 API?What's new in the Drupal 7 API?
What's new in the Drupal 7 API?
 
Drupal, Android and iPhone
Drupal, Android and iPhoneDrupal, Android and iPhone
Drupal, Android and iPhone
 
Using Features
Using FeaturesUsing Features
Using Features
 
Concepte de programare functionala in Javascript
Concepte de programare functionala in JavascriptConcepte de programare functionala in Javascript
Concepte de programare functionala in Javascript
 
Drupal and Solr
Drupal and SolrDrupal and Solr
Drupal and Solr
 
Prezentare Wurbe
Prezentare WurbePrezentare Wurbe
Prezentare Wurbe
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

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.

Notas del editor