SlideShare a Scribd company logo
1 of 28
© 2016 Magento, Inc. Page | 1
Integrations with Magento, end to end story:
RabbitMQ, APIs
© 2016 Magento, Inc. Page | 2
Magento 2 Architect:
- Magento Service Layer
- Composer Integration
- Magento CLI
- Rabbit MQ Integration
@vrann Eugene Tulika
© 2016 Magento, Inc. Page | 3
On average, Magento store integrates with
15 different external systems
Integrations Framework:
• API In supported by Web API (CE) and RabbitMQ (EE)
• API Out supported by RabbitMQ (EE)
© 2016 Magento, Inc. Page | 4
Magento Chat Bot for
Facebook Messenger
© 2016 Magento, Inc. Page | 5
Use-Case: Store With Hand-Picked Books
• Niche customers with unusual requests
© 2016 Magento, Inc. Page | 6
Use-Case: Store With Hand-Picked Books
• Facebook is the best way to reach larger and targeted audience
• Facebook Page representing the store
• Customers don’t want to leave Facebook to shop in store
• Customers ask questions in Messenger
© 2016 Magento, Inc. Page | 7
Facebook Chat Bots API
• Manager cannot handle all
communications manually
• Facebook webhooks for messages
received in the chat
• Facebook API for responses
• Backed by simple AI to understand the
context of discussion
© 2016 Magento, Inc. Page | 8
Facebook POSTs message to the Callback
Callback.php
200 OK
© 2016 Magento, Inc. Page | 9
Callback POSTs response to Facebook API
Callback.php API
© 2016 Magento, Inc. Page | 10
Integration with Magento
IN/OUT Using Web API
© 2016 Magento, Inc. Page | 11
Callback makes API request to Magento
Messenger Callback.php
API
Web API Request
Magento POSTs response to Facebook
© 2016 Magento, Inc. Page | 12
Web API Service Interface
© 2016 Magento, Inc. Page | 13
Magento API Interfaces
• https://github.com/vrann/magebot
© 2016 Magento, Inc. Page | 14
Map Service to the Web API endpoint
© 2016 Magento, Inc. Page | 15
What can go wrong?
When customer writes in
Messenger:
• Blocking request from
callback to Magento
• Scalability: Magento can be
overloaded processing other
requests
• Availability: Magento API is
unreachable at that moment
Messages from customer are lost!
© 2016 Magento, Inc. Page | 16
API IN Using RabbitMQ
© 2016 Magento, Inc. Page | 17
• Scripts: https://github.com/vrann/http-rabbitmq-writer
Callback puts messages to the Queue
Messenger
API
Callback.php
Magento POSTs response to Facebook
Rabbit MQ
© 2016 Magento, Inc. Page | 18
Magento: transform Web API to RabbitMQ
Map message handler to topic in communication.xml
Map consumer to queue in queue_consumer.xml
Run consumer(s):
© 2016 Magento, Inc. Page | 19
With Communication & Queue configs
We achieved:
 Non-Blocking request, response to Facebook sent immediately
 Scalability handled by Queue
 Availability handled by Queue
Communication vs Queue:
• Communication Framework is an abstraction around
publisher/subscriber. It can be implemented:
– with database and HTTP requests instead (webhooks)
– in-memory (observers)
• Queue is a Transport layer for Communication
– configuration of RabbitMQ adapter and topology
© 2016 Magento, Inc. Page | 20
OUT Using RabbitMQ
© 2016 Magento, Inc. Page | 21
• Scripts: https://github.com/vrann/http-rabbitmq-writer
Goal: Magento sends messages to Rabbit
Messenger
API
callback.php
response.php
© 2016 Magento, Inc. Page | 22
Before: sender interface with the HTTP request
© 2016 Magento, Inc. Page | 23
Now: Sender interface with RabbitMQ
Replace preference for MessageSenderInterface in di.xml,
Add “Remote” suffix
Interface implementation will be auto-generated:
© 2016 Magento, Inc. Page | 24
Publisher & Topology
queue_publisher.xml maps generated topic to the exchange
queue_topology.xml configures exchange to queue bindings
Available from Magento 2.2, before it was in queue.xml
© 2016 Magento, Inc. Page | 25
© 2016 Magento, Inc. Page | 26
Input Messages Handler
Input
Classifier
Search catalog by author
Title, image url, description
For Input Classifier it is better to use
© 2016 Magento, Inc. Page | 27
Wrap Up
• We covered:
– Reasons behind Magento Web API data structures
– Reasons to use queues
– Switch from Web API to the RabbitMQ
– Code generation of API OUT for RabbitMQ
– Communication framework vs Queue framework
– Separation of publishers, consumers, topology in 2.2
– Input Message Handling
– Facebook bots!
• https://github.com/vrann/facebook-chatbot
• https://github.com/vrann/http-rabbitmq-writer
• https://github.com/vrann/magebot
© 2016 Magento, Inc. Page | 28
Q&A
Write me @vrann (twitter, github)

More Related Content

What's hot

Progressive web apps
Progressive web appsProgressive web apps
Progressive web appsFastly
 
Federico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento VersionFederico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento VersionMeet Magento Italy
 
Transitioning from Web Sites to Web Apps with the History API: SMX Advanced 2013
Transitioning from Web Sites to Web Apps with the History API: SMX Advanced 2013Transitioning from Web Sites to Web Apps with the History API: SMX Advanced 2013
Transitioning from Web Sites to Web Apps with the History API: SMX Advanced 2013Tom Conte
 
Introducing eZ Publish Platform 5.1 - webinar
Introducing eZ Publish Platform 5.1 - webinarIntroducing eZ Publish Platform 5.1 - webinar
Introducing eZ Publish Platform 5.1 - webinarRoland Benedetti
 
Anatomy of a Progressive Web App
Anatomy of a Progressive Web AppAnatomy of a Progressive Web App
Anatomy of a Progressive Web AppMike North
 
How to Install Magento on WAMP Server
How to Install Magento on WAMP ServerHow to Install Magento on WAMP Server
How to Install Magento on WAMP ServerAPPSeCONNECT
 
Flex presentation1
Flex presentation1Flex presentation1
Flex presentation1Nguyen Tran
 
Progressive web apps with Angular 2
Progressive web apps with Angular 2Progressive web apps with Angular 2
Progressive web apps with Angular 2Manfred Steyer
 
Building a MVC eCommerce Site in Under 5 Minutes
Building a MVC eCommerce Site in Under 5 MinutesBuilding a MVC eCommerce Site in Under 5 Minutes
Building a MVC eCommerce Site in Under 5 MinutesGaines Kergosien
 
PWA - Progressive Web App
PWA - Progressive Web AppPWA - Progressive Web App
PWA - Progressive Web AppRobert Robinson
 
Customizing nopCommerce with Plugins and Themes
Customizing nopCommerce with Plugins and ThemesCustomizing nopCommerce with Plugins and Themes
Customizing nopCommerce with Plugins and ThemesGaines Kergosien
 
Introduction to Office Development Topics
Introduction to Office Development TopicsIntroduction to Office Development Topics
Introduction to Office Development TopicsHaaron Gonzalez
 
Progressive Web App
Progressive Web AppProgressive Web App
Progressive Web AppVinci Rufus
 
Integrating Accelerated Mobile Pages (AMP) In Drupal Websites
Integrating Accelerated Mobile Pages (AMP) In Drupal WebsitesIntegrating Accelerated Mobile Pages (AMP) In Drupal Websites
Integrating Accelerated Mobile Pages (AMP) In Drupal WebsitesExcellent Webworld
 
Php, magento and asp.net for your e commerce store
Php, magento and asp.net for your e commerce storePhp, magento and asp.net for your e commerce store
Php, magento and asp.net for your e commerce storeSteven Wilson
 

What's hot (20)

Admin Panel
Admin Panel Admin Panel
Admin Panel
 
Progressive web apps
Progressive web appsProgressive web apps
Progressive web apps
 
Federico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento VersionFederico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento Version
 
Transitioning from Web Sites to Web Apps with the History API: SMX Advanced 2013
Transitioning from Web Sites to Web Apps with the History API: SMX Advanced 2013Transitioning from Web Sites to Web Apps with the History API: SMX Advanced 2013
Transitioning from Web Sites to Web Apps with the History API: SMX Advanced 2013
 
Introducing eZ Publish Platform 5.1 - webinar
Introducing eZ Publish Platform 5.1 - webinarIntroducing eZ Publish Platform 5.1 - webinar
Introducing eZ Publish Platform 5.1 - webinar
 
Rajesh CV
Rajesh CVRajesh CV
Rajesh CV
 
Anatomy of a Progressive Web App
Anatomy of a Progressive Web AppAnatomy of a Progressive Web App
Anatomy of a Progressive Web App
 
How to Install Magento on WAMP Server
How to Install Magento on WAMP ServerHow to Install Magento on WAMP Server
How to Install Magento on WAMP Server
 
Flex presentation1
Flex presentation1Flex presentation1
Flex presentation1
 
Progressive web apps with Angular 2
Progressive web apps with Angular 2Progressive web apps with Angular 2
Progressive web apps with Angular 2
 
Building a MVC eCommerce Site in Under 5 Minutes
Building a MVC eCommerce Site in Under 5 MinutesBuilding a MVC eCommerce Site in Under 5 Minutes
Building a MVC eCommerce Site in Under 5 Minutes
 
PWA - Progressive Web App
PWA - Progressive Web AppPWA - Progressive Web App
PWA - Progressive Web App
 
Customizing nopCommerce with Plugins and Themes
Customizing nopCommerce with Plugins and ThemesCustomizing nopCommerce with Plugins and Themes
Customizing nopCommerce with Plugins and Themes
 
Introduction to Office Development Topics
Introduction to Office Development TopicsIntroduction to Office Development Topics
Introduction to Office Development Topics
 
Progressive Web-App (PWA)
Progressive Web-App (PWA)Progressive Web-App (PWA)
Progressive Web-App (PWA)
 
Progressive Web App
Progressive Web AppProgressive Web App
Progressive Web App
 
Task 1
Task 1Task 1
Task 1
 
Integrating Accelerated Mobile Pages (AMP) In Drupal Websites
Integrating Accelerated Mobile Pages (AMP) In Drupal WebsitesIntegrating Accelerated Mobile Pages (AMP) In Drupal Websites
Integrating Accelerated Mobile Pages (AMP) In Drupal Websites
 
Php, magento and asp.net for your e commerce store
Php, magento and asp.net for your e commerce storePhp, magento and asp.net for your e commerce store
Php, magento and asp.net for your e commerce store
 
Progressive Web Apps(PWA)
Progressive Web Apps(PWA)Progressive Web Apps(PWA)
Progressive Web Apps(PWA)
 

Viewers also liked

Mage Titans USA 2016 - Joshua Warren - Magento 2 Integrations
Mage Titans USA 2016 - Joshua Warren - Magento 2 Integrations Mage Titans USA 2016 - Joshua Warren - Magento 2 Integrations
Mage Titans USA 2016 - Joshua Warren - Magento 2 Integrations Stacey Whitney
 
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...Stacey Whitney
 
Your First Magento 2 Module
Your First Magento 2 ModuleYour First Magento 2 Module
Your First Magento 2 ModuleBen Marks
 
Secure input and output handling - Magento Meetup Vienna Edition
Secure input and output handling - Magento Meetup Vienna EditionSecure input and output handling - Magento Meetup Vienna Edition
Secure input and output handling - Magento Meetup Vienna EditionAnna Völkl
 
Secure input and output handling - Mage Titans Manchester 2016
Secure input and output handling - Mage Titans Manchester 2016Secure input and output handling - Mage Titans Manchester 2016
Secure input and output handling - Mage Titans Manchester 2016Anna Völkl
 
Magento 2 Development Best Practices
Magento 2 Development Best PracticesMagento 2 Development Best Practices
Magento 2 Development Best PracticesBen Marks
 
Writing Testable Code (for Magento 1 and 2) 2016 Romaina
Writing Testable Code (for Magento 1 and 2)  2016 RomainaWriting Testable Code (for Magento 1 and 2)  2016 Romaina
Writing Testable Code (for Magento 1 and 2) 2016 Romainavinaikopp
 
Prorroga_acuerdo_marco_medicion_online_iab_aimc
Prorroga_acuerdo_marco_medicion_online_iab_aimcProrroga_acuerdo_marco_medicion_online_iab_aimc
Prorroga_acuerdo_marco_medicion_online_iab_aimcOptimediaSpain
 
Magento 2 product import export
Magento 2 product import exportMagento 2 product import export
Magento 2 product import exportBenno Lippert
 
SXSW 2017 - How To Actually Predict The Future | Rohit Bhargava
SXSW 2017 - How To Actually Predict The Future | Rohit BhargavaSXSW 2017 - How To Actually Predict The Future | Rohit Bhargava
SXSW 2017 - How To Actually Predict The Future | Rohit BhargavaRohit Bhargava
 
SXSW 2017: Festival Highlights
SXSW 2017: Festival HighlightsSXSW 2017: Festival Highlights
SXSW 2017: Festival HighlightsOgilvy Consulting
 
Secure development environment @ Meet Magento Croatia 2017
Secure development environment @ Meet Magento Croatia 2017Secure development environment @ Meet Magento Croatia 2017
Secure development environment @ Meet Magento Croatia 2017Anna Völkl
 

Viewers also liked (12)

Mage Titans USA 2016 - Joshua Warren - Magento 2 Integrations
Mage Titans USA 2016 - Joshua Warren - Magento 2 Integrations Mage Titans USA 2016 - Joshua Warren - Magento 2 Integrations
Mage Titans USA 2016 - Joshua Warren - Magento 2 Integrations
 
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
 
Your First Magento 2 Module
Your First Magento 2 ModuleYour First Magento 2 Module
Your First Magento 2 Module
 
Secure input and output handling - Magento Meetup Vienna Edition
Secure input and output handling - Magento Meetup Vienna EditionSecure input and output handling - Magento Meetup Vienna Edition
Secure input and output handling - Magento Meetup Vienna Edition
 
Secure input and output handling - Mage Titans Manchester 2016
Secure input and output handling - Mage Titans Manchester 2016Secure input and output handling - Mage Titans Manchester 2016
Secure input and output handling - Mage Titans Manchester 2016
 
Magento 2 Development Best Practices
Magento 2 Development Best PracticesMagento 2 Development Best Practices
Magento 2 Development Best Practices
 
Writing Testable Code (for Magento 1 and 2) 2016 Romaina
Writing Testable Code (for Magento 1 and 2)  2016 RomainaWriting Testable Code (for Magento 1 and 2)  2016 Romaina
Writing Testable Code (for Magento 1 and 2) 2016 Romaina
 
Prorroga_acuerdo_marco_medicion_online_iab_aimc
Prorroga_acuerdo_marco_medicion_online_iab_aimcProrroga_acuerdo_marco_medicion_online_iab_aimc
Prorroga_acuerdo_marco_medicion_online_iab_aimc
 
Magento 2 product import export
Magento 2 product import exportMagento 2 product import export
Magento 2 product import export
 
SXSW 2017 - How To Actually Predict The Future | Rohit Bhargava
SXSW 2017 - How To Actually Predict The Future | Rohit BhargavaSXSW 2017 - How To Actually Predict The Future | Rohit Bhargava
SXSW 2017 - How To Actually Predict The Future | Rohit Bhargava
 
SXSW 2017: Festival Highlights
SXSW 2017: Festival HighlightsSXSW 2017: Festival Highlights
SXSW 2017: Festival Highlights
 
Secure development environment @ Meet Magento Croatia 2017
Secure development environment @ Meet Magento Croatia 2017Secure development environment @ Meet Magento Croatia 2017
Secure development environment @ Meet Magento Croatia 2017
 

Similar to Mage Titans USA 2016 Magento/Facebook/RabbitMQ

API design best practices
API design best practicesAPI design best practices
API design best practicesIgor Miniailo
 
Experience in Magento Community Projects
Experience in Magento Community ProjectsExperience in Magento Community Projects
Experience in Magento Community ProjectsMagecom UK Limited
 
Backward Compatibility Developer's Guide in Magento 2. #MM17CZ
Backward Compatibility Developer's Guide in Magento 2. #MM17CZBackward Compatibility Developer's Guide in Magento 2. #MM17CZ
Backward Compatibility Developer's Guide in Magento 2. #MM17CZIgor Miniailo
 
Backwards Compatibility Developers Guide. #MM17NL
Backwards Compatibility Developers Guide. #MM17NLBackwards Compatibility Developers Guide. #MM17NL
Backwards Compatibility Developers Guide. #MM17NLIgor Miniailo
 
Backward Compatibility Developer's Guide Webinar
Backward Compatibility Developer's Guide WebinarBackward Compatibility Developer's Guide Webinar
Backward Compatibility Developer's Guide WebinarIgor Miniailo
 
James Zetlen - PWA Studio Integration…With You
James Zetlen - PWA Studio Integration…With YouJames Zetlen - PWA Studio Integration…With You
James Zetlen - PWA Studio Integration…With YouMeet Magento Italy
 
Multi Source Inventory (MSI) in Magento 2
Multi Source Inventory (MSI) in Magento 2 Multi Source Inventory (MSI) in Magento 2
Multi Source Inventory (MSI) in Magento 2 Igor Miniailo
 
Backward Compatibility Developer's Guide in Magento 2
Backward Compatibility Developer's Guide in Magento 2Backward Compatibility Developer's Guide in Magento 2
Backward Compatibility Developer's Guide in Magento 2Igor Miniailo
 
Monitoring your cache effectiveness in Magento 2
Monitoring your cache effectiveness in Magento 2Monitoring your cache effectiveness in Magento 2
Monitoring your cache effectiveness in Magento 2Tony Brown
 
Using Magento 2.3 MySQL Queues
Using Magento 2.3 MySQL QueuesUsing Magento 2.3 MySQL Queues
Using Magento 2.3 MySQL QueuesRenu Mishra
 
Max Yekaterinenko - Magento 2 & Quality
Max Yekaterinenko - Magento 2 & QualityMax Yekaterinenko - Magento 2 & Quality
Max Yekaterinenko - Magento 2 & QualityMeet Magento Italy
 
API Design Best Practices by Igor Miniailo
API Design Best Practices by Igor MiniailoAPI Design Best Practices by Igor Miniailo
API Design Best Practices by Igor MiniailoMagecom UK Limited
 
Eugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
Eugene Shaksuvarov - Tuning Magento 2 for Maximum PerformanceEugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
Eugene Shaksuvarov - Tuning Magento 2 for Maximum PerformanceMeet Magento Italy
 
Eugene Shakhsuvarov - Improving enterprise store scalability using AMQP and A...
Eugene Shakhsuvarov - Improving enterprise store scalability using AMQP and A...Eugene Shakhsuvarov - Improving enterprise store scalability using AMQP and A...
Eugene Shakhsuvarov - Improving enterprise store scalability using AMQP and A...Meet Magento Italy
 
Igor Miniailo - Magento 2 API Design Best Practices
Igor Miniailo - Magento 2 API Design Best PracticesIgor Miniailo - Magento 2 API Design Best Practices
Igor Miniailo - Magento 2 API Design Best PracticesAtwix
 
Game changer for e-commerce - Vue Storefront - open source pwa
Game changer for e-commerce - Vue Storefront - open source pwa Game changer for e-commerce - Vue Storefront - open source pwa
Game changer for e-commerce - Vue Storefront - open source pwa Divante
 
Volodymyr Kublytskyi - Develop Product, Design Platform
Volodymyr Kublytskyi - Develop Product, Design PlatformVolodymyr Kublytskyi - Develop Product, Design Platform
Volodymyr Kublytskyi - Develop Product, Design PlatformMeet Magento Italy
 
8 pre launch steps to go with the web rtc based application development
8 pre launch steps to go with the web rtc based application development8 pre launch steps to go with the web rtc based application development
8 pre launch steps to go with the web rtc based application developmentMoonTechnolabsPvtLtd
 
The long way from Monolith to Microservices
The long way from Monolith to MicroservicesThe long way from Monolith to Microservices
The long way from Monolith to MicroservicesIgor Miniailo
 
API Management - Practical Enterprise Implementation Experience
API Management - Practical Enterprise Implementation ExperienceAPI Management - Practical Enterprise Implementation Experience
API Management - Practical Enterprise Implementation ExperienceCapgemini
 

Similar to Mage Titans USA 2016 Magento/Facebook/RabbitMQ (20)

API design best practices
API design best practicesAPI design best practices
API design best practices
 
Experience in Magento Community Projects
Experience in Magento Community ProjectsExperience in Magento Community Projects
Experience in Magento Community Projects
 
Backward Compatibility Developer's Guide in Magento 2. #MM17CZ
Backward Compatibility Developer's Guide in Magento 2. #MM17CZBackward Compatibility Developer's Guide in Magento 2. #MM17CZ
Backward Compatibility Developer's Guide in Magento 2. #MM17CZ
 
Backwards Compatibility Developers Guide. #MM17NL
Backwards Compatibility Developers Guide. #MM17NLBackwards Compatibility Developers Guide. #MM17NL
Backwards Compatibility Developers Guide. #MM17NL
 
Backward Compatibility Developer's Guide Webinar
Backward Compatibility Developer's Guide WebinarBackward Compatibility Developer's Guide Webinar
Backward Compatibility Developer's Guide Webinar
 
James Zetlen - PWA Studio Integration…With You
James Zetlen - PWA Studio Integration…With YouJames Zetlen - PWA Studio Integration…With You
James Zetlen - PWA Studio Integration…With You
 
Multi Source Inventory (MSI) in Magento 2
Multi Source Inventory (MSI) in Magento 2 Multi Source Inventory (MSI) in Magento 2
Multi Source Inventory (MSI) in Magento 2
 
Backward Compatibility Developer's Guide in Magento 2
Backward Compatibility Developer's Guide in Magento 2Backward Compatibility Developer's Guide in Magento 2
Backward Compatibility Developer's Guide in Magento 2
 
Monitoring your cache effectiveness in Magento 2
Monitoring your cache effectiveness in Magento 2Monitoring your cache effectiveness in Magento 2
Monitoring your cache effectiveness in Magento 2
 
Using Magento 2.3 MySQL Queues
Using Magento 2.3 MySQL QueuesUsing Magento 2.3 MySQL Queues
Using Magento 2.3 MySQL Queues
 
Max Yekaterinenko - Magento 2 & Quality
Max Yekaterinenko - Magento 2 & QualityMax Yekaterinenko - Magento 2 & Quality
Max Yekaterinenko - Magento 2 & Quality
 
API Design Best Practices by Igor Miniailo
API Design Best Practices by Igor MiniailoAPI Design Best Practices by Igor Miniailo
API Design Best Practices by Igor Miniailo
 
Eugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
Eugene Shaksuvarov - Tuning Magento 2 for Maximum PerformanceEugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
Eugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
 
Eugene Shakhsuvarov - Improving enterprise store scalability using AMQP and A...
Eugene Shakhsuvarov - Improving enterprise store scalability using AMQP and A...Eugene Shakhsuvarov - Improving enterprise store scalability using AMQP and A...
Eugene Shakhsuvarov - Improving enterprise store scalability using AMQP and A...
 
Igor Miniailo - Magento 2 API Design Best Practices
Igor Miniailo - Magento 2 API Design Best PracticesIgor Miniailo - Magento 2 API Design Best Practices
Igor Miniailo - Magento 2 API Design Best Practices
 
Game changer for e-commerce - Vue Storefront - open source pwa
Game changer for e-commerce - Vue Storefront - open source pwa Game changer for e-commerce - Vue Storefront - open source pwa
Game changer for e-commerce - Vue Storefront - open source pwa
 
Volodymyr Kublytskyi - Develop Product, Design Platform
Volodymyr Kublytskyi - Develop Product, Design PlatformVolodymyr Kublytskyi - Develop Product, Design Platform
Volodymyr Kublytskyi - Develop Product, Design Platform
 
8 pre launch steps to go with the web rtc based application development
8 pre launch steps to go with the web rtc based application development8 pre launch steps to go with the web rtc based application development
8 pre launch steps to go with the web rtc based application development
 
The long way from Monolith to Microservices
The long way from Monolith to MicroservicesThe long way from Monolith to Microservices
The long way from Monolith to Microservices
 
API Management - Practical Enterprise Implementation Experience
API Management - Practical Enterprise Implementation ExperienceAPI Management - Practical Enterprise Implementation Experience
API Management - Practical Enterprise Implementation Experience
 

More from Vrann Tulika

Magento Web API Ecosystem. Imagine 2018
Magento Web API Ecosystem. Imagine 2018Magento Web API Ecosystem. Imagine 2018
Magento Web API Ecosystem. Imagine 2018Vrann Tulika
 
Career of the Software Engineer in Modern Open-Source e-Commerce Company
Career of the Software Engineer in Modern Open-Source e-Commerce CompanyCareer of the Software Engineer in Modern Open-Source e-Commerce Company
Career of the Software Engineer in Modern Open-Source e-Commerce CompanyVrann Tulika
 
Magento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowMagento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowVrann Tulika
 
Enterprise Patterns in Magento
Enterprise Patterns in MagentoEnterprise Patterns in Magento
Enterprise Patterns in MagentoVrann Tulika
 
Розпаралелювання Програм на Фортрані з Використанням Техніки Переписувальних ...
Розпаралелювання Програм на Фортрані з Використанням Техніки Переписувальних ...Розпаралелювання Програм на Фортрані з Використанням Техніки Переписувальних ...
Розпаралелювання Програм на Фортрані з Використанням Техніки Переписувальних ...Vrann Tulika
 
PHP and Asynchronous Systems
PHP and Asynchronous SystemsPHP and Asynchronous Systems
PHP and Asynchronous SystemsVrann Tulika
 

More from Vrann Tulika (6)

Magento Web API Ecosystem. Imagine 2018
Magento Web API Ecosystem. Imagine 2018Magento Web API Ecosystem. Imagine 2018
Magento Web API Ecosystem. Imagine 2018
 
Career of the Software Engineer in Modern Open-Source e-Commerce Company
Career of the Software Engineer in Modern Open-Source e-Commerce CompanyCareer of the Software Engineer in Modern Open-Source e-Commerce Company
Career of the Software Engineer in Modern Open-Source e-Commerce Company
 
Magento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowMagento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request Flow
 
Enterprise Patterns in Magento
Enterprise Patterns in MagentoEnterprise Patterns in Magento
Enterprise Patterns in Magento
 
Розпаралелювання Програм на Фортрані з Використанням Техніки Переписувальних ...
Розпаралелювання Програм на Фортрані з Використанням Техніки Переписувальних ...Розпаралелювання Програм на Фортрані з Використанням Техніки Переписувальних ...
Розпаралелювання Програм на Фортрані з Використанням Техніки Переписувальних ...
 
PHP and Asynchronous Systems
PHP and Asynchronous SystemsPHP and Asynchronous Systems
PHP and Asynchronous Systems
 

Recently uploaded

%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 

Recently uploaded (20)

%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 

Mage Titans USA 2016 Magento/Facebook/RabbitMQ

  • 1. © 2016 Magento, Inc. Page | 1 Integrations with Magento, end to end story: RabbitMQ, APIs
  • 2. © 2016 Magento, Inc. Page | 2 Magento 2 Architect: - Magento Service Layer - Composer Integration - Magento CLI - Rabbit MQ Integration @vrann Eugene Tulika
  • 3. © 2016 Magento, Inc. Page | 3 On average, Magento store integrates with 15 different external systems Integrations Framework: • API In supported by Web API (CE) and RabbitMQ (EE) • API Out supported by RabbitMQ (EE)
  • 4. © 2016 Magento, Inc. Page | 4 Magento Chat Bot for Facebook Messenger
  • 5. © 2016 Magento, Inc. Page | 5 Use-Case: Store With Hand-Picked Books • Niche customers with unusual requests
  • 6. © 2016 Magento, Inc. Page | 6 Use-Case: Store With Hand-Picked Books • Facebook is the best way to reach larger and targeted audience • Facebook Page representing the store • Customers don’t want to leave Facebook to shop in store • Customers ask questions in Messenger
  • 7. © 2016 Magento, Inc. Page | 7 Facebook Chat Bots API • Manager cannot handle all communications manually • Facebook webhooks for messages received in the chat • Facebook API for responses • Backed by simple AI to understand the context of discussion
  • 8. © 2016 Magento, Inc. Page | 8 Facebook POSTs message to the Callback Callback.php 200 OK
  • 9. © 2016 Magento, Inc. Page | 9 Callback POSTs response to Facebook API Callback.php API
  • 10. © 2016 Magento, Inc. Page | 10 Integration with Magento IN/OUT Using Web API
  • 11. © 2016 Magento, Inc. Page | 11 Callback makes API request to Magento Messenger Callback.php API Web API Request Magento POSTs response to Facebook
  • 12. © 2016 Magento, Inc. Page | 12 Web API Service Interface
  • 13. © 2016 Magento, Inc. Page | 13 Magento API Interfaces • https://github.com/vrann/magebot
  • 14. © 2016 Magento, Inc. Page | 14 Map Service to the Web API endpoint
  • 15. © 2016 Magento, Inc. Page | 15 What can go wrong? When customer writes in Messenger: • Blocking request from callback to Magento • Scalability: Magento can be overloaded processing other requests • Availability: Magento API is unreachable at that moment Messages from customer are lost!
  • 16. © 2016 Magento, Inc. Page | 16 API IN Using RabbitMQ
  • 17. © 2016 Magento, Inc. Page | 17 • Scripts: https://github.com/vrann/http-rabbitmq-writer Callback puts messages to the Queue Messenger API Callback.php Magento POSTs response to Facebook Rabbit MQ
  • 18. © 2016 Magento, Inc. Page | 18 Magento: transform Web API to RabbitMQ Map message handler to topic in communication.xml Map consumer to queue in queue_consumer.xml Run consumer(s):
  • 19. © 2016 Magento, Inc. Page | 19 With Communication & Queue configs We achieved:  Non-Blocking request, response to Facebook sent immediately  Scalability handled by Queue  Availability handled by Queue Communication vs Queue: • Communication Framework is an abstraction around publisher/subscriber. It can be implemented: – with database and HTTP requests instead (webhooks) – in-memory (observers) • Queue is a Transport layer for Communication – configuration of RabbitMQ adapter and topology
  • 20. © 2016 Magento, Inc. Page | 20 OUT Using RabbitMQ
  • 21. © 2016 Magento, Inc. Page | 21 • Scripts: https://github.com/vrann/http-rabbitmq-writer Goal: Magento sends messages to Rabbit Messenger API callback.php response.php
  • 22. © 2016 Magento, Inc. Page | 22 Before: sender interface with the HTTP request
  • 23. © 2016 Magento, Inc. Page | 23 Now: Sender interface with RabbitMQ Replace preference for MessageSenderInterface in di.xml, Add “Remote” suffix Interface implementation will be auto-generated:
  • 24. © 2016 Magento, Inc. Page | 24 Publisher & Topology queue_publisher.xml maps generated topic to the exchange queue_topology.xml configures exchange to queue bindings Available from Magento 2.2, before it was in queue.xml
  • 25. © 2016 Magento, Inc. Page | 25
  • 26. © 2016 Magento, Inc. Page | 26 Input Messages Handler Input Classifier Search catalog by author Title, image url, description For Input Classifier it is better to use
  • 27. © 2016 Magento, Inc. Page | 27 Wrap Up • We covered: – Reasons behind Magento Web API data structures – Reasons to use queues – Switch from Web API to the RabbitMQ – Code generation of API OUT for RabbitMQ – Communication framework vs Queue framework – Separation of publishers, consumers, topology in 2.2 – Input Message Handling – Facebook bots! • https://github.com/vrann/facebook-chatbot • https://github.com/vrann/http-rabbitmq-writer • https://github.com/vrann/magebot
  • 28. © 2016 Magento, Inc. Page | 28 Q&A Write me @vrann (twitter, github)

Editor's Notes

  1. I want to show how the framework makes it easier Two directions of integrations Real-world example, built specifically for this conference, available on github
  2. you download library for chat bots. Here is a good one vrann/fbcahtbot (because I’ve written it:) you pass authorization on facebook you need to deploy chatbot app on AWS and enable https Once Facebook authorized it, you will receive messages from the messenger to the callback You can respond invoking Facebook API with the response message and receiver id Callback Web endpoint https It should be registered with the facebook It should be subscribed to the webhooks It should send 200 OK when received the message
  3. Facebook invokes callback with the message in JSON structure we’ve seen before The job of the Callback script will be simple – Make API request to Magento and pass message to Magento For this, we need to implement new Magento API which can accept such message structure
  4. Let’s start from the Service Interface – it defines web API endpoint It tells few things: - Class and Method which will be invoked by web api call should implement this interface Input parameter of the method should be MessageTextInterface What is MessageTextInterface?
  5. Let’s take original JSON request from Facebook We want little to no modification in it in order to have Magento accept it as Web API request. Otherwise it puts more work on the callback script Magento API Interfaces represent same data structure: we define every object in JSON structure as a separate interface in PHP. If objects are same we can re-use one interface like you see in sender and recipient Data Interfaces contains getters and setters for the fields Type of fields is either scalar value or data interface Why this is needed? It allows unified serialization pattern This is complex case, when we mock messages from external system. (Sometimes it is not possible, when conventions are different) In usual case you design objects for Magento and write a connector from external system. L
  6. Request is blocking, it means that while Magento haven’t processed request, loaded required information from the database, sent response back to Facebook, the callback will keep the connection. Facebook will not send next request until previous request is processed, so this delays delivery of other messages Answer to such kind of problems is Queues
  7. - simple receiver gets request and puts to rabbitmq exchange Callback.php sends message to the callback.received queue
  8. - I’m lucky to have Magento Enterprise, which already has built-in support of the rabbit. I will just connect it to that Rabbit instance. (Otherwise, I would need to write a connector, etc) Write communication.xml and queue_consumer.xml and bind it to existing Web API topic-based exchange Topic name is the same as a queue name Here we just listen for the messages, we assume that queue exists on the rabbit (created manually) Now I can run consumers and have messages processed from the Rabbit! Handler uses same interface as web api endpoint Handler uses same input parameter Queue ”callback.received” is the one where callback will put messages Consumer name is an alias to run consumers
  9. Difference in two configuration files and we have: sclability availability, Non-blocking requests For developers, you can two versions of extension: community edition and enterprise edition. For relatively small stores with not too many requests we can do blocking calls
  10. - simple receiver gets request and puts to rabbitmq exchange Callback.php sends message to the callback.received queue
  11. Show request/response of Facebook messages with the two rabbit listeners in CLI we can send message back directly, or we can put it back to the queue — this will save us from situations when facebook is unreachable. We create Interface with the semantic “send message to Facebook” We write “Remote preference” for it – it generates us implementation which sends message Write queue_publisher.xml Write simple rabbit listener which forwards messages to facebook.
  12. These files available in 2.2, before it was just queue.xml Publisher allows to configure which exchange will be message with the topic posted to If we don’t define it, it will go to default exchange. Topology defines binding of exchanges to the queues. Here we need to bind to the queue which response.php script knows about, otherwise it will not receive the message We bind exchange to which publisher publishes topic to the queue which is read by response.php by the topic which is generated by Remote you can configure all RabbitMQ topology on the Magento side in the same way as you configure database schema