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的原创文章,请关注公众号"汪子熙":
相关文章
- SAP UI5 SimpleForm M 和 L 型表单的 label 和 input 分配讲解
- 关于使用命令行 cf login 登录 SAP BTP CloudFoundry 环境的问题
- SAP UI5 应用中的 sap.ui.require.toUrl 使用场景
- 关于 SAP UI5 所有控件的共同祖先 - sap.ui.base.ManagedObject
- 以前编写好能够正常运行的 SAP UI5 代码,几个月后忽然不能运行了该怎么办?
- SAP UI5 sap.ui.Device.media.RANGESETS 的使用介绍
- SAP UI5 sap.ui.Device.media.initRangeSet 方法的单步调试
- SAP UI5 Tools 的 Custom UI5 Server Middleware 介绍
- [ChatGPT 勘误] SAP ABAP 里 cl_r3standard_persistence 的用途?
- 通过 SAP 官方帮助网站自学 SAP 业务知识的一种办法
- SAP MM内向交货单的凭证流
- 使用 Chrome 开发者工具分析 SAP UI5 应用的 JavaScript 代码执行性能瓶颈
- sap.m.Table 和 sap. ui.table.Table 两个控件的功能对比
- sap.ui.comp.smarttable.SmartTable 一些属性的用法阐述
- SAP UI5 里响应式表格的 minScreenWidth 属性讲解
- Google Tag Manager (GTM) 和 Adobe AEPL 在 SAP Spartacus 中的应用
- 深入比较:SAP vs Oracle(sap和oracle)
- 显示所有SAP图标的ABAP代码详解编程语言
- SAP SD订单状态详解编程语言
- SAP BAPI 去前导零、加前导零函数详解编程语言
- SAP ABAP如何隐藏你写的程序代码(危险,请小心谨慎)详解编程语言
- 系统SAP在Linux系统上的开启之旅(sap启动linux)
- 对比SAP VS Oracle: 哪个更适合你?(sap与oracle)
- 系统Oracle公司收购SAP系统开启新的商业时代(Oracle公司sap)
- 缓存使用SAP创建Redis缓存,实现高效稳定加速(sap如何创建redis)
- Oracle和SAP技术比较优势和劣势(oracle与sap比照)
- 聘请高级Oracle与SAP顾问,拓展业务潜力(oracle sap顾问)
- 探索 Oracle 与 SAP 技术的开发可能性(oracle sap开发)