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 BSP应用有状态和无状态行为差异比较相关推荐

  1. 精通有状态vs无状态(Stateful vs Stateless)一

    精通有状态vs无状态(Stateful vs Stateless)-Immutable模式之姐妹篇 Peter Wei 我相信有不少人还不明白有状态和无状态(Stateful and Stateles ...

  2. 浅析权限认证中的有状态和无状态

    转自:https://www.cnblogs.com/shiyajian/p/10672908.html 前言 我们在设计构建一个系统的时候,权限管理和用户认证是最基本功能,其中关于用户认证这块是一个 ...

  3. mysql有状态无状态_有状态和无状态的对象区别

    每次的总结,都是一种进步,把自己理解的东西记录下来不容易,让别人看懂更不容易. 第一:基本概念: 1.有状态就是有数据存储功能.有状态对象(Stateful Bean),就是有实例变量的对象,可以保存 ...

  4. IPv6系列-彻底弄明白有状态与无状态配置IPv6地址

    深入研究自动分配IPv6地址的Stateless(无状态)与Stateful(有状态)方式 小慢哥的原创文章,欢迎转载 目录 小说搜索 biqi.org ▪ 一. Link-Local Address ...

  5. 什么叫有状态,无状态

    什么叫有状态,无状态 先说结论: 无状态 当前的操作不需要历史信息的支持,一般都是短连接,比如在某个新闻网站上浏览新闻等.当从服务器获取资源后就可以和服务器断开连接 有状态 当前操作需要历史数据的支持 ...

  6. linux dhcpv6有状态配置,ipv6 有状态和无状态什么意思

    这是IPv6协议的一个突出特点:支持网络节点的地址自动配置. 一.有状态就是有数据存储功能.有状态对象(Stateful Bean),就是有实例变量的对象 ,可以保存数据,是非线程安全的.在不同方法调 ...

  7. 有状态和无状态(@stateless/@stateful)

    基本概念:  有状态就是有数据存储功能.有状态对象(Stateful Bean),就是有实例变量的对象,可以保存数据,是非线程安全的.在不同方法调用间不保留任何状态.  无状态就是一次操作,不能保存数 ...

  8. 服务器的鱼和熊掌,有状态or无状态

    问题引入 如果我们刚开始新游戏项目的服务器开发,会遇到服务器状态选择问题,游戏项目是用有状态服务器还是无状态服务器? 是什么?     服务器状态简单来说客户端的多次请求具有上下文关系.比如客户端登录 ...

  9. 有状态和无状态(Stateful vs Stateless)

    我相信有不少人还不明白有状态和无状态(Stateful and Stateless)的概念,那么我们今天就来谈谈有状态和无状态,一方面不断总结提高自我,另一方面兼扫盲. 基本概念: 有状态就是有数据存 ...

  10. 有状态和无状态的区别

    基本概念: 有状态就是有数据存储功能.有状态对象(Stateful Bean),就是有实例变量的对象 ,可以保存数据,是非线程安全的.在不同方法调用间不保留任何状态. 无状态就是一次操作,不能保存数据 ...

最新文章

  1. 合适么?现在学ASP.NET Core入门编程……
  2. OpenCASCADE:Modeling Algorithms模块几何工具之插值
  3. mysql空事务死锁_mysql空当锁导致死锁_mysql
  4. Redis在windows下安装过程(转载)
  5. XMLHttpRequest() 请求 返回结果JSON 对象与JSON 字符串处理
  6. 模拟银行自动提款系统python
  7. 图的深度优先搜索遍历
  8. java的幂运算_java数组五种运算符
  9. Golang map 三板斧第二式:注意事项
  10. jmeter性能工具 之 cookie 管理器
  11. 学习时间序列法ARIMA模型与LSTM很好的文章
  12. mysql error 1213_webgame中Mysql Deadlock ERROR 1213 (40001)错误的排查历程
  13. [Python程序设计] 用Scrapy爬取学堂在线计算机类课程页面的信息
  14. win7设置自动开机时间_想要服务器断电后自动开机,怎么设置?
  15. MADRL(多智能体深度强化学习)
  16. 班级量化考核系统php代码,班级管理量化考核及评分细则
  17. 如何查看win10系统的激活情况
  18. zic - 时区编辑器
  19. 企业微信和小程序绑定,获取unionid
  20. Latex 表格的模版笔记

热门文章

  1. android意图传递参数返回结果(六)
  2. Git 常用命令及讲解(不断更新)
  3. 方立勋_30天掌握JavaWeb_JSP
  4. Shell按行读取文件的3种方法
  5. Codeforces Round 504
  6. OLEDB不使用SQL语句直接打开数据表
  7. 使用腾讯云CDN做HTTPS的WordPress博客时要改的代码
  8. Android Bitmap和Canvas学习笔记
  9. 通过多说服务器缓存加速Gravatar 头像
  10. 固定在左右两侧不动的广告条 样式