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

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

More Decks by API Strategy & Practice Conference

Other Decks in Technology

Transcript

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

    @paulofallon Enterprise Architect, Cox Automotive
  2. 2

  3. 3

  4. 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
  5. 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
  6. 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",
 // ...
 }
  7. 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"
 },
 
 // ...
 }
  8. 9

  9. 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"
 }
 }
 }
  10. 16 API Example: /subscribers POST https://api.manheim.com/subscribers { "callback": "http://www.somecustomer.com/cb", "headers":

    { "Authorization": "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" }, "email": "[email protected]" } Location: https://api.manheim.com/subscribers/id/005739ae-625b...
  11. 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')
  12. 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"
 ]
  13. 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"] }
  14. 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..." } }
  15. 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...
  16. 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)