- Java EE 8 Design Patterns and Best Practices
- Rhuan Rocha Jo?o Purifica??o
- 318字
- 2021-07-23 16:55:02
Explaining the concept of the service-activator pattern
Suppose a client needs to request a business service, which is a process that takes a long time. In this case, the client should not wait in a synchronous way until the end of the process. Instead, there must be a way to make an asynchronous service call that does not block the client or user. This service can then be activated at some point in the future. There may be several reasons for the delay of a process. For example, there may be a database query that consumes a lot of time, or an access to a legacy system that is beyond the control of the current application. The pattern of asynchronously performing the required task is known as the service activator.
So, the service activator pattern is always used when the client needs to call a service asynchronously. This means that the client makes the request and does not wait for the response.
We can imagine some alternative solutions to this problem. One method would be to send the request to a queue, while another service would read the request from this queue and execute the task within it. Alternatively, when the client requests a service, this service could be placed in a database, and there could be a listener or a job that would check the tasks that had not yet been performed. If a task had not yet been performed, it would be executed.
In fact, the JEE specification gives us very good solutions that are used to implement the service-activator pattern. These solutions are described as follows:
- Java Message Service (JMS)
- EJB asynchronous methods
- Asynchronous events: producers and observers
These three solutions were offered in the given order within the evolution of the JEE specification. We'll look at each of these solutions in more detail in the following sections.
- Arch Linux Environment Setup How-to
- Windows Phone 7.5 Data Cookbook
- 玩到極致 iPhone 4S完全攻略
- PLC控制系統(tǒng)應(yīng)用與維護(hù)
- Ganglia系統(tǒng)監(jiān)控
- 循序漸進(jìn)學(xué)Docker
- Windows Phone應(yīng)用程序開(kāi)發(fā)
- Linux網(wǎng)絡(luò)內(nèi)核分析與開(kāi)發(fā)
- Linux使用和管理指南:從云原生到可觀測(cè)性
- OpenStack系統(tǒng)架構(gòu)設(shè)計(jì)實(shí)戰(zhàn)
- 從實(shí)踐中學(xué)習(xí)Kali Linux無(wú)線網(wǎng)絡(luò)滲透測(cè)試
- NetDevOps入門(mén)與實(shí)踐
- Python UNIX和Linux系統(tǒng)管理指南
- Linux系統(tǒng)最佳實(shí)踐工具:命令行技術(shù)
- 電腦辦公(Windows 10 + Office 2016)入門(mén)與提高(超值版)