Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Magento 2 Integrations: ERPs, APIs, Webhooks & Rabbits! - MageTitansUSA 2016

Joshua Warren
September 09, 2016

Magento 2 Integrations: ERPs, APIs, Webhooks & Rabbits! - MageTitansUSA 2016

Magento has long been the core system connecting and integrating various business systems. With Magento 2, we have even more tools at our disposal for these integrations – APIs, webhooks & RabbitMQ are all available to us. In this talk, we’ll cover how to determine which integration method to use for your project and work through a sample ERP integration utilizing Magento 2 Enterprise.

MageTitans USA 2016 edition.

Joshua Warren

September 09, 2016
Tweet

More Decks by Joshua Warren

Other Decks in Technology

Transcript

  1. None
  2. None
  3. @JoshuaSWarren #MageTitansUSA About Me • PHP-Based Ecommerce Developer Since 1999

    • Magento Developer Since 2008; Magento 2 Developer Since 2014 • Magento Master • Founder & CEO of Creatuity Corp, Magento Enterprise Solution Partner
  4. @JoshuaSWarren #MageTitansUSA Integrations

  5. @JoshuaSWarren #MageTitansUSA Discussing complex, data- intensive integrations

  6. @JoshuaSWarren #MageTitansUSA Let’s look at the new option in Magento

    2
  7. @JoshuaSWarren #MageTitansUSA What is it? How do we use it?

  8. @JoshuaSWarren #MageTitansUSA Magento 1 Integration Options • SOAP API •

    REST API*
  9. @JoshuaSWarren #MageTitansUSA Magento 2 Integration Options • SOAP API •

    REST API • Web Hooks* • RabbitMQ*
  10. @JoshuaSWarren #MageTitansUSA RabbitMQ

  11. @JoshuaSWarren #MageTitansUSA Messaging Queue

  12. @JoshuaSWarren #MageTitansUSA Messages can be plaintext, process commands or any

    other type of information.
  13. @JoshuaSWarren #MageTitansUSA Queue is a place where messages are held

    until a consumer connects and retrieves them.
  14. @JoshuaSWarren #MageTitansUSA In other words…

  15. None
  16. None
  17. None
  18. RabbitMQ:These Go to 11

  19. @JoshuaSWarren #MageTitansUSA RabbitMQ consistently sorts and delivers over one million

    messages per second http://bit.ly/2c303Wy
  20. @JoshuaSWarren #MageTitansUSA Magento hands a message off to RabbitMQ to

    be handled asynchronously
  21. @JoshuaSWarren #MageTitansUSA RabbitMQ can be clustered as you scale up

  22. @JoshuaSWarren #MageTitansUSA RabbitMQ decouples your Magento code from your integrations

    using messages
  23. @JoshuaSWarren #MageTitansUSA To harness the power of RabbitMQ…

  24. @JoshuaSWarren #MageTitansUSA think different

  25. @JoshuaSWarren #MageTitansUSA Bi-directional sync between an ERP/OMS and Magento

  26. Old Way

  27. @JoshuaSWarren #MageTitansUSA When an order is placed, an event is

    fired and an observer handles sending the order data to the ERP
  28. New Way

  29. @JoshuaSWarren #MageTitansUSA Fire a message to RabbitMQ, move on

  30. @JoshuaSWarren #MageTitansUSA \Magento\Framework\MessageQueue \PublisherInterface $publisher $publisher->publish('creatuity.sent.oms', $this- >orderInterface);

  31. @JoshuaSWarren #MageTitansUSA Topics • ‘creatuity.sent.oms’ is the topic • RabbitMQ

    can be configured to use topics to route messages to specific queues • Wildcard routing is possible - i.e., ‘creatuity.*’ would match all topics that start with ‘creatuity.’ • Topics allow the consumers connected to RabbitMQ to easily grab only the messages they need to process
  32. None
  33. @JoshuaSWarren #MageTitansUSA Messages • Can be an object, can be

    a string - can be anything you’d like • Allows the application on either end of the integration to use their native format • Keep it simple
  34. @JoshuaSWarren #MageTitansUSA Route responses to your Magento code via communication.xml

  35. @JoshuaSWarren #MageTitansUSA <config xsi:noNamespaceSchemaLocation="urn:magento:framework:Communication/etc/communication.xsd"> <topic name="creatuity.sent.oms" request="Magento\Sales\Api\Data\OrderInterface"> <handler name="creatuityoms.sent.oms.handler" type="Creatuity\Oms\Model\Oms"

    method="saveOmsNum" /> </topic> <topic name="creatuity.sent.magento" request="Magento\Sales\Api\Data\OrderInterface" > <handler name="creatuityoms.sent.magento.handler" type="Creatuity\Oms\Model\Oms" method="saveOmsNum" /> </topic> </config>
  36. @JoshuaSWarren #MageTitansUSA public function saveOmsNum(\Creatuity\Oms\Model\Oms $oms) { $oms->setData('MagentoOrderNum', $oms->getOrderNum()); $oms->setData('OmsOrderNum',

    $oms->getOmsNum()); $oms->save(); }
  37. @JoshuaSWarren #MageTitansUSA Advantages of RabbitMQ • RabbitMQ can route messages

    to specific queues for you • Decouples your code from the API on the other side of the integration • There is a RabbitMQ client for every major language • Magento developers write Magento code, ERP developers write ERP code
  38. @JoshuaSWarren #MageTitansUSA Gotchas

  39. 2.0 2.1 2.2

  40. @JoshuaSWarren #MageTitansUSA Magento 2.0, 2.1 and 2.2 all contain major

    changes to message queues
  41. None
  42. @JoshuaSWarren #MageTitansUSA Magento Enterprise Edition Only

  43. None
  44. @JoshuaSWarren #MageTitansUSA One more service to support in your web

    stack
  45. @JoshuaSWarren #MageTitansUSA Magento Cloud Edition is a good option to

    offset this
  46. @JoshuaSWarren #MageTitansUSA Homework

  47. @JoshuaSWarren #MageTitansUSA Go try RabbitMQ out

  48. @JoshuaSWarren #MageTitansUSA The key to success with RabbitMQ & all

    of Magento 2…
  49. @JoshuaSWarren #MageTitansUSA Stop trying to apply old patterns and techniques

  50. @JoshuaSWarren #MageTitansUSA Keep up with the new features and architectural

    advances
  51. @JoshuaSWarren #MageTitansUSA RabbitMQ enables us to quickly integrate third-party systems

    in a new way
  52. @JoshuaSWarren #MageTitansUSA We still don’t know the upper bound of

    Magento 2’s scalability
  53. @JoshuaSWarren #MageTitansUSA Go build something awesome!