ESB's and Gateways (Async / sync) Flashcards
What is an ESB?
Service/object which handles the business logic on top of services in SOA and ties them together.
Think: a router which routes the messages and monitors that there is no errors and maintains the order that things needs to happen - often synchronously.
What is synchronous programming?
When events are dependent/connected with each other.
Example: order food, wait for food, eat. You can’t start the next action.
How does synchronous programming work in a program?
Components, events, tasks and activities are chained. They are dependent on the other finishing before starting. Only one execution at a time.
How many threads does synchronous programming happen on?
One or multiple.
As long as Thread B waits for Thread A to finish before starting.
Why do you think about SOA when you think synchronous programming?
Because the ESB sometimes have to wait for one service in order to be ready to call the next one.
When is synchronous programming used?
In sensitive systems where the data needs to be precise and received in exact order.
When debugging. It’s better to see things step by step.
Pros with synchronous programming?
No need to implement response routing. A call automatically happens after the previous is done.
No need to correlate a response to a request. Its implicit.
It is safer.
Easy to follow and debug / test.
Cons with synchronous programming?
Prone to network errors and exceptions.
Failure is permanent, you need to send the request again, no automatic retry options.
You can’t send to multiple receivers.
Senders application is blocked until response.
The sender and receiver needs to be online at the same time.
What is asynchronous programming?
Parallel execution on tasks.
Mainly when tasks is ran separately from the main program. So for example the main program can still be used. (scrolling on an application).
When is asynchronous programming used?
When programs need to perform multiple operations at the same time.
For example: input/output operations. file- database- network I/O
What is the extra requirements with asynchronous programming?
It requires handling, usage of async/await - then/catch. To ensure that the response is ready before trying to send it.
So await sending the response until it has gotten the data from the database.
How does asynchronous programming work?
Components, events, tasks are ran independently. Then each component notifies the main thread when done.
What are the pros of asynchronous programming?
Real time.
Loose coupling of applications
Multiple receivers are possible.
Sender and receiver does not need to be online at the same time.
Increase in throughput (not performance).
- Throughput is the amount of service a program can do.
No timeouts. The call is done when it’s done.
Sender can send more messages while other tasks execute.
Cons with asynchronous programming?
It adds complexity to your program.
No immediate response from a call - you have to wait for the task to complete before using the response.
Sender needs to account for responses and requests on its own. (frameworks do it for you).
Harder to debug.
A comparison with ASYNC / SYNC
In sync... Data is sent In blocks / frames. Uses more time to finish a task. All resources needs to be available. Used in SOA - ESB
in async…
data is sent in bytes
can save time because more action can happen simultaneously.
Used in cloud