SAP BSP應用有狀態和無狀態行為差異比較
In previous blog Fiori and CRM WebClient UI – Stateless and Stateful, but how? I have researched how stateful and stateless BSP application are handled in ABAP server side. In this blog I will explain how stateful and stateless BSP application behave differently.
The test BSP application I am using
It consists of three files.
first.json
<%@page language="abap" %><%
WAIT UP TO 3 SECONDS.
%>
{
"message":"First page wait 3 seconds"
}
Here I use WAIT keyword to simulate that it will take 3 seconds for the first request to finish.
index.html
In this html file, I fire two requests to fetch “first.json” and “second.json” one by one. The first request is sent before second request.
<%@page language="abap" %><%@extension name="htmlb" prefix="htmlb" %><!DOCTYPE html><html><head><title>Jerry Test Stateful</title></head><body><button onclick="fire()">Fire two request</button><script>function wrapperOnFetch(url){
fetch(url,{ credentials:"include" }).then(function(response){
return response.json();
}).then(function(json){
console.log(url + ":" + json.message);
});}function fire(){
wrapperOnFetch("first.json");
wrapperOnFetch("second.json");}</script></body></html>
second.json
<%@page language="abap"%>
{
"message":"Second page no wait to response"
}
The application is firstly set as Stateful:
Stateful test
(1) Launch index.html, and in Chrome development tool you can see there are three “set-cookie” in Response Header fields.
One of them, the sap-contextid is set in method ON_REQUEST_LEAVE of CL_BSP_RUNTIME explained in previous blog.
And you can observe the cookie in tab “Application”:
The cookie could also be reviewed in Chrome via Settings ->Advanced Settings->Privacy->Content Settings->All cookies and site data…
(2) click button “Fire two request”, and in console we can observe that these two requests are handled sequentially in server: the response of first request still comes first before the response of second request.
This could also be confirmed in the Network tab. The first request takes totally 3 seconds to finish. During the wait of this 3 seconds, the process of second request is pending till the first request finishes. As a result finally both request takes around 3 seconds to get handled.
We can also observe that the cookie set by index.html load is now automatically appended as the request header for “first.json” and “second.json” request:
Stateless test
Now set application as stateless and open index.html again:
Compare the cookie with stateful test, this time the cookie sap-contextid is not there. This observation is consistent with what I found in blog Fiori and CRM WebClient UI – Stateless and Stateful, but how?, as it will only be set in stateful application.
Click fire button, and we can find in stateless application, these two requests are handled by server in parallel: the response of second request is now coming first before the response of first request.
In Network tab, once fire button is clicked, the second request gets processed almost immediately, and the first request still has status “Pending”.
After 3 seconds the first request is done, total duration is around 3 seconds:
In Stateless application, it is clearly observed that cookie field sap-contextid is not involved in the request & response handling.
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2714419/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SAP Fiori和WebClient UI的有狀態和無狀態行為設計原理WebclientUI
- 有狀態和無狀態的區別
- Spring Bean Scope 有狀態的Bean和無狀態的BeanSpringBean
- Java應用異常狀態監測Java
- 架構設計(五):有狀態服務和無狀態服務架構
- 關於有狀態和無狀態會話bean的解釋 (轉)會話Bean
- 系統設計架構:有狀態與無狀態架構
- 行為和狀態的關係
- mysql較為重要的狀態變數MySql變數
- Kubernetes有狀態應用管理——PetSet
- 什麼時候用有狀態session bean,什麼時候用無狀態session bean (轉)SessionBean
- 行為型模式:狀態模式模式
- Kubernetes 實戰——有狀態應用(StatefulSet)
- ssdbgrid中,設了斷點的除錯狀態和執行狀態有區別斷點除錯
- 無狀態協議協議
- 執行緒狀態和鎖執行緒
- 解決IIS無響應假死狀態
- 使用SAP BSP應用執行VueVue
- 探索FSM (有限狀態機)應用
- 最全的HTTP響應狀態碼列表:除了404,HTTP狀態碼還有啥?HTTP
- 執行緒狀態執行緒
- SAP ABAP應用伺服器的HTTP響應狀態碼(Status Code)伺服器HTTP
- statefulset詳解及為何結合headless service部署有狀態應用
- steam雲狀態無法同步怎麼辦 steam雲狀態無法同步會有什麼影響
- Gavin King為有狀態Bean SFSB平反Bean
- 3個有狀態應用程式的無伺服器開發策略 - Twain Taylor伺服器AI
- ASP.NET Core 應用程式狀態ASP.NET
- SAP Hybris Commerce的JSP tag和SAP BSP tag的比較JS
- 對於“前端狀態”相關問題,如何思考比較全面前端
- 使用NAS動態儲存卷建立有狀態應用
- HTTP 響應狀態碼HTTP
- Memcached 多執行緒和狀態機執行緒
- Blazor中的無狀態元件Blazor元件
- 前端狀態管理與有限狀態機前端
- 設計模式--狀態模式State(行為型)設計模式
- AI模組(有限狀態機、行為樹)-應用在cocos中AI
- Oracle資料庫的靜默狀態和掛起狀態Oracle資料庫
- 使用 Provider 管理 Flutter 應用狀態 (下)IDEFlutter