A RESTful Approach to Real-time, Event Driven Messaging by Paul O'Fallon

A RESTful Approach to Real-time, Event Driven Messaging by Paul O'Fallon

Transcript

  1. A RESTful Approach to Real-time, Event Driven Messaging Paul O’Fallon

    @paulofallon Enterprise Architect, Cox Automotive
  2. 2

  3. 3

  4. 4 Our Starting Point

  5. 5 Drawbacks • Adding JMS consumers required SOA configuration changes

    • JMS isn't the best for non-JVM language support • JMS isn't the best for integrating with 3rd parties over the Internet • No message history • No symmetry between SOAP services and JMS messages
  6. 6 A new "Manheim API" Consistent, cohesive set of endpoints

    RESTful, hypermedia-inspired API Self-service sign-up, API key management Support for internal projects, customers and partners OAuth2 support for delegated interactions
  7. 7 Each resource has an “href” GET https://api.manheim.com/units/id/429a5d00-353c... {
 "href":

    "https://api.manheim.com/units/id/429a5d00-353c...",
 "vin": "1G1AP14P577112297",
 "description": {
 "modelYear": 2014,
 "make": "Ford",
 "model": "Mustang",
 "trim": "GT Convertible 2-Door",
 // ...
 }
  8. 8 Related Resources are also “hrefs” GET https://api.manheim.com/consignments/id/863cd3c0... {
 "href":

    "https://api.manheim.com/consignments/id/863cd3c0...",
 "status": "ACTIVE", "unit": {
 "href": "https://api.manheim.com/units/id/429a5d00-353c..."
 },
 "operatingLocation": {
 "href": "https://api.manheim.com/locations/id/AAA"
 },
 
 // ...
 }
  9. 9

  10. 10 Eventer

  11. 11 Events “Just an href”

  12. 12 API Example: /events POST https://api.manheim.com/events {
 "resource": "https://api.manheim.com/consignments/id/863cd3c0...", "eventType":

    "CONSIGNMENTS.CHECKEDIN",
 "body": {
 "href": "https://api.manheim.com/consignments/id/863cd3c0...",
 "status": "ATAUCTION",
 "unit": {
 "href": "https://api.manheim.com/units/id/429a5d00-353c..."
 },
 "operatingLocation": {
 "href": "https://api.manheim.com/locations/id/AAA"
 }
 }
 }
  13. 13 Eventer

  14. 14 Eventer

  15. 15 Subscribers & Subscriptions

  16. 16 API Example: /subscribers POST https://api.manheim.com/subscribers { "callback": "http://www.somecustomer.com/cb", "headers":

    { "Authorization": "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" }, "email": "jdoe@somecustomer.com" } Location: https://api.manheim.com/subscribers/id/005739ae-625b...
  17. 17 Subscribers & Subscriptions

  18. 18 Subscription Matching Criteria • One or more Resource URLs

    (inc. related resources) • Event type (inc. wildcards: CONSIGNMENTS.*) • VIN … or any combination of the above (treated as a logical 'and')
  19. 19 Resource Expansion { "resource": "https://api.manheim.com/consignments/id/863cd3c...",
 "eventType": "CONSIGNMENTS.CHECKEDIN", "body": {


    "href": "...",
 "status": "ATAUCTION",
 "unit": {
 "href": "..."
 },
 "operatingLocation": {
 "href": "..." }
 } } "expansions": [
 "root", "unit",
 "operatingLocation"
 ]
  20. 20 API Example: /subscriptions POST https://api.manheim.com/subscriptions { "subscriber": {
 "href":

    "https://api.manheim.com/subscribers/id/005739ae..."
 }, "criteria": [
 { "type": { "pattern": "CONSIGNMENTS.CHECKEDIN" } }, { "resource": { "href": "https://api.manheim.com/locations/id/AAA" } } ], "expansions": ["root",
"unit"] }
  21. 21 A Published Event { "href": "https://api.manheim.com/events/id/624c277c...", "eventType": "CONSIGNMENTS.CHECKEDIN", "body":

    { "href": "https://api.manheim.com/consignments/id/863cd3c0...", "status": "ATAUCTION", "operatingLocation": { "href": https://api.manheim.com/locations/id/AAA } }, "createdOn": "2015-11-16T20:48:26.138Z", "subscription": { "href": "https://api.manheim.com/subscriptions/id/cd09a47c..." }, "subscriber": { "href": "https://api.manheim.com/subscribers/id/005739ae..." } }
  22. 22 Can Pull Events Too By subscription
 https://api.manheim.com/events/subscription/696f2d67-b483… By subscriber


    https://api.manheim.com/events/subscriber/005739ae-625b... Individual event https://api.manheim.com/events/id/1c160532-13ac...
  23. 23 High Level Architecture

  24. 24 Future Plans Today: Recovery via Retrieval 1. When retries

    are exhausted, event is not passed to the callback 2. Client must pull (GET /events) for missing events to fill in gaps Future: Recovery via Replay 1. Client can pause callbacks, or… 2. Client can request a "replay" of missed events 3. Recovered events will be delivered in order (before new events)
  25. 25 To Learn More…

  26. Thank you! @paulofallon