Session management method, computer device, storage medium and program product
Patent Information
- Application Number
- CN202611128394.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-28
- Publication Date
- 2026-10-30
AI Technical Summary
[0003]本申请提供了一种会话管理方法、计算机设备、计算机可读存储介质以及计算机程序产品,以至少解决相关技术中难以弹性适应会话量而影响会话管理可靠性的问题
[0014]通过本申请,由于在获取会话请求后创建当前会话并形成对应的管理事件,将该管理事件写入由应用实例提供计算资源的消息队列,延迟第一预设时间后监测当前会话是否结束,且在当前会话未结束时适配其会话状态开展会话管理。由于应用实例具备可扩展特性,其提供给消息队列的计算资源能够伴随会话量的变化进行动态调整,会话量激增时可通过扩展应用实例以扩充计算资源,会话量回落时可收缩应用实例以节约计算资源,以此实现计算资源与会话量的精准匹配。这种基于可扩展应用实例以及消息队列的会话管理方式,能够有效避免因计算资源固定而无法适配会话量波动的情况,进而提高会话管理的可靠性,同时依托消息队列的有序处理能力以及状态适配的精准管理,还能够提升整体的会话管理效率。因此,可以解决难以弹性适应会话量而影响会话管理可靠性的技术问题,达到利用可扩展的应用实例以及消息队列实现会话管理,计算资源能够动态适应会话量以提高会话管理可靠性以及管理效率的技术效果。
Smart Images

Figure CN123011550A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of session management technology, and in particular to a session management method, computer device, computer-readable storage medium, and computer program product. Background Technology
[0002] Currently, session management is typically based on data tables, requiring prior configuration of the database and other components via relevant code. However, in real-world scenarios, there may be situations where the number of sessions surges beyond the capacity of the current data tables, leading to session congestion or even system crashes. Summary of the Invention
[0003] This application provides a session management method, a computer device, a computer-readable storage medium, and a computer program product to at least solve the problem in the related art that it is difficult to flexibly adapt to the amount of sessions, thus affecting the reliability of session management.
[0004] This application provides a session management method, which includes: obtaining a session request; creating a current session and generating a management event for the session request; writing the management event into a message queue and delaying for a first preset time to monitor whether the current session has ended; wherein the message queue is provided with computing resources by the application instance; and in response to the current session not ending, performing session management according to the session state of the current session.
[0005] In one embodiment of this application, session management based on the session state of the current session includes: obtaining the role identifier of the last message of the current session as a management identifier; and selectively controlling the generation of prompt messages or the termination of the current session based on different management identifiers.
[0006] In one embodiment of this application, selectively controlling the generation of prompt messages or the termination of the current session according to different management identifiers includes: in response to the management identifier being a user identifier, obtaining the latest message of the customer service role in the current session as a first message; obtaining the time difference between the first message and the last message as a first factor; in response to the first factor reaching a second preset time, sending a prompt reply message to the customer service role; wherein the second preset time is greater than the first preset time.
[0007] In one embodiment of this application, selectively controlling the generation of prompt messages or termination of the current session according to different management identifiers includes: in response to the management identifier being a customer service identifier, obtaining the latest message of the user role in the current session as a second message; obtaining the time difference between the second message and the last message as a second factor; in response to the second factor reaching a third preset time, suspending the current session or ending the current session; wherein the third preset time is greater than the first preset time.
[0008] In one embodiment of this application, in response to the current session not ending, the method further includes: generating a new management event; identifying a pre-configured queue topic for the message queue, and finding a message queue with a queue topic associated with a first preset time as the target queue; writing the new management event to the target queue, and generating a monitoring event after a first preset time delay until the current session ends; wherein the monitoring event is used to monitor whether the current session has ended.
[0009] In one embodiment of this application, after obtaining a session request, the process includes: generating a session identifier; monitoring session messages in the current session; and assigning a session identifier, a sender's role identifier, and a sending time identifier to the session message.
[0010] In one embodiment of this application, the session management method further includes: identifying the instance load of an application instance; and creating a new application instance in response to the instance load reaching a load threshold.
[0011] This application also provides a computer device, which includes: a memory and a processor; the memory is used to store a computer program; the processor is used to implement the steps of any of the above-described session management methods when executing the computer program.
[0012] This application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the above-described session management methods.
[0013] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described session management methods.
[0014] This application achieves a unique approach: upon receiving a session request, a current session is created, generating a corresponding management event. This event is then written to a message queue provided with computing resources by the application instance. After a first preset delay, the system monitors whether the current session has ended. If the session is still active, session management is implemented based on its state. Because application instances are scalable, the computing resources provided to the message queue can be dynamically adjusted according to changes in session volume. When session volume surges, application instances can be expanded to increase computing resources; when session volume decreases, application instances can be shrunk to conserve computing resources, thus achieving precise matching between computing resources and session volume. This session management method, based on scalable application instances and message queues, effectively avoids situations where fixed computing resources cannot adapt to fluctuations in session volume, thereby improving the reliability of session management. Furthermore, leveraging the ordered processing capabilities of message queues and precise state adaptation management, it also enhances overall session management efficiency. Therefore, it solves the technical problem of difficulty in flexibly adapting to session volume, thus affecting the reliability of session management. It achieves the technical effect of utilizing scalable application instances and message queues to implement session management, with computing resources dynamically adapting to session volume to improve both reliability and efficiency. Attached Figure Description
[0015] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 This is a flowchart illustrating an embodiment of the session management method of this application; Figure 2 This is a flowchart illustrating another embodiment of the session management method of this application; Figure 3 This is a schematic diagram illustrating an application scenario of an embodiment of the session management method of this application; Figure 4 This is a schematic diagram of the structure of a computer device according to an embodiment of this application; Figure 5 This is a schematic diagram of another embodiment of the computer device of this application. Detailed Implementation
[0017] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0018] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0019] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0020] The embodiments of this application provide a session management method, and the session management method is described in detail in conjunction with the execution flow of the session management method.
[0021] Please see Figure 1 , Figure 1 This is a flowchart illustrating an embodiment of the session management method of this application.
[0022] S101: Get session request.
[0023] In this embodiment, interaction commands initiated by front-end clients, third-party interfaces, or internal services can be monitored to obtain session requests. Session requests can be different types of interaction requests, such as user login commands, business function call commands, data interaction commands, and customer service requests related to products or software.
[0024] S102: Management event that creates the current session and forms a session request.
[0025] In this embodiment, in response to a session request, a current session corresponding to the request can be created, and a session request management event can be formed based on the basic attributes of the current session to enable subsequent session monitoring and management.
[0026] S103: After writing the management event to the message queue, delay for a first preset time and monitor whether the current session has ended; wherein, the message queue is provided with computing resources by the application instance.
[0027] In this embodiment, the generated management events are written to a message queue. After the writing operation is completed, a first preset time is delayed, and then the running status of the current session is monitored to determine whether the current session has ended. The computing resources for the message queue can be provided by the application instance. The application instance can have flexible and scalable performance, thus adjusting the scale of computing resource supply according to changes in the number of sessions, thereby ensuring the efficiency of the message queue in processing management events.
[0028] S104: In response to the current session not ending, perform session management according to the current session state.
[0029] In this embodiment, in response to the detection that the current session has not ended, the corresponding session management operation can be performed according to the real-time status of the current session, so as to ensure that the session can proceed stably.
[0030] As can be seen above, after obtaining a session request, the current session is created and a corresponding management event is generated. This management event is written to a message queue provided by the application instance's computing resources. After a first preset time delay, it is monitored whether the current session has ended. If the current session has not ended, session management is performed according to its session state. Because application instances are scalable, the computing resources they provide to the message queue can be dynamically adjusted according to changes in session volume. When session volume surges, application instances can be expanded to increase computing resources; when session volume decreases, application instances can be shrunk to save computing resources, thus achieving precise matching between computing resources and session volume. This session management method based on scalable application instances and message queues effectively avoids situations where fixed computing resources cannot adapt to fluctuations in session volume, thereby improving the reliability of session management. Furthermore, relying on the ordered processing capabilities of message queues and precise state adaptation management, it also improves the overall efficiency of session management.
[0031] Furthermore, the instance load of the application instance can be identified. In response to the instance load reaching the load threshold, a new application instance is created.
[0032] In other words, this embodiment can identify application instance load and collect and analyze the runtime load data of each application instance in real time. Instance load can be characterized by single or combined indicators such as CPU utilization, memory usage, message queue task processing latency, and session management event throughput. Real-time monitoring of these indicators through a preset collection period helps ensure accurate understanding of the load status of each application instance.
[0033] Furthermore, to ensure stable support of application instances for session management requirements, a load threshold can be pre-configured. This load threshold can be flexibly set according to factors such as business scenarios, hardware resource limits, and session processing performance requirements, which will not be elaborated here.
[0034] When the system detects that the instance load of a certain application instance has reached the preset load threshold, it can be considered that the computing resources of the current application instance are insufficient to efficiently support the existing session management tasks, and situations such as the accumulation of management events in the message queue and the delay in session status monitoring may occur. Therefore, the application instance expansion mechanism can be automatically triggered to create a new application instance.
[0035] Once a new application instance is created, it can be automatically connected to the message queue's computing resource supply system and work with existing application instances to undertake session management-related computing tasks. This allows for rapid expansion of the overall computing resource scale, ensuring that the computing resource supply can match the growing demand for sessions in a timely manner, further enhancing the elastic adaptability of session management, and guaranteeing the reliability and efficiency of session management.
[0036] Please see Figure 2 , Figure 2 This is a flowchart illustrating another embodiment of the session management method of this application.
[0037] S201: Get session request.
[0038] In this embodiment, session requests can be actively monitored or passively received.
[0039] Furthermore, session identifiers can be generated. Session messages in the current session are monitored. A session identifier, a sender's role identifier, and a sending time identifier are assigned to each session message. This allows for the generation of unique and non-repeating session identifiers for each session request, distinguishing sessions from different sources and subjects, and reducing session confusion or data mismatch issues. Simultaneously, all session messages generated during the current session can be continuously monitored. After collecting each session message, it is assigned the generated session identifier, the message sender's role identifier, and the message sending time identifier. This multi-dimensional identifier binding facilitates the traceability and management of session messages.
[0040] S202: Management event that creates the current session and forms a session request.
[0041] In this embodiment, a current session matching the request can be created based on the session identifier.
[0042] S203: Write management events to the message queue.
[0043] In this embodiment, the message queue is provided with computing resources by the application instance. The application instance has scalability and can dynamically adjust the scale of computing resource supply according to fluctuations in session volume. Management events are written to the message queue according to a preset transmission protocol, thereby leveraging the asynchronous processing capability of the message queue to achieve orderly storage and scheduling of management events. This also alleviates the system response latency problem in synchronous processing mode, thus helping to ensure the reliability and efficiency of session management.
[0044] S204: Delay the first preset time.
[0045] In this embodiment, a first preset time is deferred after the management event is written to the message queue. The first preset time can be flexibly configured according to the actual needs of the business scenario. For example, it can be configured to 5 seconds to reduce the ineffective consumption of system computing resources by high-frequency session status monitoring, improve resource utilization efficiency, and reserve a relatively reasonable time window to ensure the stability of the session status monitoring process.
[0046] S205: Monitor whether the current session has ended.
[0047] In this embodiment, in response to the current session not ending, session management can be performed according to the current session state, and step S206 is executed. In response to the current session ending, the process ends.
[0048] S206: Obtain the management identifier.
[0049] In this embodiment, the role identifier of the last message in the current session can be obtained as a management identifier. This allows for selective control over the generation of prompt messages or the termination of the current session based on different management identifiers. By obtaining this management identifier, differentiated management methods can be implemented for different role entities, enabling selective control over the generation of prompt messages or the termination of the current session, thus improving the flexibility and targeting of session management.
[0050] S207: When the first factor reaches the second preset time, send a prompt reply message to the customer service role.
[0051] In this embodiment, in response to the management identifier being a user identifier, the latest message from the customer service role in the current session can be obtained as the first message. The time difference between the first message and the last message is obtained as a first factor. In response to the first factor reaching a second preset time, a prompt reply message is sent to the customer service role. The second preset time is greater than the first preset time.
[0052] In other words, when the management identifier is the user identifier, it can be assumed that the last message in the current session was sent by the user. Therefore, the latest message sent by the customer service role in the current session can be extracted as the first message. The time difference between the first message and the last message is calculated and defined as the first factor. A pre-configured second preset time is used for status verification. When the first factor reaches the second preset time, it can be assumed that the customer service role has not responded to the user message in a timely manner. A prompt reply message is then automatically sent to the customer service role to remind them to handle user requests promptly and ensure a smooth user experience.
[0053] S208: When the second factor reaches the third preset time, the current session is suspended or the current session is terminated.
[0054] In this embodiment, in response to the management identifier being a customer service identifier, the latest message from the user role in the current session can be obtained as the second message. The time difference between the second message and the last message is obtained as a second factor. In response to the second factor reaching a third preset time, the current session is either suspended or terminated. The third preset time is greater than the first preset time.
[0055] In other words, when the management identifier is the customer service identifier, it can be assumed that the last message of the current session was sent by customer service. Therefore, the latest message sent by the user role in the current session can be extracted as the second message. The time difference between the second message and the last message is calculated and defined as the second factor. A pre-configured third preset time is used for status verification. When the second factor reaches the third preset time, it can be assumed that the user has not responded to customer service messages for a long time. Based on preset rules, the current session can be automatically suspended or terminated directly, thereby reducing the consumption of system computing resources by invalid sessions.
[0056] S209: Generate a new management event.
[0057] In this embodiment, a new management event is generated to return to the message queue in order to monitor whether the current conversation has ended.
[0058] S210: Write the new management event to the target queue.
[0059] In this embodiment, pre-configured queue topics are identified, and a message queue with a queue topic associated with a first preset time is selected as the target queue. A new management event is written to the target queue, and a monitoring event is generated after a first preset time delay, continuing until the current session ends. The monitoring event is used to monitor whether the current session has ended.
[0060] In simpler terms, this embodiment allows for the pre-configuration of different queue topics for the message queue, each associated with different time parameters. When a management event (or even the management event generated in step S202) is to be written to the message queue, all queue topics of the message queue can be identified, and a queue topic associated with a first preset time can be found and designated as the target queue. The new management event is then written to this target queue, achieving the effect of automatically generating a monitoring event after a first preset time delay. This monitoring event can be used to re-monitor whether the current session has ended, until the current session finally terminates.
[0061] Please see Figure 3 , Figure 3 This is a schematic diagram illustrating an application scenario of an embodiment of the session management method of this application.
[0062] In one embodiment, taking MQ (Message Queue) as an example, the interaction modules involved in the session management process can include business nodes, MQ, and a management module. Specifically, the business node can obtain a dialogue request, and either the business node or the management module can generate a management event based on the request and write it to the MQ's message queue. After receiving the management event, the message queue generates a monitoring event and transmits it to the management module. The management module executes the session management method based on the monitoring event, and after completing the operation, generates a new management event and writes it back to the message queue. Through the cyclical interaction between these modules, the session management described above is achieved.
[0063] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.
[0064] Embodiments of this application also provide a session management device.
[0065] The session management device may include an input module and a management module.
[0066] The input module is used to input dialogue requests.
[0067] The management module is used to implement the session management method as described in any of the above embodiments. In other words, the management module can at least obtain session requests; create the current session and form a management event for the session request; write the management event to a message queue and delay for a first preset time to monitor whether the current session has ended; wherein, the message queue is provided with computing resources by the application instance; and in response to the current session not ending, perform session management according to the session state of the current session.
[0068] For a description of the features in the embodiment corresponding to the session management device, please refer to the relevant description of the embodiment corresponding to the session management method, which will not be repeated here.
[0069] Embodiments of this application also provide a computer device. See also... Figure 4 , Figure 4 This is a schematic diagram of the structure of a computer device according to an embodiment of this application.
[0070] In one embodiment, the computer device may include a memory 11 and a processor 12.
[0071] The memory 11 stores a computer program, and the processor 12 is configured to run the computer program to perform the steps in any of the above-described session management method embodiments.
[0072] Please see Figure 5 , Figure 5This is a schematic diagram of another embodiment of the computer device of this application.
[0073] In one embodiment, the computer device may be a server or a terminal.
[0074] Taking a computer device as an example, its internal structure diagram can be as follows: Figure 5 The example illustrates this. A computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it implements a session management method.
[0075] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described session management method embodiments at runtime.
[0076] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0077] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described session management method embodiments.
[0078] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described session management method embodiments.
[0079] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0080] The foregoing has provided a detailed description of a session management method, computer device, computer-readable storage medium, and computer program product provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of this application.
Claims
1. A session management method, characterized in that, The session management method includes: Get the session request; A management event that creates the current session and forms the session request; After writing the management event into the message queue, a first preset time is delayed to monitor whether the current session has ended; wherein, the message queue is provided with computing resources by the application instance; In response to the fact that the current session has not ended, session management is performed according to the session state of the current session.
2. The session management method according to claim 1, characterized in that, The session management based on the session state of the current session includes: Obtain the role identifier of the last message in the current session and use it as the management identifier; The management identifier can be used to selectively control the generation of prompt messages or the termination of the current session.
3. The session management method according to claim 2, characterized in that, The selective control of generating prompt messages or terminating the current session based on different management identifiers includes: In response to the management identifier being a user identifier, the latest message from the customer service role in the current session is obtained as the first message; The time difference between the first message and the last message is used as the first factor; In response to the first factor reaching a second preset time, a prompt reply message is sent to the customer service role; wherein the second preset time is greater than the first preset time.
4. The session management method according to claim 2, characterized in that, The selective control of generating prompt messages or terminating the current session based on different management identifiers includes: In response to the management identifier being a customer service identifier, the latest message of the user role in the current session is obtained as the second message; The time difference between the second message and the last message is used as the second factor. In response to the second factor reaching a third preset time, the current session is either put to sleep or terminated; wherein the third preset time is greater than the first preset time.
5. The session management method according to claim 1, characterized in that, The response after the current session has not ended also includes: Generate new management events; Identify the pre-configured queue topics of the message queue and find the message queue with a queue topic associated with the first preset time as the target queue; The new management event is written to the target queue, and a monitoring event is generated after a first preset time delay until the current session ends; wherein the monitoring event is used to monitor whether the current session has ended.
6. The session management method according to claim 1, characterized in that, After obtaining the session request, the following is included: Generate a session identifier; Monitor session messages in the current session; Assign the session identifier, the sender's role identifier, and the sending time identifier to the session message.
7. The session management method according to claim 1, characterized in that, The session management method also includes: Identify the instance load of the application instance; In response to the instance load reaching the load threshold, a new application instance is created.
8. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the session management method according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the session management method according to any one of claims 1 to 7.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the session management method according to any one of claims 1 to 7.
