Dennis Traub, Developer Advocate, Amazon Web Services
Twitter: @dtraub
Podcast: bit.ly/aws-podcast
Application Integration Patterns
for Microservices
Application Integration Patterns
(not only) for Microservices
Dennis Traub, Developer Advocate, Amazon Web Services
Twitter: @dtraub
Podcast: bit.ly/aws-podcast
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Two Architectural Principles:
- Divide and Conquer
- Loose (not lousy) Coupling
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“If your application is cloud native, or
large-scale, or distributed, and
doesn’t include a messaging
component, that’s probably a bug.”
Tim Bray
Former Senior Principal Engineer at AWS
Co-Author of the original XML Spec
Potential drawbacks of
synchronous systems
Synchronous systems are tightly
coupled
A problem in a synchronous
downstream dependency has
immediate impact on the upstream
callers
Retries from upstream callers can all
too easily fan out and amplify
problems
Photo: Dirk Fröhner
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Message exchange
One way Request response
Message
channel
Receiver
No response expected
Synchronous vs. fire-and-forget
Response expected
Return address
Correlation ID
Sender
Message
channel
Responder
Requester
Message
channel
Message channels
Point-to-point (queue) Publish-subscribe (topic)
Consumed by one receiver
Easy to scale
Flatten peak loads
Consumed by all subscribers
Durable subscriber
Receivers
Sender
Queue
Subscribers
Publisher
Topic
Message channels
Point-to-point (queue) Publish-subscribe (topic)
AWS service for queue functionality:
Amazon Simple Queue Services (Amazon SQS)
Serverless & cloud-native
AWS service for topic functionality:
Amazon Simple Notification Service (Amazon SNS)
Serverless & cloud-native
Receivers
Sender
Subscribers
Publisher
Amazon SQS Amazon SNS
Message channels
Point-to-point (queue) Publish-subscribe (topic)
AWS service for queue functionality (nonserverless):
Amazon MQ (managed Apache Active MQ)
For applications constrained to protocols like JMS,
AMQP, etc.
AWS service for topic functionality (nonserverless):
Amazon MQ (managed Apache Active MQ)
For applications constrained to protocols like JMS,
AMQP, etc.
Receivers
Sender
Subscribers
Publisher
Amazon MQ Amazon MQ
Message channels
Visibility timeout, inflight messages, message acknowledgement
Time
Receive
message
Receive
message
Delete or acknowledge
message
Visibility timeout
🔥
Time
Visibility timeout
Receive
message
Receive
message
Receive
message
Receive
message
Message channels
Topic-queue-chaining
Allows fan-out and receiver scale-out at the same time
Publisher
Topic
Queue
Queue
Receivers
Application 1
Application 2
Message channels
Dead-letter queue
Transient failure mitigation
Poison-pill handling
Sender
Queue
Receivers
X
Dead-letter
queue
Message channels
FIFO queue Message groups
Guaranteed ordering Messages grouped by discriminator attribute
Example: Amazon SQS with sender provided message
Group IDs: No further consumption as long as messages
with particular message group IDs are invisible
Queue
Receiver
Sender
Receivers
Sender
Queue
Order
Message channels
FIFO queue Message groups
Guaranteed ordering Messages grouped by discriminator attribute
Example: Amazon SQS with sender provided message
Group IDs: No further consumption as long as messages
with particular message group IDs are invisible
Queue
Receiver
Sender
Receivers
Sender
Queue
Order
Message channels
FIFO queue Message groups
Guaranteed ordering Messages grouped by discriminator attribute
Example: Amazon SQS with sender provided message
Group IDs: No further consumption as long as messages
with particular message group IDs are invisible
Queue
Receiver
Sender
Receivers
Sender
Queue
Order
Message channels
FIFO queue Message groups
Guaranteed ordering Messages grouped by discriminator attribute
Example: Amazon SQS with sender provided message
Group IDs: No further consumption as long as messages
with particular message group IDs are invisible
Queue
Receiver
Sender
Receivers
Sender
Queue
Order
Message channels
FIFO queue Message groups
Guaranteed ordering Messages grouped by discriminator attribute
Example: Amazon SQS with sender provided message
Group IDs: No further consumption as long as messages
with particular message group IDs are invisible
Queue
Receiver
Sender
Receivers
Sender
Queue
Order
Message channels
FIFO queue Message groups
Guaranteed ordering Messages grouped by discriminator attribute
Example: Amazon SQS with sender provided message
Group IDs: No further consumption as long as messages
with particular message group IDs are invisible
Queue
Receiver
Sender
Receivers
Sender
Queue
Order
Message channels
FIFO queue Message groups
Guaranteed ordering Messages grouped by discriminator attribute
Example: Amazon SQS with sender provided message
Group IDs: No further consumption as long as messages
with particular message group IDs are invisible
Queue
Receiver
Sender
Receivers
Sender
Queue
Order
Message channels
FIFO queue Message groups
Guaranteed ordering Messages grouped by discriminator attribute
Example: Amazon SQS with sender provided message
Group IDs: No further consumption as long as messages
with particular message group IDs are invisible
Queue
Receiver
Sender
Receivers
Sender
Queue
Order
Message channels
FIFO queue Message groups
Guaranteed ordering Messages grouped by discriminator attribute
Example: Amazon SQS with sender provided message
Group IDs: No further consumption as long as messages
with particular message group IDs are invisible
Queue
Receiver
Sender
Receivers
Sender
Queue
Order!
Message channels
Message delivery QoS
At least once
At most once
Exactly once
Queue
Receiver
Sender
Exactly once? Well!
How to deal with a situation where the message was
consumed but never acknowledged?
→ Your systems still have to be able to
handle duplicate messages
→ Messages should be processed in
an idempotent manner
Choose between at least once or at most once
Message routing
Message filter Recipient list
Receive only a relevant subset of messages
Controlled by subscriber
Publisher remains completely unaware
Send only a relevant subset of messages to a subscriber
Controlled by publisher or separate component
Potentially adds coupling
Subscribers
Publisher
Subscribers
Publisher
Topic
color = blue
color = yellow
Recipient
list
Message routing
Scatter-gather
Requester
Topic
Responders
Queue
Aggregator Processor
How to distribute a request across potentially interested or relevant parties and capture their individual responses?
- RFQ scenarios, search for best response, etc.
- Parallel processing scenarios
Message routing
Pipes and filters
Event triggers chain of processing steps (“filters”)
Knowledge of destination for next steps is wired into each filter
Event source Pipe Filter Filter
Pipe Pipe Result target
…
Filter
Step 1 Step 2 Step n
Message routing
Saga orchestration
Event triggers orchestrated workflow
Knowledge of workflow is externalized into orchestrator component, as well as for potential rollback
Workflow participants remain as loosely coupled as possible
Processor
Processor
Processor
Processor
Event source Orchestrator
…
Step 1
Step 2 Step n-1
Step n
Result target
Message routing
Saga orchestration
AWS service for saga orchestration (serverless):
AWS Step Functions
Processor
Processor
Processor
Processor
Event source Orchestrator
…
Step 1
Step 2 Step n-1
Step n
Result target
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Use case: Submit a ride completion
AWS Cloud
{
"from": "...",
"to": "...",
"duration": "...",
"distance": "...",
"customer": "...",
"fare": "..."
}
Unicorn
Wild Rydes
unicorn app
https://...
submit-ride-completion
201 Created
Location: ...
Content-Location: ...
{
<cmpl-ride-repr>
}
Rides
store
Unicorn
management
service
Use case: Submit a ride completion
AWS Cloud
Customer
notification
service
Customer
accounting
service
Customer
loyalty
service
Data lake
ingestion
service
Extraordinary
rides
service
{
"from": "...",
"to": "...",
"duration": "...",
"distance": "...",
"customer": "...",
"fare": "..."
}
Unicorn
Wild Rydes
unicorn app
https://...
submit-ride-completion
201 Created
Location: ...
Content-Location: ...
{
<cmpl-ride-repr>
}
Rides
store
Unicorn
management
service
Use case: Submit a ride completion
AWS Cloud
Customer
notification
service
Customer
accounting
service
Customer
loyalty
service
Data lake
ingestion
service
Extraordinary
rides
service
{
"from": "...",
"to": "...",
"duration": "...",
"distance": "...",
"customer": "...",
"fare": "..."
}
Interested in rides with
fare >= x
distance >= y
Rides
store
Unicorn
Wild Rydes
unicorn app
https://...
submit-ride-completion
Unicorn
management
service
201 Created
Location: ...
Content-Location: ...
{
<cmpl-ride-repr>
}
Use case: Submit a ride completion
AWS Cloud
Customer
notification
service
Customer
accounting
service
Customer
loyalty
service
Data lake
ingestion
service
Extraordinary
rides
service
{
"from": "...",
"to": "...",
"duration": "...",
"distance": "...",
"customer": "...",
"fare": "..."
}
Unicorn
Wild Rydes
unicorn app
https://...
submit-ride-completion
201 Created
Location: ...
Content-Location: ...
{
<cmpl-ride-repr>
}
Rides
store
Unicorn
Management
Service
Interested in rides with
fare >= x
distance >= y
Integration via database?
Use case: Submit a ride completion
AWS Cloud
Customer
notification
service
Customer
accounting
service
Customer
loyalty
service
Data lake
ingestion
service
Extraordinary
rides
service
{
"from": "...",
"to": "...",
"duration": "...",
"distance": "...",
"customer": "...",
"fare": "..."
}
Unicorn
Wild Rydes
unicorn app
https://...
submit-ride-completion
201 Created
Location: ...
Content-Location: ...
{
<cmpl-ride-repr>
}
Rides
store
Unicorn
Management
Service
Integration via database?
Oh my!
Interested in rides with
fare >= x
distance >= y
Use case: Submit a ride completion
AWS Cloud
Customer
notification
service
Customer
accounting
service
Customer
loyalty
service
Data lake
ingestion
service
Extraordinary
rides
service
{
"from": "...",
"to": "...",
"duration": "...",
"distance": "...",
"customer": "...",
"fare": "..."
}
Unicorn
Wild Rydes
unicorn app
https://...
submit-ride-completion
201 Created
Location: ...
Content-Location: ...
{
<cmpl-ride-repr>
}
Rides
store
Unicorn
Management
Service
Integration via REST APIs?
Interested in rides with
fare >= x
distance >= y
Use case: Submit a ride completion
AWS Cloud
Customer
notification
service
Customer
accounting
service
Customer
loyalty
service
Data lake
ingestion
service
Extraordinary
rides
service
{
"from": "...",
"to": "...",
"duration": "...",
"distance": "...",
"customer": "...",
"fare": "..."
}
Unicorn
Wild Rydes
unicorn app
https://...
submit-ride-completion
201 Created
Location: ...
Content-Location: ...
{
<cmpl-ride-repr>
}
Rides
store
Unicorn
Management
Service
Integration via REST APIs?
Absolutely, but …
Interested in rides with
fare >= x
distance >= y
Use case: Submit a ride completion
AWS Cloud
Customer
notification
service
Customer
accounting
service
Customer
loyalty
service
Data lake
ingestion
service
Extraordinary
rides
service
{
"from": "...",
"to": "...",
"duration": "...",
"distance": "...",
"customer": "...",
"fare": "..."
}
https://...
https://...
https://...
https://...
https://...
Recipient list
Unicorn
Wild Rydes
unicorn app
https://...
submit-ride-completion
201 Created
Location: ...
Content-Location: ...
{
<cmpl-ride-repr>
}
Rides
store
Unicorn
management
service
Use case: Submit a ride completion
AWS Cloud
Customer
notification
service
Customer
accounting
service
Customer
loyalty
service
Data lake
ingestion
service
Extraordinary
rides
service
{
"from": "...",
"to": "...",
"duration": "...",
"distance": "...",
"customer": "...",
"fare": "..."
}
https://...
https://...
https://...
https://...
https://...
Recipient list service
Unicorn
Request
distribution
service
https://...
Wild Rydes
unicorn app
https://...
submit-ride-completion
201 Created
Location: ...
Content-Location: ...
{
<cmpl-ride-repr>
}
Rides
store
Unicorn
management
service
Use case: Submit a ride completion
AWS Cloud
Customer
notification
service
Customer
accounting
service
Customer
loyalty
service
Data lake
ingestion
service
Extraordinary
rides
service
{
"from": "...",
"to": "...",
"duration": "...",
"distance": "...",
"customer": "...",
"fare": "..."
}
https://...
https://...
https://...
https://...
https://...
Self-managed filtering
Unicorn
Request
distribution
service
https://...
Wild Rydes
Unicorn app
https://...
submit-ride-completion
201 Created
Location: ...
Content-Location: ...
{
<cmpl-ride-repr>
}
Rides
store
Unicorn
management
service
Interested in rides with
fare >= x
distance >= y
Use case: Submit a ride completion
AWS Cloud
Customer
notification
service
Customer
accounting
service
Customer
loyalty
service
Data lake
ingestion
service
Extraordinary
rides
service
{
"from": "...",
"to": "...",
"duration": "...",
"distance": "...",
"customer": "...",
"fare": "..."
}
https://...
https://...
https://...
https://...
https://...
Self-managed filtering
Unicorn
Request
Distribution
Service
https://...
Wild Rydes
unicorn app
https://...
submit-ride-completion
201 Created
Location: ...
Content-Location: ...
{
<cmpl-ride-repr>
}
Rides
store
Unicorn
Management
Service
Interested in rides with
fare >= x
distance >= y
Integration via messaging?
Absolutely!
Use case: Submit a ride completion
AWS Cloud
Customer
notification
service
Customer
accounting
service
Customer
loyalty
service
Data lake
ingestion
service
Extraordinary
rides
service
{
"from": "...",
"to": "...",
"duration": "...",
"distance": "...",
"customer": "...",
"fare": "..."
}
Publish-subscribe (topic)
Unicorn
Ride
completion
topic
Wild Rydes
unicorn app
https://...
submit-ride-completion
201 Created
Location: ...
Content-Location: ...
{
<cmpl-ride-repr>
}
Rides
store
Unicorn
management
service
Use case: Submit a ride completion
AWS Cloud
Customer
notification
service
Customer
accounting
service
Customer
loyalty
service
Data lake
ingestion
service
Extraordinary
rides
service
{
"from": "...",
"to": "...",
"duration": "...",
"distance": "...",
"customer": "...",
"fare": "..."
}
SNS message filter:
fare >= x
distance >= y
Message filter
Unicorn
Ride
completion
topic
Wild Rydes
unicorn app
https://...
submit-ride-completion
201 Created
Location: ...
Content-Location: ...
{
<cmpl-ride-repr>
}
Rides
store
Unicorn
management
service
Use case: Submit a ride completion
Unicorn
AWS Cloud
Customer
notification
service
Customer
accounting
service
Customer
loyalty
service
Data lake
ingestion
service
Extraordinary
rides
service
{
"from": "...",
"to": "...",
"duration": "...",
"distance": "...",
"customer": "...",
"fare": "..."
}
Ride
completion
topic
Topic-queue-chaining
Wild Rydes
unicorn app
https://...
submit-ride-completion
201 Created
Location: ...
Content-Location: ...
{
<cmpl-ride-repr>
}
Rides
store
Unicorn
management
service
SNS message filter:
fare >= x
distance >= y
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Use case: Prebooking campaigns
AWS Cloud
Wild Rydes
customer
Wild Rydes
customer app
https://...
submit-ride-prebooking
{
"from": "...",
"to": "...",
"when": "...",
"customer": "..."
}
201 Created
Location: http://...
Content-Location: ...
{
<prebooking-repr>
}
Ride-booking
service
Prebookings
store
Use case: Prebooking campaigns
AWS Cloud
Wild Rydes
customer
Wild Rydes
customer app
https://...
submit-ride-prebooking
{
"from": "...",
"to": "...",
"when": "...",
"customer": "..."
}
201 Created
Location: http://...
Content-Location: ...
{
<prebooking-repr>
}
Ride Booking
Service
Prebookings
store
Massive campaign with CTA:
Book today!
Use case: Prebooking campaigns
AWS Cloud
Wild Rydes
customer
Wild Rydes
customer app
https://...
submit-ride-prebooking
{
"from": "...",
"to": "...",
"when": "...",
"customer": "..."
}
Ride-booking
service
Further decoupling
Use case: Prebooking campaigns
AWS Cloud
Wild Rydes
customer
Wild Rydes
customer app
https://...
submit-ride-prebooking
{
"from": "...",
"to": "...",
"when": "...",
"customer": "..."
}
Ride-booking
service
Further decoupling
Prebooking
submission
resource
Use case: Prebooking campaigns
AWS Cloud
Further decoupling
Wild Rydes
customer
Wild Rydes
customer app
https://...
submit-ride-prebooking
{
"from": "...",
"to": "...",
"when": "...",
"customer": "..."
}
Prebooking
notification
topic
Ride-booking
service
Prebooking
submission
resource
Use case: Prebooking campaigns
AWS Cloud
Further decoupling
Wild Rydes
customer
Wild Rydes
customer app
https://...
submit-ride-prebooking
{
"from": "...",
"to": "...",
"when": "...",
"customer": "..."
}
Prebooking
notification
topic
202 Accepted
Location: ...
Content-Location: ...
{
<task-status-repr>
}
Ride-booking
service
Prebooking
submission
resource
Use case: Prebooking campaigns
AWS Cloud
Further decoupling
Prebooking
notification
buffer queue
Prebooking
processing
buffer queue
Wild Rydes
customer
Wild Rydes
customer app
https://...
submit-ride-prebooking
{
"from": "...",
"to": "...",
"when": "...",
"customer": "..."
}
Prebooking
notification
topic
Ride-booking
service
Prebooking
submission
resource
202 Accepted
Location: ...
Content-Location: ...
{
<task-status-repr>
}
Use case: Prebooking campaigns
AWS Cloud
Data lake
ingestion
service
Ride-booking
service /
Prebooking
processing
resource
Further decoupling
Prebooking
notification
buffer queue
Prebooking
processing
buffer queue
Wild Rydes
customer
Wild Rydes
customer app
https://...
submit-ride-prebooking
{
"from": "...",
"to": "...",
"when": "...",
"customer": "..."
}
Prebooking
notification
topic
Ride-booking
service
Prebooking
submission
resource
202 Accepted
Location: ...
Content-Location: ...
{
<task-status-repr>
}
Use case: Prebooking campaigns
AWS Cloud
Data lake
ingestion
service
Further decoupling
Prebooking
notification
buffer queue
Prebooking
processing
buffer queue
Wild Rydes
customer
Wild Rydes
customer app
https://...
submit-ride-prebooking
{
"from": "...",
"to": "...",
"when": "...",
"customer": "..."
}
Prebooking
notification
topic
Ride-booking
service
Prebooking
submission
resource
202 Accepted
Location: ...
Content-Location: ...
{
<task-status-repr>
} Massive campaign with CTA:
No, really! Book now!
Ride-booking
service /
Prebooking
processing
resource
Use case: Prebooking campaigns
Wild Rydes
customer
Wild Rydes
customer app
https://...
AWS Cloud
Data lake
ingestion
service
Action=SendMessage
&MessageBody=...
...
Prebooking
notification
topic
Even further decoupling
Prebooking
notification
buffer queue
Prebooking
processing
buffer queue
Prebooking
submission
buffer queue
200 OK
...
<SendMessageResponse>
...
</SendMessageResponse> Ride-booking
service
Prebooking
submission
resource
Ride-booking
service /
Prebooking
processing
resource
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Use case: Instant ride RFQ
Wild Rydes
customer
Wild Rydes
customer app
https://...
submit-instant-ride-rfq
AWS Cloud
Ride-booking
service
{
"from": "...",
"to": "...",
"customer": "..."
}
Scatter-gather
202 Accepted
Location: ...
Content-Location: ...
{
"links": { ... },
"status": "...",
"eta": "..."
}
Use case: Instant ride RFQ
Wild Rydes
customer
Wild Rydes
customer app
https://...
submit-instant-ride-rfq
AWS Cloud
Ride-booking
service
{
"from": "...",
"to": "...",
"customer": "..."
}
Request for
quotes topic
Scatter-gather
202 Accepted
Location: ...
Content-Location: ...
{
"links": { ... },
"status": "...",
"eta": "..."
}
Unicorn Management Service
Use case: Instant ride RFQ
Wild Rydes
customer
Wild Rydes
customer app
https://...
submit-instant-ride-rfq
AWS Cloud
Ride-booking
service
Unicorn
management
resource
Unicorn
management
resource
Unicorn
management
resource
{
"from": "...",
"to": "...",
"customer": "..."
}
Request for
quotes topic
Scatter-gather
…
202 Accepted
Location: ...
Content-Location: ...
{
"links": { ... },
"status": "...",
"eta": "..."
}
Unicorn Management Service
Use case: Instant ride RFQ
Wild Rydes
customer
Wild Rydes
customer app
https://...
submit-instant-ride-rfq
AWS Cloud
Ride-booking
service
Unicorn
management
resource
Unicorn
management
resource
Unicorn
management
resource
{
"from": "...",
"to": "...",
"customer": "..."
}
Request for
quotes topic
Scatter-gather
RFQ response
queue
…
202 Accepted
Location: ...
Content-Location: ...
{
"links": { ... },
"status": "...",
"eta": "..."
}
Unicorn Management Service
Use case: Instant ride RFQ
Wild Rydes
customer
Wild Rydes
customer app
https://...
submit-instant-ride-rfq
AWS Cloud
Ride-booking
service
Unicorn
management
resource
Unicorn
management
resource
Unicorn
management
resource
{
"from": "...",
"to": "...",
"customer": "..."
}
Request for
quotes topic
Scatter-gather
202 Accepted
Location: ...
Content-Location: ...
{
"links": { ... },
"status": "...",
"eta": "..."
}
RFQ response
queue
…
Unicorn Management Service
Use case: Instant ride RFQ
Wild Rydes
customer
Wild Rydes
customer app
https://...
retrieve-rfq-status
AWS Cloud
Ride-booking
service
Unicorn
management
resource
Unicorn
management
resource
Unicorn
management
resource
Request for
quotes topic
Scatter-gather
RFQ response
queue
…
Unicorn Management Service
Use case: Instant ride RFQ
Wild Rydes
customer
Wild Rydes
customer app
https://...
retrieve-rfq-status
AWS Cloud
Ride-booking
service
Unicorn
management
resource
Unicorn
management
resource
Unicorn
management
resource
Request for
quotes topic
Scatter-gather
RFQ response
queue
…
200 OK
{
"links": { ... },
"status": "running",
"eta": "..."
}
Unicorn Management Service
Use case: Instant ride RFQ
Wild Rydes
customer
Wild Rydes
customer app
https://...
retrieve-rfq-status
AWS Cloud
Ride-booking
service
Unicorn
management
resource
Unicorn
management
resource
Unicorn
management
resource
Request for
quotes topic
Scatter-gather
RFQ response
queue
…
200 OK
{
"links": { ...
<link-to-result>
... },
"status": "done"
}
Unicorn Management Service
Use case: Instant ride RFQ
Wild Rydes
customer
Wild Rydes
customer app
https://...
retrieve-rfq-result
AWS Cloud
Ride-booking
service
Unicorn
management
resource
Unicorn
management
resource
Unicorn
management
resource
Request for
quotes topic
Scatter-gather
RFQ response
queue
…
Unicorn Management Service
Use case: Instant ride RFQ
Wild Rydes
customer
Wild Rydes
customer app
https://...
retrieve-rfq-result
AWS Cloud
Ride-booking
service
Unicorn
management
resource
Unicorn
management
resource
Unicorn
management
resource
Request for
quotes topic
Scatter-gather
RFQ response
queue
…
200 OK
{
"links": { ... },
"from": "...",
"to": "...",
"quotes": "..."
}
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Resources
AWS blogs and other content on messaging and application integration
https://aws.amazon.com/messaging/
https://aws.amazon.com/event-driven-architecture/
https://aws.amazon.com/blogs/compute/category/messaging/
The German-language AWS-Podcast
Keep in mind
Loose coupling is always better than lousy coupling
bit.ly/aws-podcast
Vielen Dank für’s Zuschauen!
Dennis Traub, Developer Advocate, Amazon Web Services
Twitter: @dtraub
Podcast: bit.ly/aws-podcast

Application Integration Patterns (not only) for Microservices

  • 1.
    Dennis Traub, DeveloperAdvocate, Amazon Web Services Twitter: @dtraub Podcast: bit.ly/aws-podcast Application Integration Patterns for Microservices
  • 2.
    Application Integration Patterns (notonly) for Microservices Dennis Traub, Developer Advocate, Amazon Web Services Twitter: @dtraub Podcast: bit.ly/aws-podcast
  • 3.
    © 2021, AmazonWeb Services, Inc. or its affiliates. All rights reserved.
  • 4.
    Two Architectural Principles: -Divide and Conquer - Loose (not lousy) Coupling
  • 5.
    © 2021, AmazonWeb Services, Inc. or its affiliates. All rights reserved. “If your application is cloud native, or large-scale, or distributed, and doesn’t include a messaging component, that’s probably a bug.” Tim Bray Former Senior Principal Engineer at AWS Co-Author of the original XML Spec
  • 6.
    Potential drawbacks of synchronoussystems Synchronous systems are tightly coupled A problem in a synchronous downstream dependency has immediate impact on the upstream callers Retries from upstream callers can all too easily fan out and amplify problems Photo: Dirk Fröhner
  • 7.
    © 2021, AmazonWeb Services, Inc. or its affiliates. All rights reserved.
  • 8.
    Message exchange One wayRequest response Message channel Receiver No response expected Synchronous vs. fire-and-forget Response expected Return address Correlation ID Sender Message channel Responder Requester Message channel
  • 9.
    Message channels Point-to-point (queue)Publish-subscribe (topic) Consumed by one receiver Easy to scale Flatten peak loads Consumed by all subscribers Durable subscriber Receivers Sender Queue Subscribers Publisher Topic
  • 10.
    Message channels Point-to-point (queue)Publish-subscribe (topic) AWS service for queue functionality: Amazon Simple Queue Services (Amazon SQS) Serverless & cloud-native AWS service for topic functionality: Amazon Simple Notification Service (Amazon SNS) Serverless & cloud-native Receivers Sender Subscribers Publisher Amazon SQS Amazon SNS
  • 11.
    Message channels Point-to-point (queue)Publish-subscribe (topic) AWS service for queue functionality (nonserverless): Amazon MQ (managed Apache Active MQ) For applications constrained to protocols like JMS, AMQP, etc. AWS service for topic functionality (nonserverless): Amazon MQ (managed Apache Active MQ) For applications constrained to protocols like JMS, AMQP, etc. Receivers Sender Subscribers Publisher Amazon MQ Amazon MQ
  • 12.
    Message channels Visibility timeout,inflight messages, message acknowledgement Time Receive message Receive message Delete or acknowledge message Visibility timeout 🔥 Time Visibility timeout Receive message Receive message Receive message Receive message
  • 13.
    Message channels Topic-queue-chaining Allows fan-outand receiver scale-out at the same time Publisher Topic Queue Queue Receivers Application 1 Application 2
  • 14.
    Message channels Dead-letter queue Transientfailure mitigation Poison-pill handling Sender Queue Receivers X Dead-letter queue
  • 15.
    Message channels FIFO queueMessage groups Guaranteed ordering Messages grouped by discriminator attribute Example: Amazon SQS with sender provided message Group IDs: No further consumption as long as messages with particular message group IDs are invisible Queue Receiver Sender Receivers Sender Queue Order
  • 16.
    Message channels FIFO queueMessage groups Guaranteed ordering Messages grouped by discriminator attribute Example: Amazon SQS with sender provided message Group IDs: No further consumption as long as messages with particular message group IDs are invisible Queue Receiver Sender Receivers Sender Queue Order
  • 17.
    Message channels FIFO queueMessage groups Guaranteed ordering Messages grouped by discriminator attribute Example: Amazon SQS with sender provided message Group IDs: No further consumption as long as messages with particular message group IDs are invisible Queue Receiver Sender Receivers Sender Queue Order
  • 18.
    Message channels FIFO queueMessage groups Guaranteed ordering Messages grouped by discriminator attribute Example: Amazon SQS with sender provided message Group IDs: No further consumption as long as messages with particular message group IDs are invisible Queue Receiver Sender Receivers Sender Queue Order
  • 19.
    Message channels FIFO queueMessage groups Guaranteed ordering Messages grouped by discriminator attribute Example: Amazon SQS with sender provided message Group IDs: No further consumption as long as messages with particular message group IDs are invisible Queue Receiver Sender Receivers Sender Queue Order
  • 20.
    Message channels FIFO queueMessage groups Guaranteed ordering Messages grouped by discriminator attribute Example: Amazon SQS with sender provided message Group IDs: No further consumption as long as messages with particular message group IDs are invisible Queue Receiver Sender Receivers Sender Queue Order
  • 21.
    Message channels FIFO queueMessage groups Guaranteed ordering Messages grouped by discriminator attribute Example: Amazon SQS with sender provided message Group IDs: No further consumption as long as messages with particular message group IDs are invisible Queue Receiver Sender Receivers Sender Queue Order
  • 22.
    Message channels FIFO queueMessage groups Guaranteed ordering Messages grouped by discriminator attribute Example: Amazon SQS with sender provided message Group IDs: No further consumption as long as messages with particular message group IDs are invisible Queue Receiver Sender Receivers Sender Queue Order
  • 23.
    Message channels FIFO queueMessage groups Guaranteed ordering Messages grouped by discriminator attribute Example: Amazon SQS with sender provided message Group IDs: No further consumption as long as messages with particular message group IDs are invisible Queue Receiver Sender Receivers Sender Queue Order!
  • 24.
    Message channels Message deliveryQoS At least once At most once Exactly once Queue Receiver Sender Exactly once? Well! How to deal with a situation where the message was consumed but never acknowledged? → Your systems still have to be able to handle duplicate messages → Messages should be processed in an idempotent manner Choose between at least once or at most once
  • 25.
    Message routing Message filterRecipient list Receive only a relevant subset of messages Controlled by subscriber Publisher remains completely unaware Send only a relevant subset of messages to a subscriber Controlled by publisher or separate component Potentially adds coupling Subscribers Publisher Subscribers Publisher Topic color = blue color = yellow Recipient list
  • 26.
    Message routing Scatter-gather Requester Topic Responders Queue Aggregator Processor Howto distribute a request across potentially interested or relevant parties and capture their individual responses? - RFQ scenarios, search for best response, etc. - Parallel processing scenarios
  • 27.
    Message routing Pipes andfilters Event triggers chain of processing steps (“filters”) Knowledge of destination for next steps is wired into each filter Event source Pipe Filter Filter Pipe Pipe Result target … Filter Step 1 Step 2 Step n
  • 28.
    Message routing Saga orchestration Eventtriggers orchestrated workflow Knowledge of workflow is externalized into orchestrator component, as well as for potential rollback Workflow participants remain as loosely coupled as possible Processor Processor Processor Processor Event source Orchestrator … Step 1 Step 2 Step n-1 Step n Result target
  • 29.
    Message routing Saga orchestration AWSservice for saga orchestration (serverless): AWS Step Functions Processor Processor Processor Processor Event source Orchestrator … Step 1 Step 2 Step n-1 Step n Result target
  • 30.
    © 2021, AmazonWeb Services, Inc. or its affiliates. All rights reserved.
  • 32.
    © 2021, AmazonWeb Services, Inc. or its affiliates. All rights reserved.
  • 33.
    Use case: Submita ride completion AWS Cloud { "from": "...", "to": "...", "duration": "...", "distance": "...", "customer": "...", "fare": "..." } Unicorn Wild Rydes unicorn app https://... submit-ride-completion 201 Created Location: ... Content-Location: ... { <cmpl-ride-repr> } Rides store Unicorn management service
  • 34.
    Use case: Submita ride completion AWS Cloud Customer notification service Customer accounting service Customer loyalty service Data lake ingestion service Extraordinary rides service { "from": "...", "to": "...", "duration": "...", "distance": "...", "customer": "...", "fare": "..." } Unicorn Wild Rydes unicorn app https://... submit-ride-completion 201 Created Location: ... Content-Location: ... { <cmpl-ride-repr> } Rides store Unicorn management service
  • 35.
    Use case: Submita ride completion AWS Cloud Customer notification service Customer accounting service Customer loyalty service Data lake ingestion service Extraordinary rides service { "from": "...", "to": "...", "duration": "...", "distance": "...", "customer": "...", "fare": "..." } Interested in rides with fare >= x distance >= y Rides store Unicorn Wild Rydes unicorn app https://... submit-ride-completion Unicorn management service 201 Created Location: ... Content-Location: ... { <cmpl-ride-repr> }
  • 36.
    Use case: Submita ride completion AWS Cloud Customer notification service Customer accounting service Customer loyalty service Data lake ingestion service Extraordinary rides service { "from": "...", "to": "...", "duration": "...", "distance": "...", "customer": "...", "fare": "..." } Unicorn Wild Rydes unicorn app https://... submit-ride-completion 201 Created Location: ... Content-Location: ... { <cmpl-ride-repr> } Rides store Unicorn Management Service Interested in rides with fare >= x distance >= y Integration via database?
  • 37.
    Use case: Submita ride completion AWS Cloud Customer notification service Customer accounting service Customer loyalty service Data lake ingestion service Extraordinary rides service { "from": "...", "to": "...", "duration": "...", "distance": "...", "customer": "...", "fare": "..." } Unicorn Wild Rydes unicorn app https://... submit-ride-completion 201 Created Location: ... Content-Location: ... { <cmpl-ride-repr> } Rides store Unicorn Management Service Integration via database? Oh my! Interested in rides with fare >= x distance >= y
  • 38.
    Use case: Submita ride completion AWS Cloud Customer notification service Customer accounting service Customer loyalty service Data lake ingestion service Extraordinary rides service { "from": "...", "to": "...", "duration": "...", "distance": "...", "customer": "...", "fare": "..." } Unicorn Wild Rydes unicorn app https://... submit-ride-completion 201 Created Location: ... Content-Location: ... { <cmpl-ride-repr> } Rides store Unicorn Management Service Integration via REST APIs? Interested in rides with fare >= x distance >= y
  • 39.
    Use case: Submita ride completion AWS Cloud Customer notification service Customer accounting service Customer loyalty service Data lake ingestion service Extraordinary rides service { "from": "...", "to": "...", "duration": "...", "distance": "...", "customer": "...", "fare": "..." } Unicorn Wild Rydes unicorn app https://... submit-ride-completion 201 Created Location: ... Content-Location: ... { <cmpl-ride-repr> } Rides store Unicorn Management Service Integration via REST APIs? Absolutely, but … Interested in rides with fare >= x distance >= y
  • 40.
    Use case: Submita ride completion AWS Cloud Customer notification service Customer accounting service Customer loyalty service Data lake ingestion service Extraordinary rides service { "from": "...", "to": "...", "duration": "...", "distance": "...", "customer": "...", "fare": "..." } https://... https://... https://... https://... https://... Recipient list Unicorn Wild Rydes unicorn app https://... submit-ride-completion 201 Created Location: ... Content-Location: ... { <cmpl-ride-repr> } Rides store Unicorn management service
  • 41.
    Use case: Submita ride completion AWS Cloud Customer notification service Customer accounting service Customer loyalty service Data lake ingestion service Extraordinary rides service { "from": "...", "to": "...", "duration": "...", "distance": "...", "customer": "...", "fare": "..." } https://... https://... https://... https://... https://... Recipient list service Unicorn Request distribution service https://... Wild Rydes unicorn app https://... submit-ride-completion 201 Created Location: ... Content-Location: ... { <cmpl-ride-repr> } Rides store Unicorn management service
  • 42.
    Use case: Submita ride completion AWS Cloud Customer notification service Customer accounting service Customer loyalty service Data lake ingestion service Extraordinary rides service { "from": "...", "to": "...", "duration": "...", "distance": "...", "customer": "...", "fare": "..." } https://... https://... https://... https://... https://... Self-managed filtering Unicorn Request distribution service https://... Wild Rydes Unicorn app https://... submit-ride-completion 201 Created Location: ... Content-Location: ... { <cmpl-ride-repr> } Rides store Unicorn management service Interested in rides with fare >= x distance >= y
  • 43.
    Use case: Submita ride completion AWS Cloud Customer notification service Customer accounting service Customer loyalty service Data lake ingestion service Extraordinary rides service { "from": "...", "to": "...", "duration": "...", "distance": "...", "customer": "...", "fare": "..." } https://... https://... https://... https://... https://... Self-managed filtering Unicorn Request Distribution Service https://... Wild Rydes unicorn app https://... submit-ride-completion 201 Created Location: ... Content-Location: ... { <cmpl-ride-repr> } Rides store Unicorn Management Service Interested in rides with fare >= x distance >= y Integration via messaging? Absolutely!
  • 44.
    Use case: Submita ride completion AWS Cloud Customer notification service Customer accounting service Customer loyalty service Data lake ingestion service Extraordinary rides service { "from": "...", "to": "...", "duration": "...", "distance": "...", "customer": "...", "fare": "..." } Publish-subscribe (topic) Unicorn Ride completion topic Wild Rydes unicorn app https://... submit-ride-completion 201 Created Location: ... Content-Location: ... { <cmpl-ride-repr> } Rides store Unicorn management service
  • 45.
    Use case: Submita ride completion AWS Cloud Customer notification service Customer accounting service Customer loyalty service Data lake ingestion service Extraordinary rides service { "from": "...", "to": "...", "duration": "...", "distance": "...", "customer": "...", "fare": "..." } SNS message filter: fare >= x distance >= y Message filter Unicorn Ride completion topic Wild Rydes unicorn app https://... submit-ride-completion 201 Created Location: ... Content-Location: ... { <cmpl-ride-repr> } Rides store Unicorn management service
  • 46.
    Use case: Submita ride completion Unicorn AWS Cloud Customer notification service Customer accounting service Customer loyalty service Data lake ingestion service Extraordinary rides service { "from": "...", "to": "...", "duration": "...", "distance": "...", "customer": "...", "fare": "..." } Ride completion topic Topic-queue-chaining Wild Rydes unicorn app https://... submit-ride-completion 201 Created Location: ... Content-Location: ... { <cmpl-ride-repr> } Rides store Unicorn management service SNS message filter: fare >= x distance >= y
  • 47.
    © 2021, AmazonWeb Services, Inc. or its affiliates. All rights reserved.
  • 48.
    Use case: Prebookingcampaigns AWS Cloud Wild Rydes customer Wild Rydes customer app https://... submit-ride-prebooking { "from": "...", "to": "...", "when": "...", "customer": "..." } 201 Created Location: http://... Content-Location: ... { <prebooking-repr> } Ride-booking service Prebookings store
  • 49.
    Use case: Prebookingcampaigns AWS Cloud Wild Rydes customer Wild Rydes customer app https://... submit-ride-prebooking { "from": "...", "to": "...", "when": "...", "customer": "..." } 201 Created Location: http://... Content-Location: ... { <prebooking-repr> } Ride Booking Service Prebookings store Massive campaign with CTA: Book today!
  • 50.
    Use case: Prebookingcampaigns AWS Cloud Wild Rydes customer Wild Rydes customer app https://... submit-ride-prebooking { "from": "...", "to": "...", "when": "...", "customer": "..." } Ride-booking service Further decoupling
  • 51.
    Use case: Prebookingcampaigns AWS Cloud Wild Rydes customer Wild Rydes customer app https://... submit-ride-prebooking { "from": "...", "to": "...", "when": "...", "customer": "..." } Ride-booking service Further decoupling Prebooking submission resource
  • 52.
    Use case: Prebookingcampaigns AWS Cloud Further decoupling Wild Rydes customer Wild Rydes customer app https://... submit-ride-prebooking { "from": "...", "to": "...", "when": "...", "customer": "..." } Prebooking notification topic Ride-booking service Prebooking submission resource
  • 53.
    Use case: Prebookingcampaigns AWS Cloud Further decoupling Wild Rydes customer Wild Rydes customer app https://... submit-ride-prebooking { "from": "...", "to": "...", "when": "...", "customer": "..." } Prebooking notification topic 202 Accepted Location: ... Content-Location: ... { <task-status-repr> } Ride-booking service Prebooking submission resource
  • 54.
    Use case: Prebookingcampaigns AWS Cloud Further decoupling Prebooking notification buffer queue Prebooking processing buffer queue Wild Rydes customer Wild Rydes customer app https://... submit-ride-prebooking { "from": "...", "to": "...", "when": "...", "customer": "..." } Prebooking notification topic Ride-booking service Prebooking submission resource 202 Accepted Location: ... Content-Location: ... { <task-status-repr> }
  • 55.
    Use case: Prebookingcampaigns AWS Cloud Data lake ingestion service Ride-booking service / Prebooking processing resource Further decoupling Prebooking notification buffer queue Prebooking processing buffer queue Wild Rydes customer Wild Rydes customer app https://... submit-ride-prebooking { "from": "...", "to": "...", "when": "...", "customer": "..." } Prebooking notification topic Ride-booking service Prebooking submission resource 202 Accepted Location: ... Content-Location: ... { <task-status-repr> }
  • 56.
    Use case: Prebookingcampaigns AWS Cloud Data lake ingestion service Further decoupling Prebooking notification buffer queue Prebooking processing buffer queue Wild Rydes customer Wild Rydes customer app https://... submit-ride-prebooking { "from": "...", "to": "...", "when": "...", "customer": "..." } Prebooking notification topic Ride-booking service Prebooking submission resource 202 Accepted Location: ... Content-Location: ... { <task-status-repr> } Massive campaign with CTA: No, really! Book now! Ride-booking service / Prebooking processing resource
  • 57.
    Use case: Prebookingcampaigns Wild Rydes customer Wild Rydes customer app https://... AWS Cloud Data lake ingestion service Action=SendMessage &MessageBody=... ... Prebooking notification topic Even further decoupling Prebooking notification buffer queue Prebooking processing buffer queue Prebooking submission buffer queue 200 OK ... <SendMessageResponse> ... </SendMessageResponse> Ride-booking service Prebooking submission resource Ride-booking service / Prebooking processing resource
  • 58.
    © 2021, AmazonWeb Services, Inc. or its affiliates. All rights reserved.
  • 59.
    Use case: Instantride RFQ Wild Rydes customer Wild Rydes customer app https://... submit-instant-ride-rfq AWS Cloud Ride-booking service { "from": "...", "to": "...", "customer": "..." } Scatter-gather 202 Accepted Location: ... Content-Location: ... { "links": { ... }, "status": "...", "eta": "..." }
  • 60.
    Use case: Instantride RFQ Wild Rydes customer Wild Rydes customer app https://... submit-instant-ride-rfq AWS Cloud Ride-booking service { "from": "...", "to": "...", "customer": "..." } Request for quotes topic Scatter-gather 202 Accepted Location: ... Content-Location: ... { "links": { ... }, "status": "...", "eta": "..." }
  • 61.
    Unicorn Management Service Usecase: Instant ride RFQ Wild Rydes customer Wild Rydes customer app https://... submit-instant-ride-rfq AWS Cloud Ride-booking service Unicorn management resource Unicorn management resource Unicorn management resource { "from": "...", "to": "...", "customer": "..." } Request for quotes topic Scatter-gather … 202 Accepted Location: ... Content-Location: ... { "links": { ... }, "status": "...", "eta": "..." }
  • 62.
    Unicorn Management Service Usecase: Instant ride RFQ Wild Rydes customer Wild Rydes customer app https://... submit-instant-ride-rfq AWS Cloud Ride-booking service Unicorn management resource Unicorn management resource Unicorn management resource { "from": "...", "to": "...", "customer": "..." } Request for quotes topic Scatter-gather RFQ response queue … 202 Accepted Location: ... Content-Location: ... { "links": { ... }, "status": "...", "eta": "..." }
  • 63.
    Unicorn Management Service Usecase: Instant ride RFQ Wild Rydes customer Wild Rydes customer app https://... submit-instant-ride-rfq AWS Cloud Ride-booking service Unicorn management resource Unicorn management resource Unicorn management resource { "from": "...", "to": "...", "customer": "..." } Request for quotes topic Scatter-gather 202 Accepted Location: ... Content-Location: ... { "links": { ... }, "status": "...", "eta": "..." } RFQ response queue …
  • 64.
    Unicorn Management Service Usecase: Instant ride RFQ Wild Rydes customer Wild Rydes customer app https://... retrieve-rfq-status AWS Cloud Ride-booking service Unicorn management resource Unicorn management resource Unicorn management resource Request for quotes topic Scatter-gather RFQ response queue …
  • 65.
    Unicorn Management Service Usecase: Instant ride RFQ Wild Rydes customer Wild Rydes customer app https://... retrieve-rfq-status AWS Cloud Ride-booking service Unicorn management resource Unicorn management resource Unicorn management resource Request for quotes topic Scatter-gather RFQ response queue … 200 OK { "links": { ... }, "status": "running", "eta": "..." }
  • 66.
    Unicorn Management Service Usecase: Instant ride RFQ Wild Rydes customer Wild Rydes customer app https://... retrieve-rfq-status AWS Cloud Ride-booking service Unicorn management resource Unicorn management resource Unicorn management resource Request for quotes topic Scatter-gather RFQ response queue … 200 OK { "links": { ... <link-to-result> ... }, "status": "done" }
  • 67.
    Unicorn Management Service Usecase: Instant ride RFQ Wild Rydes customer Wild Rydes customer app https://... retrieve-rfq-result AWS Cloud Ride-booking service Unicorn management resource Unicorn management resource Unicorn management resource Request for quotes topic Scatter-gather RFQ response queue …
  • 68.
    Unicorn Management Service Usecase: Instant ride RFQ Wild Rydes customer Wild Rydes customer app https://... retrieve-rfq-result AWS Cloud Ride-booking service Unicorn management resource Unicorn management resource Unicorn management resource Request for quotes topic Scatter-gather RFQ response queue … 200 OK { "links": { ... }, "from": "...", "to": "...", "quotes": "..." }
  • 69.
    © 2021, AmazonWeb Services, Inc. or its affiliates. All rights reserved.
  • 70.
    Resources AWS blogs andother content on messaging and application integration https://aws.amazon.com/messaging/ https://aws.amazon.com/event-driven-architecture/ https://aws.amazon.com/blogs/compute/category/messaging/ The German-language AWS-Podcast Keep in mind Loose coupling is always better than lousy coupling bit.ly/aws-podcast
  • 71.
    Vielen Dank für’sZuschauen! Dennis Traub, Developer Advocate, Amazon Web Services Twitter: @dtraub Podcast: bit.ly/aws-podcast