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
- Java應用異常狀態監測Java
- 架構設計(五):有狀態服務和無狀態服務架構
- 系統設計架構:有狀態與無狀態架構
- Kubernetes 實戰——有狀態應用(StatefulSet)
- 工作流從無狀態切換到有狀態的好處
- SAP Hybris Commerce的JSP tag和SAP BSP tag的比較JS
- 行為型模式:狀態模式模式
- 執行緒狀態和鎖執行緒
- 無狀態協議協議
- 使用SAP BSP應用執行VueVue
- 探索FSM (有限狀態機)應用
- statefulset詳解及為何結合headless service部署有狀態應用
- TCP為什麼是有狀態的?TCP
- 最全的HTTP響應狀態碼列表:除了404,HTTP狀態碼還有啥?HTTP
- SAP ABAP應用伺服器的HTTP響應狀態碼(Status Code)伺服器HTTP
- 執行緒狀態執行緒
- 順序控制和狀態機之間的差別
- 使用 Provider 管理 Flutter 應用狀態 (下)IDEFlutter
- 使用 Provider 管理 Flutter 應用狀態 (上)IDEFlutter
- ASP.NET Core 應用程式狀態ASP.NET
- steam雲狀態無法同步怎麼辦 steam雲狀態無法同步會有什麼影響
- 3個有狀態應用程式的無伺服器開發策略 - Twain Taylor伺服器AI
- Lua有狀態迭代器
- 對於“前端狀態”相關問題,如何思考比較全面前端
- 使用NAS動態儲存卷建立有狀態應用
- Memcached 多執行緒和狀態機執行緒
- XMLHttpRequest readyState響應狀態XMLHTTP
- HTTP 響應狀態碼HTTP
- Blazor中的無狀態元件Blazor元件
- 前端狀態管理與有限狀態機前端
- NetApp使有狀態應用程式更易於在Kubernetes中完成APP
- 死鎖避免中的安全狀態和不安全狀態
- AI模組(有限狀態機、行為樹)-應用在cocos中AI
- [譯] Flutter 中的原生應用程式狀態Flutter
- java執行緒的五大狀態,阻塞狀態詳解Java執行緒
- C#實現JWT無狀態驗證的實戰應用C#JWT
- 用設計模式去掉沒必要的狀態變數 —— 狀態模式設計模式變數