microservices, containers, databases and persistence models · microservices interact by...
TRANSCRIPT
![Page 1: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/1.jpg)
Copyright©2017, Oracleand/oritsaffiliates.Allrightsreserved.|
Microservices,Containers,DatabasesandPersistenceModelsTIP4071
Kuassi MensahDirectorProductManagement,Oracle
PaulParkinsonConsultantMemberTechnicalStaff,Oracle
October23,2018
![Page 2: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/2.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
SafeHarborStatement
Thefollowingisintendedtooutlineourgeneralproductdirection.Itisintendedforinformationpurposesonly,andmaynotbeincorporatedintoanycontract.Itisnotacommitmenttodeliveranymaterial,code,orfunctionality,andshouldnotberelieduponinmakingpurchasingdecisions.Thedevelopment,release,timing, andpricingofanyfeaturesorfunctionalitydescribedforOracle’sproductsmaychangeandremainsatthesolediscretionofOracleCorporation.
![Page 3: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/3.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
Agenda• Concepts:Microservices,Containers,Kubernetes• TransactionModels• MicroservicesPersistenceandDatabases• Demo
3
![Page 4: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/4.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
Concepts:Microservices,Containers,Kubernetes
4
![Page 5: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/5.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
MicroServicesBuildfromScratchorBreakMonolithicappsintoModules• Reducecomplexity• Modulespecificdatamodel• Scaleatmodulelevel• FasterDevelopment– API-First,Events-First,DomainDrivenDesign
• Blue/greendeployments• Idempotent• FaultIsolation
![Page 6: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/6.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
Containers/Docker• OSvirtualization• Modularity• Reducedsize• Greaterscaling• Isolatedenvironmentforrunningapps,webserver,persistencestore,etc• Consistencyinruntimeenvironments(includingtestingandproduction)• Operationalsimplicity• Productivity• Enableportabilityfromon-premisestotheCloud
Source:Docker
![Page 7: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/7.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
ContainersOrchestration/KubernetesContainersmustbemanaged(resource),scheduled,loadbalancedandconnectedtoexternalworld
Kubernetes:Greekwordforaship'scaptain• Goal:robustplatformforrunningthousandsofcontainersinproduction.
• Systemforautomatingdeploymentandscalingofcontainerizedapps• Velocity– constantupdates,pause/resumedeployments,versioncontrol
• Immutability– newimageforchanges(maintainshistory,lineage)
• DeclarativeAPI&config– describedesiredstateofsystem,abstracts“how”
• Selfhealing– continuouslymaintainsdesiredstateovertime.
• Autoscaling
![Page 8: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/8.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
Kubernetes/MicroServicesIdealformicroservices…• Pods,arunnableunitofwork(containerimagesdevelopedbydifferentteamsintoasingledeployableunit);usuallyholds1or2containers• Loadbalancing,naminganddiscoveryisolateonemicroservicefromanother• Namespacesprovideisolationandaccesscontrolsothateachmicroservicecancontrolthedegreetowhichotherservicesinteractwithit.• PlatformservicestellstherestoftheKubernetesenvironmentwhatservices yourapplicationprovides.• Api-registry:tracksofallavailableservicesandtheresourcestheyexpose.
![Page 9: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/9.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
KubernetesPlatformServicesonOKE
9
![Page 10: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/10.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.| 10
PainPointsAddressed
![Page 11: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/11.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
IstioRoutingRules• IstioRouteRulescanbeusedtochangewhichservicereceivesrequests• Thisallowsinvokertopassrequeststodifferentservicewithnocodechangeorredeployment• Routerulescanshifttrafficallatonce,orroutepercentagestonewservices
RouteRule.yaml
kind: VirtualServicemetadata:
name: processnamespace: demo
spec:hosts:- processhttp:- route:
- destination:host: processsubset: v2
11
kind: DestinationRulemetadata:
name: processnamespace: demo
spec:host: processsubsets:- name: v1
labels:version: v1
- name: v2labels:version: v2
![Page 12: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/12.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
EventBroker• Addsrules,callbacks,andstructuretovanillamessagebus• Rulesaresimpleandstraightforward• Rulescanbeupdatedtoalterrequestflow• EBcanleverageanymessagebusimplementationunderneath
EventRule.yaml
apiVersion: auraevents.oracledx.com/v1alpha1kind: Rulemetadata:name: rule-process
labels:auraevents.oracledx.com/eventType:
processspec:
action:url: http://process.demo:2222
callbackURL: http://storefront.sf:8888/callback
12
![Page 13: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/13.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
EventBroker• CloudEvents standard ExampleCloudEvent
{"cloudEventsVersion":"0.1","eventType":"com.example.someevent","source":"/mycontext","eventID":"A234-1234-1234","eventTime":"2018-04-05T17:31:00Z","comExampleExtension1":"value","comExampleExtension2":{"otherValue": 5
},"contentType":"text/xml","data":"<muchwow=\"xml\"/>"
}
13
![Page 14: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/14.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
SauronIntegration• EasyintegrationofSauronManagedService• Providesvisualrepresentationofapplicationandsystemmetrics• ProvidesalertingfeaturesviaeMail,Slack,etc.
Prometheusconfig- job_name: 'events-broker'
scrape_interval: 5s
scrape_timeout: 5s
static_configs:
- targets: ['129.213.46.56:30350']
• Businessmetricsbasedonsmartfilteringofeventmetricsindashboard
14
![Page 15: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/15.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
MarketplaceProvisioningofATPDBaaS• ServiceBrokeraddsconnectioninfointoclusterviaKubernetesSecrets• ServiceiswrittentoconsumeSecret• Thisallowsservicetobedeployedindifferentenvironmentswithoutanycodechanges,andpickuptheappropriateDBconnectionautomatically
Deployment.yamlenv: - name:DB_ADMIN_USER valueFrom:
secretKeyRef:name:atp-demo-binding
key:user_name - name:DB_ADMIN_PWD valueFrom:
secretKeyRef:name:atp-user-cred
key:password - name:WALLET_PWD valueFrom:
secretKeyRef:name:atp-user-cred
key:wallet_password volumeMounts: - name:creds mountPath:/db-demo/creds
15
![Page 16: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/16.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
TransactionsModels
16
![Page 17: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/17.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
MicroServices Integration• AnapplicationbecomeanassemblyofMicroServices thatcommunicateamongthemselves• MSintegrationchoices:filesystem,database,RPC,Event• Event-basedIntegration:bestchoice– Asynchronous,loosecoupling– Pub/Sub,Notification– Statetransfer– Immutable– SupportforEventSourcingandCommandQueryResponsibilitySegratation (CQRS)
![Page 18: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/18.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
EventSourcingMicroservicesinteractby”sourcingevents”in/outfromtheEventstoreviatheEventBroker• Eventstore(Kafka,AQinthefutureorvanillaOracleDB)isthesinglesourceoftruth:• Producers:logeventsintheEventstorethenpublishanotification• Consumers:notifiedwhenEventsarepublishedthen“read”theEventstore
WebServer Shipping ServiceOrdersService
PublishEvent
ReceiveEvent
![Page 19: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/19.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
CommandQueryResponsibilitySegregation- CQRSSeparationofresponsibilitieswithinaboundedcontext(Designdomain)• Commands:makechangestostate/data-- donotquerystate
• Queries:viewstate/data(scalewithMaterializedViews)-- donotchangestate
• OftencombinedwithEventSourcing
WebServer Shipping ServiceOrdersServiceCommand
Query
MaterializedViews
![Page 20: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/20.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
BusinessTransactions– RequirementsDistributedTransactionsthatspanmultiplemicroservices– E.g.,Bookingatripinclude:flight,hotel,car,shows
• MicroserviceAcallsBthatcallsC.– TheworkfloworbusinesstransactioncommitsonlywhenCcompletes
• HowdoyouundoA&BshouldCfail?– Traditionaltwo-phaseCOMMITTXisananti-patternwithMicroServices– Eachservicecommitsindividually(locally):howtoensureconsistency?• SAGAPattern• HighconcurrencywithEscrow/Promises
![Page 21: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/21.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
BusinessTransactionsConsistencywithSAGAPattern“Asagaisasequenceoflocaltransactions.Eachlocaltransactionupdatesthestate(database)andpublishesamessageoreventtotriggerthenextlocaltransaction inthesaga.Ifalocaltransaction failsbecauseitviolatesabusinessrulethenthesagaexecutesaseriesofcompensating transactions thatundothechanges thatweremadebytheprecedinglocaltransactions.”https://microservices.io/patterns/data/saga.html
Twoapproachesforcompensatingfailedmember(s)ofadistributedTx• Choreography– Theservicesinteractwitheachothertocoordinatewellknown/definedactivity(thedemohasanexample)
• Orchestration– Anorchestratorisusedtocoordinatetheactivity.– Allmessagesarepassedthrough(interceptedandissuedby)thisorchestrator.
• CompensationcansimplybeTxABORT (thiscanbeautomated)
![Page 22: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/22.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
BusinessTransactionsConsistencywithEscrow/PromisesEscrow– longrunningbusinesstransactions• Counters(anycolumnwith“commutative”properties)usedforinventoriesmanagement– Stockonhand,money/share/creditofaccount,availableseats,...– manipulatedwithplus/minus-- commutative– Onerequestissufficientamount := amount+/-change
• Queriesreturntwodistinctstates:#availableinstock,#inflow• Benefits:parallelupdate,automaticcompensation(theinversefunction)
Promises(notJava/NodeJSpromises)
• Apromiseisagrantedescrowrequestwithtimelimits(i.e.,On-holdreservation)– Expirationneedscarefulhandlingofraceconditions
![Page 23: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/23.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
MicroservicesPersistenceandDatabasesDataModels,Domains,Databases
23
![Page 24: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/24.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
PolyglotorMulti-ModelDatabase?Microservicesarchitecturegoals:flexibilityandagility• Polyglotsystem– aspecializeddatabaseforeachmicroservice– mayleadtoanexpensiveanddifficultplatformtooperate
• Multi- modeldatabase(i.e.,AutonomousTransactionProcessing)– EachservicegetsorshareanATPserviceinstance– highavailabilityanddurabilityoptions
Spatial
Graph
Relational
XML UnstructuredData
![Page 25: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/25.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
OracleAutonomousDatabase
2525
Self-Driving• Automatesallmonitoring,managementandtuning
• Createsmissioncriticalscale-outdatabasewithDR
• Fullcompatibilityenablessimpledatabasemigration
Self-Repairing• Recoversautomaticallyfromanyfailure
• 99.995%uptimeincludingmaintenance,guaranteed
• Elasticallyscalescomputeorstorageasneeded
Self-Securing• Automaticallyappliessecurityupdatesonline
• Secureconfigurationwithfulldatabaseencryption
• SensitivedatahiddenfromOracleorcustomeradmins
![Page 26: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/26.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
PDBSharding forMicroservices
• PDBSharding inDB19c– EachPDBcanbesharded acrossmultipleCDBs
• Providesfaultisolationandgeo-distributionformicroservices– LossofanentireCDBmakesonlypartofaPDBunavailable
• Alsoallowseachmicroservices toscaleitsPDBindividually– Moreefficientuseofresourcescomparedtoscalingamonolithicapplication(CDB).
26
Scalability,faultisolationandgeo-distribution Shard-1 Shard-1Shard-1
Shard-2 Shard-2
Shard-3
Recomm
ProductCatalog
ProductCatalog
ProductCatalog
CheckOut
CheckOut
![Page 27: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/27.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
OnlineShoppingKafkaasEventBrokerandStore
Catalog Cart Order Inventory Shipping
PlaceOrder
BrowseCatalog Product
InCart
KubernetesEventBrokerandEventRules
Kafka/EventStore/EventLog
PublishCloudEvent
ConsumeEvent
![Page 28: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/28.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
AQSupportforMicroservices• AQ/ATPasEventstore• QueueoperationsandDMLDataandmessageinthesamelocaltransaction• Sharded Queuesfurnishhighscalability• Transactedsessionguaranteesnolossofmessageandexactlyoncedelivery
• Clientinitiatednotification• Handleslargemessagebacklogs
• Queuelevelaccessprivileges(enqueue,dequeue)supportsCQRS• AQsupportforSAGA-patterndistributedtransactions• HighAvailabilityandDisasterRecovery
![Page 29: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/29.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
OnlineShoppingKafkaEventBroker&Store+AQMessageproviderservice
Catalog Cart Order Inventory Shipping
PlaceOrder(insertdb+AQmessage)
BrowseCatalog Product
InCart
K8EventBrokerandEventRules
Kafka/EventStore/EventLog
AQEventProviderService
CloudEvent
![Page 30: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/30.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
AQEnhancementstoSupportMicroServices• RetentionsupportinSharded Queues• CloudEventssupport• Logcompaction• AutonomousQueuesinDBaaS• ChangeQueryNotificationsupportinATPusingAQsecurenotification• Lightweight,seekable andretroactivesubscribers• Topicauto-creation• KafkaAPI(Java)
![Page 31: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/31.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
OnlineShoppingAQasEventBrokerandStore
Catalog Cart Order Inventory Shipping
PlaceOrder(insertdb+AQmessage)
BrowseCatalog Product
InCart
AQBroker,Storeand EventRules
Kafka/EventStore/EventLog
AQEventProviderService
![Page 32: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/32.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
AsynchronousDatabaseAccessforMicroServicesMicroservicesarchitecturegoals:flexibilityandagility• SynchronousDBAccess(JDBC)– Themicroservicewaitstilldataupdate(DML)iscompleted– Publishestheevent
• AsynchronousDbAccess(ADBA)– ThemicroservicesubmitsaDMLoperation+AQeventpublisgingthenmoveson.a) Create a transaction object b) create/submit a RowCountOperation to insert an orderc) get a CompletionStaged) create another RowCountOperation to publish an AQ event e) session.commitMaybeRollback(trans) f) submit the whole transaction and return
– Hands-onlabandSession@https://bit.ly/2DzV3uT
![Page 33: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/33.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
RefactoringMonolithic
• CapturesaSQLTuningSet(STS)whileaSQLworkloadisrunning• ProducesaMapofSQLvsTables• GeneratesaGraph
![Page 34: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/34.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
RefactoringMonolithic– BoundedContexts
• Identifynon-conflictingdatamodel• DefineserviceswithinBoundedContextsboundaries
![Page 35: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/35.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
Demo
35
![Page 36: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/36.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
OnlineShopping
Catalog Cart Order Inventory Supplier
PlaceOrder(insertdb+AQmessage)
BrowseCatalog Product
InCart
K8EventBrokerandEventRules
Kafka/EventStore/EventLog
AQEventProviderService
CloudEvent
![Page 37: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/37.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
OnlineShopping- Workflow1. Catalogservice:Graphdatamodel– notimplemented
2. Orderservice:entersanorderintheDBandpublishesanAQmessageinthesamelocalTx
3. Dbeventprovider:picksuptheAQmessagepublishesittotheCloudEventBroker
4. Supplierservice:suppliestheInventoryserviceandpublishesanAQmessageinthesamelocalTx.
5. Inventoryservice:receivesanOrderplaceeventthenpublishesa“lackofinventoryfororderitem”event
6. Orderservice:picksupthateventandconstructsitsstatefromtheeventsourcingmechanismw/oqueryingthedatabase
![Page 38: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/38.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
![Page 39: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/39.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
![Page 40: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/40.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
![Page 41: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/41.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
![Page 42: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/42.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
![Page 43: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/43.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
![Page 44: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/44.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
![Page 45: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/45.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
![Page 46: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/46.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
![Page 47: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/47.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
Reportoffailedordertoclient(theresultofmissinginventory)…
![Page 48: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/48.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
OrderinsertedintableandAQmessagesentinsamelocaltransaction(src code)…
![Page 49: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/49.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
OrderservicelogsshowinginsertoforderandAQsend
OrderinsertedintableandAQmessagesentinsamelocaltransaction(logs)…
![Page 50: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/50.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
AQEventproviderserviceMediatingAQmessagereceivedfromitintoaCloudEventthatispublishedtoeventbrokerforprocessingbasedonrules.Therecanbemultiplerulesforasingleeventtype(eg ordercompletiontriggersemail,delivery,etc.notification)
![Page 51: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/51.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
![Page 52: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/52.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
InventoryservicereceivingeventasaresultofruleprocessingoforderplacedCloudeventandthenpublishingeventindicating(lackof)inventoryfororderitem.
![Page 53: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/53.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
Orderservicereceivinginventoryeventandcancellingorderasaresult(settingstatustofailedandreturningittotheclient).
Choreographysaga:servicescoordinatedirectlywitheachothertomaintaindataintegrityforabusinessactivity.E.g.,the lackofinventory(intheinventoryservice/database)inthiscaseresultsinacancelled/failedorder(intheorderservice/database).
![Page 54: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/54.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
Supplierserviceinterfacetoinventoryserviceaddsinventory…
![Page 55: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/55.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
Reportoffailedordertoclient(theresultofinventorynowexisting)…
![Page 56: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/56.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
Samemessage/workflowandorderisnowsuccessfulasinventoryexists.
![Page 57: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/57.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
![Page 58: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/58.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
CQRS(aggregate)queryprovidingdatagleanedfromeventsourcing.Dataissourcedfromeventsreceivedandeachservicebuildsandaccessesthespecificstate/representationitrequireslocallyallowingforCommandQueryResponsibilitySegregation.Theorderserviceorderdetail,eg,ineffecthasinformationfromotherservices’databases(inventoryandsuggesteditems).
![Page 59: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/59.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
QandA
![Page 60: Microservices, Containers, Databases and Persistence Models · Microservices interact by ”sourcing events” in/out from the Event store via the Event Broker • Event store (Kafka,](https://reader030.vdocuments.mx/reader030/viewer/2022040419/5e02eb08d9e2ea2f2040e687/html5/thumbnails/60.jpg)
Copyright©2017,Oracleand/oritsaffiliates.Allrightsreserved.|
SeeourNextSessions@https://bit.ly/2DzV3uT
60