Skip to content

Instantly share code, notes, and snippets.

@bjyurkovich
Last active February 27, 2017 03:09
Show Gist options
  • Save bjyurkovich/4b0ee39be40c68c027f05eaacdd4c37a to your computer and use it in GitHub Desktop.
Save bjyurkovich/4b0ee39be40c68c027f05eaacdd4c37a to your computer and use it in GitHub Desktop.
Example of transactionalized microservice approach...

Take for example 2 different microservices, user, address and patient with a gateway.

Upon a creation of a patient, both user and address need to also be created. Therefore, let's say that a call to create a patient comes in from the frontend client:

POST /patient
host: gateway.com
content-type: application/json
{
  "name" : "Patient Q. Public",
  "address" : "address",
  "email" : "p@p.com",
  "password": "pass"
}

Upon receiving the request, the gateway must call three different microservices: address, user, and patient, in that order. Before commencing the first address creation, a unique xid is generated by the gateway.

First Gateway Call: Address MS

Gateway makes a call to address to create an address record:

POST /address
HOST address.com
xa-id: xid
{
  "address" : "address"
}

A address creation success responds with:

{
  "addressId" : "aID"
}

Second Gateway Call: User MS

...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment