OutSystsems User Group Netherlands September 2024.pdf

mail496323 294 views 58 slides Sep 26, 2024
Slide 1
Slide 1 of 58
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58

About This Presentation

The slides of both presentations at the September 2024 edition of the Dutch OSUG.


Slide Content

September 2024
How touseGraphQL in
Outsystems

About GraphQL
Overview | Basic concepts | Key components
Integration
How to connect to GraphQL | Best Practices
Demo
Considerations
Q&A
01
02
03
04
05
Performance metrics | Use cases | GraphQL vs REST

GraphQL is a runtime for APIs and query
language that lets clients ask exactly what
they need
Alternative to using REST APIs
query {
books {
title,
author,
year
}
}
GraphQL

Use case
Books
Reviews

REST REQUEST
https://example.com/books
REST JSON
{
[
“id”: “a633b31b92f4”
“isbn”: “978-01209354”,
"title": “Ocean Wonders",
"author": "Jane S.",
“year": 2022,
“genre”: “Fantasy”,
”publisher”: “Tree House”
]
}
REST REQUEST
https://example.com/books/id/reviews
REST JSON
{
“bookId": a633b31b92f4"",
“reviews": [
{
“rating": 2,
“username”: “Diane556”
}
]
}
REST API
GRAPHQL QUERY
{
books {
title
author
year
reviews {
rating
}
}
}
GRAPHQL JSON
{
"data": {
"book": {
"title": "Ocean Wonders",
"author": "Jane S.",
“year": 2022,
"reviews": [
{
"rating": 2
}
]
}
}
GraphQL

Over fetching
Getting back more data than we need
REST API
example.com/books
[
{
"id": "91571854-d196-4470-939f",
"isbn": "978-0060935467",
"title": "The Fellowship of the Ring",
"author": "J.R.R. Tolkien",
"year": 1954,
"genre": "Fantasy",
"publisher": "George Allen & Unwin"
}
]

Under fetching
Getting back less data than we need
REST API
example.com/books/Id
Additional request
example.com/books/id/reviews
{
"id": "91571854-d196-4470-939f",
"isbn": "978-0060935467",
"title": "The Fellowship of the Ring",
"author": "J.R.R. Tolkien",
"year": 1954,
"genre": "Fantasy",
"publisher": "George Allen & Unwin"
}

Single endpoint
The graph object is a building block
GraphQL
example.com/graphQL
query {
books {
title
author
reviews {
rating
}
}
}

Type system
Schema
Resolvers
GraphQL
Abstraction layer
HTTP
Database
Third-party API
Microservice
Client-side Server-side

Select
Insert | Update | Delete
Where | Order By | Limit
Views | Subqueries
Query
Mutations
Arguments
Fragments
GraphQL

Schema definition
First, define your data with a
schema
The schema describes the
shape of the graph and the
data available on it
GraphQL

Resolvers
Next, implement resolvers for
each schema field
Operate at the level of individual
object properties
Load balancers for improved
performance
GraphQL

Query language
Finally, you can interact with the
GraphQL API
The query describes the data
requirements
GraphQL

Data returned
The data is provided as
requested in the query
Payload includes the errors,
providing details about what
part of the query failed and
why
GraphQL

Error
handling
Errors on the
query execution
are split from
HTTP errors
HTTP status shows if the GraphQL
server processed the request, NOT
the success of the query execution
- Returns HTTP200 for all responses,
including errors
- Partial success: Available data and error
details are returned without discarding
the entire response
GraphQL

Consume a
POST REST
method
1
Wrap your
method
2
Use your
integration
3
Query
Operation name
Variables
Authentication
Response
query {
query string...
}
data {
string...
}
Integration

GraphQL IDEs
GraphiQL
GraphQL
Playground
Apollo Studio
Postman
Tools to simplify the process of
writing, testing & debugging
- Schema exploration
- Interactive query building
- Track query execution times

GraphiQL

Best Practices
Abstract your integration
Wrap your method with a server
action:
- Library
- Authentication
- Request

Best Practices
Don’t hardcode your
queries
Use a Backoffice to configure your
queries
-Query string
-Operation name
-Code

Best Practices
Name all operations
Naming isn't required for single
operations but helps with tracing
and debugging

Best Practices
Don’t extend existing
queries
Balancing query reuse is important
for maintainability, but in the long
run, it may not be sustainable
DRY Principle

Best Practices
Fetch what you need, when
you need
Offset-based pagination and limit
to build infinite scroll
Cursor-based pagination for larger
datasets
Fragmented query for rendering
several UI components
synchronously

Demo time
Because seeing is believing

Connecting with GraphQL

Using your connection

GraphQL is 27% faster than REST
Performance Metrics
Reduced
data size

Use Cases
Need to access data from
multiple endpoints?
GraphQL lets you gather it all in a single call
1
Building complex solutions that
are user-story driven?
GraphQL asks the server to get only what
the client needs
2
Dealing with many external
sources?
GraphQL can provide a consistent pathway
to access it all
3
Building mobile apps?
GraphQL allows you to have control on the
data transferred over the network
4
Is your API simple, with clear
endpoints and few data types?
Stick to REST if you want well-documented,
easy-to-understand APIs
5
Does your solution depend a lot
on caching?
REST endpoints are stateless and
predictable, which simplifies caching
6

It’s a wrap…
Which one fits best?

Q&A

Thanksforyourtime

WELCOME

Event-Driven
Architecture
in OutSystems
ODC
OSUG
September 2024

Aurélio
Dos Santos
OutSystems developer
in/aurelio-dos-santos-
junior-76a98522
Ozan
Çali
OutSystems developer
in/ozancali

Basics
Concepts
What’s under the hood?
In Practice
01
02
03
Best ways to implement EDA… and its challenges
What is it?
Working with Events in ODC & Demo
Q & A
04
05

Basics

Modularity: a global trend
6
microservices vs. monolith

Producing events
in the system where something has just changed
- a user action, a sensor reading, a database update, a trigger from an external system, …
Event-Driven Architecture is about
Detecting events
in an intermediary (router) system
-Collects data about the event and dispatches to the handlers
Reacting to events
by systems “curious” about a particular change in another system
- Doesn’t listen to the changed system directly, but rather the “change dispatcher”
7

OutSystems already applies event-driven architecture in many aspects.
•We trigger events in blocks to notify the parent screen that something has changed
•With RWA, we have client-side event handlers such as OnInitialize, OnReady, OnRender, OnDestroy, OnParametersChanged,
OnAfterFetch, OnAppReady... triggered when a change with UI blocks or data occurs
Sounds familiar?
8

Concepts

Coupled services respond synchronously to
sequential updates
Coupled services, sequential updates
User purchases a concert ticket online
Their seat is reserved at the venue
The order details are mailed to the user
Courier company is notified for physical tickets
Earned extra points in loyalty program
All steps should run without an issue for the
operation to complete
10

Decoupled services respond asynchronously to events
Decoupled services, event-driven updates
User purchases a concert ticket online
This triggers an update to different systems
Courier company is notified for
physical tickets
Mailing system is notified
Loyalty system is notified
Allows flexibility, scalability and
real-time responsiveness
11
Venue reservation
logic is executed
Message router
Handler_ReserveSeat
GUID, GuestID, EventID
Handler_AddPointsToGuest
GUID, GuestID, EventID
Handler_SendConfirmationEmail
GUID, GuestID, EventID
Handler_NewCourierRequest
GUID, GuestID, EventID
TicketPurchasedAm I ESB?

Event-Driven Communication
Event notification = publish-subscribe (pub-sub)
Brings publishers together with
subscribers
Downstream event-driven activity by
reacting to subscriptions
Publishes an event as a result of
an action
12
Event channel
Event consumer
Event producer
Event processing engine

•Senses a change and represents the change as an event message
•Agnostic of consumers
•Unique event IDs & timestamps, immutable events
•A producer system can also be the consumer of another system in a chain
Producer
13
Publishes an event as a result of
an action
Event producer

a.k.a. Broker, Broadcaster, Router, …
•Mechanism of propagatingthe collected events, or just streaming
•Multiple asynchronous event channels
•Can be any type of input (XML, JSON etc.) as long as agreed upon
•Message queue systems such as Apache Kafka, AWS Lambda, RabbitMQ (in O11), NATS (in ODC)
•Events are stored in a message queue, waiting to be processed later by the event processing engine
•Should have high observability (robust logging, monitoring, tracing)and good documentation
•Can be expanded to act as an Enterprise Service Bus, for sharing more data bi-directionally
Channel
14
Brings publishers together with
subscribers
Event channel
Event processing engine

•Reacts asynchronously: receive order might not be the same as produced order
•Good to have internal event management
•Free to process at its own pace; can do non-real-time processing, too
•Idempotent(same results for the same/duplicate messages received)
•Can trigger an event as a result of handling another event(chain of events)
Consumer
15
Downstream event-driven activity by
reacting to subscriptions
Event consumer

In
Practice

Designing Services & Events
Three levels to Service-Oriented Architecture (SOA)
1.Identify components
2.Define conversations between them (events & handlers)
3.Identify linking concepts (keys, IDs) across multiple services
17
Do event storming with business to figure out domain events of a business process
(with post-its on the wall)
•Clearer domain and event definitions
•Promotes more independent and atomic teams
•Reveals complexity of the ecosystem and individual domains

Advantages
•Flexibility: decoupled nature makes it more adaptable
•Can scalesystems horizontally
•Asynchronouscommunication
•Agility: no custom code for polling, filtering or routing events; standard schemas
•Real-time responsiveness (especially visible in frontends)
•Monitor & Configurewith easeand in detail
•Fault tolerance: Retry or re-route mechanism in event broker
•Fail independently
18

Challenges
•Possible microservices overload, deadlocks
•Data inconsistency risk: independent transactions need rollback mechanisms
•Security concerns
•Latency risk
•Complex event chains
•Event schema evolution
•More complex deployments, monitoring, debugging and error handling
•Extra layer for message routing; which team is responsible for it?
•Maintenance overhead
19
Evaluate if it make sense to start with microservices & EDA!

Working with
Events in ODC
& Demo

The 2 business use caseswe solved
1.As a direct replacement for Light-BPT: near real-time, asynchronous execution of business logic, manipulating
considerable amounts of data (order lines).
Whenever data is created/updated via an exposed REST API, the application needs to run a set of validations
based on specific business rules.
2.Publisher/subscriber (pub/sub) model: one application exposes a public event, letting consumer applications
handle it as they see fit.
As the order lines transition between the different possible statuses, the application needs to keep a detailed
logging of those transitions.
21

ODC Application 1
Use case 1 – Implementation Details
22
Create task
Task Type
Get tasks
Trigger event
1 2 3
Implements
business logic

ODC Application 1
Use case 2 – Implementation Details
23
Declares public event
Triggers event
ODC Application 2
Consumes public event
Implements event handler

Lessons learned
●Handle transactions carefully.
●Be careful with large text inputs, as there's a 2000-character limit.
●Be aware of event timeouts (2 minutes only).
●Debugging can be tricky.
●Out-of-the-box logging is limited, so you might need to add custom logging.
●Always handle exceptions in your event handlers.
24

Comparison with BPT in O11
BPT (Processes) in O11
Human & automatic act., wait, conditional start, decision
Light BPT can have max 20 threads per FE by default
Light BPT timeout is 3 mins
Possible to automatically trigger an event with a
database create operation
25
Events for Light BPT and Workflows for BPT in ODC
Only human & automatic activities, decisions (in Workflows)
No instance limit with Events
Events timeout is 2 mins
We need to trigger an Event manually after each operation

Questions?

Thank you

References
https://www.linkedin.com/pulse/microservice-101-event-driven-architecture-eda-shanoj-kumar-v-
iofjc/?trackingId=samSjZiJSga5jKpGMhl0iQ%3D%3D
https://www.linkedin.com/pulse/accelerating-event-driven-architecture-domain-driven-design-
kl3cf/?trackingId=WBDE8lYATgGghjdO7vF3Ng%3D%3D
https://www.linkedin.com/pulse/event-driven-architecture-rocky-bhatia-k1nuf/?trackingId=l33FrSasSr%2BSG0vwffu7qQ%3D%3D
https://www.outsystems.com/blog/posts/event -driven-apps/
https://www.outsystems.com/-/media/files/low-code-platform/event-driven-architecture/outsystems-event-driven-architecture-
datasheet.pdf?updated=20240313202406
https://success.outsystems.com/documentation/outsystems_developer_cloud/building_apps/events/
https://medium.com/@joshuasalema/event -driven-architecture-in-outsystems-using-celigo-integrations-platform-27a731105777
https://en.wikipedia.org/wiki/Event_(computing)
https://en.wikipedia.org/wiki/Event-driven_architecture
https://aws.amazon.com/event-driven-
architecture/#:~:text=An%20event%2Ddriven%20architecture%20uses,on%20an%20e%2Dcommerce%20website .
https://medium.com/@mmowaffak/essential -idempotency-for-event-driven-systems-b0e4a1bf538b
https://www.youtube.com/watch?v=Fb_0UOD2X2I
https://commons.wikimedia.org/w/index.php?title=File:Event_driven_programming_Simply_Explained.jpg&oldid=462525602
https://en.wikipedia.org/wiki/Loose_coupling
https://en.wikipedia.org/wiki/Message-oriented_middleware
https://blogs.zeiss.com/digital-innovation/en/event-storming-at-a-glance/
https://www.amdocs.com/insights/blog/event -storming
https://www.linkedin.com/posts/abuijze_in-my-previous-role-i-was-a-troubleshooter-activity-7236633454677766144-VDiR/
https://medium.com/@rohitdoshi9/event -driven-architecture-benefits-challenges-and-examples-c957c269420a
https://medium.com/productleague/near -real-time-erp-integration-to-process-large-data-with-outsystems-part-2-queueing-
bucketing-345f42c774b1
https://www.enterpriseintegrationpatterns.com/ramblings/eventdriven_coupling.html
28
Tags