Starting processing method, device and equipment of application item, medium and program product

By detecting and replacing the object implementation class of the distributed service client when the application project starts, the problem of application project startup failure caused by the initialization failure of the distributed service client is solved, thus improving startup efficiency and the availability of distributed services.

CN121209983APending Publication Date: 2025-12-26CHINA CONSTRUCTION BANK +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511291066.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-10
Publication Date
2025-12-26

AI Technical Summary

Technical Problem

During the application project startup phase, the failure of the distributed service client initialization caused the application project to fail to start, affecting startup efficiency.

Method used

When the application project starts, it checks whether the object implementation class of the distributed service client is the preset object implementation class, and replaces the preset object implementation class with the target object implementation class when the connection is available, so as to ensure that the distributed service client is initialized successfully.

Benefits of technology

This ensures that the application project will not fail to start due to the failure of the distributed service client initialization, thereby improving the startup efficiency of the application project and ensuring the availability of the distributed service.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121209983A_ABST
    Figure CN121209983A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of big data, and discloses an application item starting processing method and device, equipment, a medium and a program product. The method comprises the following steps: when an application project is started, enabling a distributed service client to be initialized successfully; wherein the distributed service client is used for supporting distributed service capability; the application project quotes the distributed service capability; detecting whether the object implementation class of the successfully initialized distributed service client is a preset object implementation class or not; if the object implementation class of the successfully initialized distributed service client is the preset object implementation class, detecting whether the connection of the distributed service corresponding to the distributed service client is available or not; and if the connection of the distributed service corresponding to the distributed service client is available, replacing the preset object implementation class with a target object implementation class corresponding to the distributed service client. By adopting the method, the starting efficiency of the application project can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of big data technology, and in particular to a method, apparatus, device, medium, and program product for initiating an application project. Background Technology

[0002] With the development of big data and computer technology, the scale of application systems and the amount of data they need to process are constantly expanding. The demand for concurrent data processing and distributed coordination is increasing, requiring application systems to support distributed capabilities to improve their data processing efficiency. Therefore, to enable the rapid implementation of distributed capabilities, application projects used to build application systems can reference distributed service capabilities, which can be supported by distributed service clients.

[0003] To utilize distributed service capabilities, the distributed service client can be initialized during the application project's startup phase. However, in related technologies, initializing the distributed service client during application project startup may fail, causing application startup failure and resulting in low startup efficiency. Summary of the Invention

[0004] Therefore, it is necessary to provide an application project startup processing method, apparatus, equipment, medium, and program product to address the above-mentioned technical problems.

[0005] Firstly, this application provides a method for initiating an application project, including:

[0006] When the application project starts, the distributed service client is initialized successfully; wherein, the distributed service client is used to support distributed service capabilities; the application project references the distributed service capabilities;

[0007] Check whether the object implementation class of the successfully initialized distributed service client is a preset object implementation class;

[0008] If the object implementation class of the successfully initialized distributed service client is the preset object implementation class, then check whether the connection of the distributed service corresponding to the distributed service client is available;

[0009] If the connection to the distributed service corresponding to the distributed service client is available, then the preset object implementation class is replaced with the target object implementation class corresponding to the distributed service client.

[0010] In one embodiment, the step of successfully initializing the distributed service client when the application project starts includes: initializing the distributed service client using the target object implementation class corresponding to the distributed service client when the application project starts; if the target object implementation class fails to successfully initialize the distributed service client, then using a preset object implementation class to successfully initialize the distributed service client.

[0011] In one embodiment, after initializing the distributed service client using the target object implementation class corresponding to the distributed service client, the method further includes: capturing exception information of the distributed service client during the initialization process of the distributed service client; if exception information of the distributed service client is captured, it is determined that the target object implementation class has failed to initialize the distributed service client successfully.

[0012] In one embodiment, the step of successfully initializing the distributed service client when the application project starts includes: using a preset object implementation class to successfully initialize the distributed service client when the application project starts.

[0013] In one embodiment, after detecting whether the connection of the distributed service corresponding to the distributed service client is available, the method further includes: if the connection of the distributed service corresponding to the distributed service client is unavailable, then starting a scheduled task; the scheduled task is used to return to execute the step of detecting whether the connection of the distributed service corresponding to the distributed service client is available according to a target time.

[0014] In one embodiment, after replacing the preset object implementation class with the target object implementation class corresponding to the distributed service client if the connection to the distributed service corresponding to the distributed service client is available, the method further includes:

[0015] If an exception occurs after the target object implementation class replaces the preset object implementation class, then the preset object implementation class is used to replace the target object implementation class, and a scheduled task is started; the scheduled task is used to return to execute the step of detecting whether the connection of the distributed service corresponding to the distributed service client is available according to the target time.

[0016] Secondly, this application also provides an application project initiation processing apparatus, comprising:

[0017] An initialization module is used to ensure that the distributed service client is successfully initialized when the application project starts; wherein, the distributed service client is used to support distributed service capabilities; and the application project references the distributed service capabilities.

[0018] The class detection module is used to detect whether the object implementation class of the successfully initialized distributed service client is a preset object implementation class;

[0019] The service detection module is used to detect whether the connection of the distributed service corresponding to the distributed service client is available if the object implementation class of the successfully initialized distributed service client is the preset object implementation class.

[0020] The class replacement module is used to replace the preset object implementation class with the target object implementation class corresponding to the distributed service client if the connection to the distributed service corresponding to the distributed service client is available.

[0021] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0022] When the application project starts, the distributed service client is initialized successfully; wherein, the distributed service client is used to support distributed service capabilities; the application project references the distributed service capabilities; it is checked whether the object implementation class of the successfully initialized distributed service client is a preset object implementation class; if the object implementation class of the successfully initialized distributed service client is the preset object implementation class, it is checked whether the connection of the distributed service corresponding to the distributed service client is available; if the connection of the distributed service corresponding to the distributed service client is available, the preset object implementation class is replaced with the target object implementation class corresponding to the distributed service client.

[0023] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:

[0024] When the application project starts, the distributed service client is initialized successfully; wherein, the distributed service client is used to support distributed service capabilities; the application project references the distributed service capabilities; it is checked whether the object implementation class of the successfully initialized distributed service client is a preset object implementation class; if the object implementation class of the successfully initialized distributed service client is the preset object implementation class, it is checked whether the connection of the distributed service corresponding to the distributed service client is available; if the connection of the distributed service corresponding to the distributed service client is available, the preset object implementation class is replaced with the target object implementation class corresponding to the distributed service client.

[0025] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:

[0026] When the application project starts, the distributed service client is initialized successfully; wherein, the distributed service client is used to support distributed service capabilities; the application project references the distributed service capabilities; it is checked whether the object implementation class of the successfully initialized distributed service client is a preset object implementation class; if the object implementation class of the successfully initialized distributed service client is the preset object implementation class, it is checked whether the connection of the distributed service corresponding to the distributed service client is available; if the connection of the distributed service corresponding to the distributed service client is available, the preset object implementation class is replaced with the target object implementation class corresponding to the distributed service client.

[0027] The aforementioned application project startup processing method, apparatus, device, medium, and program product ensures successful initialization of the distributed service client during application project startup. This distributed service client supports distributed service capabilities, and the application project references these capabilities. This ensures that the application project will not fail to start due to distributed service client initialization failure. Then, it checks whether the object implementation class of the successfully initialized distributed service client is a preset object implementation class. If it is, it checks whether the connection to the distributed service corresponding to the distributed service client is available. If the connection is available, it replaces the preset object implementation class with the target object implementation class corresponding to the distributed service client. Therefore, while ensuring the application project will not fail to start due to distributed service client initialization failure, it checks whether the object implementation class of the successfully initialized distributed service client is a preset object implementation class. If so, when the connection to the distributed service corresponding to the distributed service client is detected to be available, the target object implementation class of the distributed service client replaces the preset object implementation class, thus making the distributed service available and preventing application project startup failure due to distributed service client initialization failure. This improves application project startup efficiency and ensures the availability of distributed services. Attached Figure Description

[0028] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0029] Figure 1 This is an application environment diagram of the application project startup processing method in one embodiment;

[0030] Figure 2 This is a flowchart illustrating the startup process of an application project in one embodiment;

[0031] Figure 3 This is a flowchart illustrating the steps involved in successfully initializing a distributed service client in one embodiment.

[0032] Figure 4 This is a flowchart illustrating the application project startup process in another embodiment;

[0033] Figure 5 This is a flowchart illustrating the application project startup process in yet another embodiment;

[0034] Figure 6 This is a structural block diagram of the application project startup processing device in one embodiment;

[0035] Figure 7 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0036] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. It should be noted that existing industry solutions such as software, components, and models may be mentioned in the embodiments of this application. These should be considered exemplary and are intended only to illustrate the feasibility of implementing the technical solutions of this application, but do not imply that the applicant has already used or necessarily used such solutions.

[0037] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with relevant regulations. The acquisition, storage, use and processing of data in the technical solution of this application all comply with the relevant provisions of national laws and regulations.

[0038] The terms "first," "second," etc., used in this application may be used to describe various objects, but these objects are not limited by these terms. These terms are only used to distinguish the first object from the second object. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.

[0039] The application project startup processing method provided in this application embodiment can be applied to, for example, Figure 1 The application environment shown is as follows. In this environment, the terminal can communicate with the server via a network. The data storage system can store the data that the server needs to process. The data storage system can be integrated on the server or placed on the cloud or other network servers. For example, when the application project starts, the server can successfully initialize the distributed service client; the distributed service client is used to support distributed service capabilities; the application project references the distributed service capabilities; then the server can check whether the object implementation class of the successfully initialized distributed service client is a preset object implementation class; if the object implementation class of the successfully initialized distributed service client is the preset object implementation class, the server can check whether the connection of the distributed service corresponding to the distributed service client is available; if the connection of the distributed service corresponding to the distributed service client is available, the server can replace the preset object implementation class with the target object implementation class corresponding to the distributed service client. The terminal can be, but is not limited to, various personal computers, laptops, smartphones, tablets, drones, low-altitude aircraft, IoT devices, and portable wearable devices. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, projection devices, etc. Portable wearable devices can be smartwatches, smart bracelets, head-mounted devices, etc. Headset devices can be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. Servers can be standalone physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers that provide cloud computing services.

[0040] In one exemplary embodiment, such as Figure 2 As shown, an application project startup processing method is provided, which can be applied to applications such as... Figure 1 The method may include the following steps:

[0041] Step S201: When the application project starts, ensure the distributed service client is successfully initialized. The distributed service client is used to support distributed service capabilities; the application project references distributed service capabilities.

[0042] Application projects can be used to build application systems. Application projects can reference distributed service capabilities to meet the application system's needs for distributed services, such as the concurrent data processing and distributed coordination requirements of an ever-growing application system. Distributed service clients can be used to support distributed service capabilities; application projects can achieve this by referencing distributed service clients.

[0043] In this step, the server can start the application project, ensuring the distributed service client initializes successfully upon startup. As an implementation method, the server can ensure successful initialization of the distributed service client using a pre-defined object implementation class, thus preventing application startup failure due to distributed service client initialization failure. Here, the object implementation class refers to the implementation class of the distributed service client object. For example, the server can ensure successful initialization of the distributed service client using a pre-defined object implementation class, such as an empty implementation class or a downgraded implementation class.

[0044] Step S202: Check whether the object implementation class of the successfully initialized distributed service client is the preset object implementation class.

[0045] In this step, after the application project starts, the server can check whether the object implementation class of the successfully initialized distributed service client is a preset object implementation class. This preset object implementation class can be one of the pre-defined object implementation classes mentioned above. For example, this object implementation class can be an empty implementation class or a downgraded implementation class, or other pre-defined object implementation classes.

[0046] Step S203: If the object implementation class of the successfully initialized distributed service client is a preset object implementation class, then check whether the connection of the distributed service corresponding to the distributed service client is available.

[0047] In this step, if the server detects that the object implementation class of the successfully initialized distributed service client is a preset object implementation class, it means that the object implementation class of the distributed service client needs to be processed. First, it can check whether the connection of the distributed service corresponding to the distributed service client is available. If it is detected that the connection of the distributed service corresponding to the distributed service client is available, step S204 can be executed.

[0048] In some embodiments, if the server detects that the object implementation class of the successfully initialized distributed service client is not a preset object implementation class, it can determine that the object implementation class of the successfully initialized distributed service client is the target object implementation class corresponding to the distributed service client. The target object implementation class can be the actual implementation class corresponding to the distributed service client. In this case, the server can end the processing flow because the distributed service client referenced by the application project has been successfully initialized and the initialization has been successfully implemented through the target object implementation class corresponding to the distributed service client. Therefore, the distributed service capability referenced by the application project is in an available state, and there is no need to process the object implementation class of the distributed service client anymore.

[0049] Step S204: If the connection to the distributed service corresponding to the distributed service client is available, then replace the preset object implementation class with the target object implementation class corresponding to the distributed service client.

[0050] In this step, when the server detects that the successfully initialized distributed service client's object implementation class is a preset object implementation class and that the connection to the distributed service corresponding to the distributed service client is available, the server can replace the preset object implementation class with the target object implementation class corresponding to the distributed service client, allowing the distributed service capabilities referenced by the application project to be used. Specifically, the server can replace the preset object implementation class that originally enabled the distributed service client to initialize successfully with the actual implementation class corresponding to the distributed service client, thus enabling the distributed service capabilities referenced by the application project to be used.

[0051] The application project startup method in this embodiment ensures that the distributed service client is successfully initialized during application project startup. This distributed service client supports distributed service capabilities, and the application project references these capabilities. This ensures that the application project will not fail to start due to distributed service client initialization failure. Then, it checks whether the object implementation class of the successfully initialized distributed service client is a preset object implementation class. If it is, it checks whether the connection to the distributed service corresponding to the distributed service client is available. If the connection is available, it replaces the preset object implementation class with the target object implementation class corresponding to the distributed service client. Therefore, while ensuring the application project will not fail to start due to distributed service client initialization failure, it checks whether the object implementation class of the successfully initialized distributed service client is a preset object implementation class. If so, when the connection to the distributed service corresponding to the distributed service client is detected to be available, the target object implementation class of the distributed service client replaces the preset object implementation class, thus making the distributed service available and avoiding application project startup failure due to distributed service client initialization failure. This improves application project startup efficiency and ensures the availability of distributed services.

[0052] In one exemplary embodiment, such as Figure 3 As shown, step S201, which involves successfully initializing the distributed service client when the application project starts, may include the following steps:

[0053] Step S301: When the application project starts, the distributed service client is initialized using the target object implementation class corresponding to the distributed service client; Step S303: If the target object implementation class fails to initialize the distributed service client, the preset object implementation class is used to initialize the distributed service client successfully.

[0054] In this embodiment, the server can execute step S301, which initializes the distributed service client using the target object implementation class corresponding to the distributed service client when the application project starts. Then, step S302 is executed to check whether the distributed service client has been successfully initialized, i.e., whether the target object implementation class has enabled the distributed service client to be successfully initialized. If not, step S303 is executed; if yes, step S304, the termination step, is executed. After this termination step, the server can continue executing step S202. In step S303, if the target object implementation class fails to initialize the distributed service client, the server can use a preset object implementation class to enable the distributed service client to be successfully initialized, and then execute step S304, the termination step. After this termination step, the server can continue executing step S202. As an example, when the actual implementation class corresponding to the distributed service client cannot enable the distributed service client to be successfully initialized, a preset object implementation class, such as an empty implementation class or a downgraded implementation class, is used to enable the distributed service client to be successfully initialized, ensuring that the application project does not fail to start due to the failure of the distributed service client initialization.

[0055] In this embodiment, the distributed service client can be initialized using the target object implementation class corresponding to the distributed service client. This allows the application project to start normally and use the distributed service if the distributed service is available. Furthermore, if the target object implementation class fails to initialize the distributed service client, a preset object implementation class can be used to initialize the distributed service client, thus preventing the application project from failing to start due to the failure of the distributed service client initialization.

[0056] In an exemplary embodiment, after initializing the distributed service client using the target object implementation class corresponding to the distributed service client in step S301 above, the following steps may also be included:

[0057] During the initialization of the distributed service client, capture any exception information from the distributed service client. If any exception information from the distributed service client is captured, it is determined that the target object implementation class failed to initialize the distributed service client successfully.

[0058] In this embodiment, exception handling can be added at the initialization of the distributed service client. This exception handling can be used to capture exception information of the distributed service client during the initialization process. This exception information can indicate that an exception occurred during the initialization of the distributed service client, such as a distributed service connection failure. Based on this, the server can capture exception information of the distributed service client during the initialization process by adding exception handling at the initialization of the distributed service client. If the server does not capture the exception information of the distributed service client, it can determine that the target object implementation class has successfully initialized the distributed service client, and thus the above-mentioned step S304 (the end step) can be executed. If the server captures the exception information of the distributed service client, it can determine that the target object implementation class has failed to successfully initialize the distributed service client, and thus the above-mentioned step S303 can be executed to use a preset object implementation class to successfully initialize the distributed service client.

[0059] The solution in this embodiment can be used to implement the step of detecting whether the distributed service client has been successfully initialized in step S302 above. By adding exception handling at the initialization of the distributed service client, it is possible to accurately and conveniently detect whether the target object implementation class has enabled the distributed service client to be initialized successfully. This makes it easier to use a preset object implementation class to enable the distributed service client to be initialized successfully in a timely manner when it is detected that the target object implementation class has failed to initialize the distributed service client, thus avoiding the application project from failing to start due to the failure of the distributed service client initialization.

[0060] In an exemplary embodiment, step S201, which involves successfully initializing the distributed service client upon application startup, may include:

[0061] When the application project starts, the distributed service client is initialized successfully using a preset object implementation class.

[0062] In this embodiment, when the application project starts, the server can directly use the preset object implementation class to successfully initialize the distributed service client, thereby prioritizing the normal startup of the application project and improving the startup efficiency of the application project. Then, through the above steps S203 to S204, if the connection of the distributed service corresponding to the distributed service client is available, the target object implementation class corresponding to the distributed service client can be used to replace the preset object implementation class, so that the distributed service capabilities referenced by the application project can be used.

[0063] In an exemplary embodiment, after detecting whether the connection to the distributed service corresponding to the distributed service client is available in step S203, the following steps may also be included:

[0064] If the connection to the distributed service corresponding to the distributed service client is unavailable, a scheduled task is started. This scheduled task is used to return and execute the step of checking whether the connection to the distributed service corresponding to the distributed service client is available at a target time.

[0065] In this embodiment, the server checks whether the connection to the distributed service corresponding to the distributed service client is available. If the connection is unavailable, it indicates an abnormal connection to the distributed service. In this case, the server can start a scheduled task, which, for example, can be an asynchronous scheduled task. This scheduled task can be used to return to the execution of step S203, which checks whether the connection to the distributed service corresponding to the distributed service client is available, according to a target time. The target time can be a custom time, such as 30 seconds. In some embodiments, the target time can be a periodic target time, referred to as the target period. The scheduled task returns to the execution of the step checking whether the connection to the distributed service corresponding to the distributed service client is available according to the target period, until the connection to the distributed service corresponding to the distributed service client is found to be available. In some embodiments, if the connection to the distributed service corresponding to the distributed service client is unavailable, an alarm can be set to indicate that the connection to the distributed service detected is unavailable, thus providing a timely and accurate indication of the current availability status of the distributed service connection.

[0066] The solution in this embodiment can start a scheduled task to return to the step of checking whether the distributed service connection is available at a target time when the connection of the distributed service corresponding to the distributed service client is detected to be unavailable. This achieves the effect of attempting to reconnect at a target time when the connection of the distributed service is unavailable, so as to ensure that the distributed service is restored to an available state as soon as possible.

[0067] In an exemplary embodiment, after step S204, where the connection to the distributed service corresponding to the distributed service client is available, and the target object implementation class corresponding to the distributed service client is used to replace the preset object implementation class, the following steps may also be included:

[0068] If an exception occurs after replacing the preset object implementation class with the target object implementation class, the preset object implementation class will be used to replace the target object implementation class, and a scheduled task will be started. The scheduled task is used to return at a target time to perform the step of checking whether the connection to the distributed service corresponding to the distributed service client is available.

[0069] In this embodiment, when the connection to the distributed service corresponding to the distributed service client is available, the target object implementation class corresponding to the distributed service client can be used to replace the preset object implementation class. If no exception occurs when replacing the preset object implementation class with the target object implementation class, such as no creation exception, the server can determine that the application project can use the distributed service normally. If an exception occurs after replacing the preset object implementation class with the target object implementation class, such as a creation exception, the server can continue to use the preset object implementation class to replace the target object implementation class and start a scheduled task. As an example, this scheduled task can be an asynchronous scheduled task. This scheduled task can be used to return and execute the step of detecting whether the connection to the distributed service corresponding to the distributed service client is available in step S203 according to a target time. The target time can be a custom time, such as 30 seconds. In some embodiments, the target time can be a periodic target time, which can be denoted as the target period. The scheduled task can be used to return and execute the step of detecting whether the connection to the distributed service corresponding to the distributed service client is available according to the target period, until the connection to the distributed service corresponding to the distributed service client is detected to be available. In some embodiments, after the server continues to replace the target object implementation class with the preset object implementation class, it can also set an alarm prompt. The alarm prompt can be used to indicate whether the connection of the distributed service being tested is available, whether there is an exception after the target object implementation class is replaced with the preset object implementation class, etc., so as to indicate the status information during the retry process of the distributed service in a timely and accurate manner. The status information can include the current availability status of the distributed service, the abnormal status of the target object implementation class replacing the preset object implementation class, etc.

[0070] Therefore, if the connection to the distributed service corresponding to the distributed service client is detected to be available, the step of replacing the preset object implementation class with the target object implementation class corresponding to the distributed service client in step S204 above can be executed again, and it can be checked whether an exception occurs after the target object implementation class replaces the preset object implementation class. If no exception occurs, the server can determine that the application project can use the distributed service normally. If an exception occurs, the target object implementation class can be replaced with the preset object implementation class again and the scheduled task can be started until no exception occurs after the target object implementation class replaces the preset object implementation class.

[0071] The solution in this embodiment can replace the target object implementation class with the preset object implementation class and start a scheduled task when it is detected that the connection of the distributed service corresponding to the distributed service client is available and an anomaly occurs after the target object implementation class is replaced with the preset object implementation class. This achieves the effect of attempting to reconnect and try to replace the preset object implementation class with the target object implementation class again according to the target time, so as to ensure that the distributed service is restored to an available state as soon as possible.

[0072] In one exemplary embodiment, such as Figure 4 As shown, an application project startup processing method is also provided, which may include the following steps:

[0073] Step S401: When the application project starts, the distributed service client is initialized using the target object implementation class corresponding to the distributed service client. The distributed service client is used to support distributed service capabilities; the application project references distributed service capabilities.

[0074] As an example, the application project could be a Spring Boot project, and the distributed service client could be the corresponding client for RedissonClient. Spring Boot is a rapid development framework based on the Spring framework, which simplifies the setup and development process of Spring applications. Spring is an open-source framework widely used in Java development. RedissonClient is a Redis client object provided by Redisson, which encapsulates various methods and functionalities for interacting with the Redis server, allowing convenient Redis operations through Java code. Redisson is a Java-based Redis client that provides rich data structures and distributed services.

[0075] As an example, a Spring Boot project can initialize a RedissonClient object at startup. In this step, the actual implementation class of RedissonClient can be used as the target object implementation class to initialize the RedissonClient object.

[0076] Step S402: Check whether the distributed service client has been successfully initialized.

[0077] As an example, you can configure the Spring container-managed object for connecting to Redis, add exception handling when initializing the RedissonClient object, and use exception handling to detect whether the distributed service client has been initialized successfully.

[0078] Step S403: If the target object implementation class fails to initialize the distributed service client, then the preset object implementation class is used to initialize the distributed service client successfully, and step S405 is executed.

[0079] As an example, a custom empty implementation class, EmptyRedissonClient, can be pre-defined as the default object implementation class that implements the RedissonClient interface. The interface methods can be configured to all throw a Redisson connection exception (RedisConnectionException). In this step, if an exception occurs during the initialization of the distributed service client, the custom empty implementation class EmptyRedissonClient can be used directly for initialization, and then step S405 can be executed.

[0080] Step S404: If the target object implementation class enables the distributed service client to initialize successfully, then proceed to step S405.

[0081] In this step, if the actual implementation class corresponding to RedissonClient successfully initializes the RedissonClient object, then step S405 can be executed.

[0082] Step S405: Check whether the object implementation class of the successfully initialized distributed service client is the preset object implementation class.

[0083] As an example, the ApplicationReadyEvent event can be pre-registered. This ApplicationReadyEvent can be a lifecycle event emitted by Spring Boot when the application has fully started and is ready to receive requests. For this ApplicationReadyEvent event, the onApplicationEvent method can be used to implement a step to check whether the implementation class of the successfully initialized distributed service client object is a preset object implementation class. Specifically, it can check whether the implementation class of the successfully initialized distributed service client object in the Spring container-managed object factory is a preset object implementation class, i.e., an empty implementation class. Conversely, it can also check whether the implementation class of the successfully initialized distributed service client object in the Spring container-managed object factory is a real implementation class.

[0084] Step S406: If the object implementation class of the successfully initialized distributed service client is not the preset object implementation class, then the process ends.

[0085] As an example, the process can end if the object implementation class of the successfully initialized distributed service client is not an empty implementation class, or if the object implementation class of the successfully initialized distributed service client is a real implementation class.

[0086] Step S407: If the object implementation class of the successfully initialized distributed service client is a preset object implementation class, then check whether the connection of the distributed service corresponding to the distributed service client is available.

[0087] As an example, if the object implementation class of the successfully initialized distributed service client is an empty implementation class, or if the object implementation class of the successfully initialized distributed service client is not a real implementation class, then the availability of the Redis connection can be checked.

[0088] Step S408: If the connection to the distributed service corresponding to the distributed service client is unavailable, start the scheduled task.

[0089] As an example, if the Redis connection fails, i.e., the Redis connection is unavailable, an asynchronous scheduled task can be started. This asynchronous scheduled task can be applied to return to the step of checking whether the connection of the distributed service corresponding to the distributed service client is available, which is executed according to a target time, in step S407 above. As an example, the target time could be, for example, 30 seconds. In some embodiments, alarm information can also be set. This alarm can be used to indicate that the connection of the distributed service detected is unavailable, etc.

[0090] Step S409: If the connection to the distributed service corresponding to the distributed service client is available, then replace the preset object implementation class with the target object implementation class corresponding to the distributed service client.

[0091] As an example, if the Redis connection is available, you can create a Spring container managed object definition using the actual implementation class, put it into the Spring container managed object factory, and try to replace the empty implementation class in the Spring container managed object factory.

[0092] Step S410: Detect whether there is an exception after the target object implementation class is replaced with the preset object implementation class.

[0093] As an example, it can be used to detect whether there are any exceptions after the actual implementation class is replaced with an empty implementation class, such as whether there are any exceptions or failures in the creation of the actual implementation class.

[0094] Step S411: If there is no exception when the target object implementation class replaces the preset object implementation class, then the process ends.

[0095] As an example, if no exception occurs after replacing the empty implementation class with the real implementation class, the process can be terminated.

[0096] Step S412: If an exception occurs after the target object implementation class is replaced with the preset object implementation class, then the preset object implementation class is used to replace the target object implementation class, and the scheduled task is started.

[0097] As an example, if an exception occurs after replacing the empty implementation class with the actual implementation class, a custom empty implementation class can be used to create a Spring container-managed object definition, which can then be placed into the Spring container-managed object factory to replace the actual implementation class. An asynchronous scheduled task can be started and an alarm can be set. The asynchronous scheduled task can be used to return to step S407 (checking whether the connection to the distributed service corresponding to the distributed service client is available) at a target time. The alarm can be used to indicate whether the connection to the distributed service being checked is available, or if an exception occurred after replacing the preset object implementation class with the target object implementation class, etc.

[0098] The solution in this embodiment can be applied to the startup of a Spring Boot project, such as... Figure 5 As shown, starting a Spring Boot project can include the following steps:

[0099] Step S501: Initialize the environment.

[0100] The initialization process includes loading environment configurations, parsing configuration sources, and setting system properties to prepare the application for startup. This includes configuring Redis connection parameters (such as connection address, cluster information, etc.) within the project.

[0101] Step S502, Event Listener: Register an event listener.

[0102] During this stage, you can register custom event listeners (such as ApplicationReadyEventListener) to perform specific tasks after the application starts.

[0103] Specifically, you can register an `ApplicationReadyEvent` event and implement the following in the `onApplicationEvent` method: Check if the implementation class of the `RedissonClient` object in the Spring container's managed object factory is a real implementation class. If it is, the process can end. If it is not, check if the Redis connection is normal. If the connection fails, start an asynchronous scheduled task to retry. If the connection is normal, create a Spring container managed object definition using the real implementation class and put it into the Spring container managed object factory. If initializing the Spring container managed object fails or an exception occurs, you can create a Spring container managed object definition using a custom empty implementation class, put it into the Spring container managed object factory, and start an asynchronous scheduled task to retry, etc.

[0104] Step S503: Load resources.

[0105] This allows you to load the resources required by the application, such as configuration files, static resources, and so on.

[0106] Step S504: Create the Spring container.

[0107] This involves initializing the Spring container, which manages various Beans within the application. A Bean is an object managed by the Spring framework.

[0108] Step S505: Initialize the Bean object.

[0109] This allows you to create and initialize various Bean objects, including RedissonClient objects. If RedissonClient initialization fails, the application will fail to start.

[0110] Step S506: Execute the method that implements the interface.

[0111] In this step, the run methods of classes that implement the ApplicationRunner and CommandLineRunner interfaces can be executed: after the application starts, the run methods in these classes can be used to perform some initialization tasks after startup.

[0112] Step S507, trigger the event.

[0113] In this step, events such as ApplicationStartedEvent and ApplicationReadyEvent can be triggered. These events can be triggered at different stages of application startup to notify registered listeners to perform corresponding operations.

[0114] In application scenarios, using Redisson in a Spring Boot project allows you to access its distributed data structures and distributed locking capabilities. As application systems grow in scale, the demand for concurrent data processing and distributed coordination increases, leading to a continuous strengthening of the need for Redisson in application projects.

[0115] In this context, the solution in this embodiment allows for empty initialization when the Redis service is unavailable during application startup, preventing application startup failure. After the application has successfully started and is ready to handle requests, it checks if the objects in the Spring container-managed object factory are real objects. If not, it attempts to replace the objects in the Spring container-managed object factory. If this fails, an asynchronous scheduled task can be started to retry after 30 seconds (customizable). Therefore, the unavailability of the Redis service will not cause application startup failure. The application will automatically restore the objects corresponding to the Redis connection in the Spring container-managed object factory when the Redis service recovers, making the Redis service available. This avoids the problem of application startup failure due to the Redis service not starting or crashing, and also avoids the impact on development efficiency when Redis service connection problems occur during development, thus improving the startup efficiency of the application project.

[0116] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.

[0117] Based on the same inventive concept, this application also provides an application project startup processing apparatus for implementing the application project startup processing method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more application project startup processing apparatus embodiments provided below can be found in the limitations of the application project startup processing method described above, and will not be repeated here.

[0118] In one exemplary embodiment, such as Figure 6 As shown, an application project startup processing device 600 is provided, which may include:

[0119] An initialization module 601 is used to ensure that the distributed service client is successfully initialized when the application project starts; wherein, the distributed service client is used to support distributed service capabilities; and the application project references the distributed service capabilities.

[0120] Class detection module 602 is used to detect whether the object implementation class of the successfully initialized distributed service client is a preset object implementation class;

[0121] The service detection module 603 is used to detect whether the connection of the distributed service corresponding to the distributed service client is available if the object implementation class of the successfully initialized distributed service client is the preset object implementation class.

[0122] The class replacement module 604 is used to replace the preset object implementation class with the target object implementation class corresponding to the distributed service client if the connection to the distributed service corresponding to the distributed service client is available.

[0123] In an exemplary embodiment, the initialization module 601 is used to initialize the distributed service client using the target object implementation class corresponding to the distributed service client when the application project starts; if the target object implementation class fails to initialize the distributed service client successfully, a preset object implementation class is used to initialize the distributed service client successfully.

[0124] In an exemplary embodiment, the initialization module 601 is further configured to capture exception information of the distributed service client during the initialization process of the distributed service client; if exception information of the distributed service client is captured, it is determined that the target object implementation class has failed to initialize the distributed service client successfully.

[0125] In an exemplary embodiment, the initialization module 601 is used to enable the distributed service client to be successfully initialized using a preset object implementation class when the application project starts.

[0126] In an exemplary embodiment, the device 600 may further include: a first retry module, configured to start a scheduled task if the connection to the distributed service corresponding to the distributed service client is unavailable; the scheduled task is configured to return to the execution of the step of detecting whether the connection to the distributed service corresponding to the distributed service client is available according to a target time.

[0127] In an exemplary embodiment, the device 600 may further include: a second retry module, configured to replace the target object implementation class with the preset object implementation class and start a timed task if an exception occurs after the target object implementation class replaces the preset object implementation class; the timed task is configured to return to the step of detecting whether the connection of the distributed service corresponding to the distributed service client is available according to a target time.

[0128] Each module in the startup processing device of the aforementioned application project can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0129] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 7 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external devices via a network connection. When the computer program is executed by the processor, it implements an application project startup process.

[0130] Those skilled in the art will understand that Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0131] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0132] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0133] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0134] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0135] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0136] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for initiating an application project, characterized in that, The method includes: When the application project starts, the distributed service client is initialized successfully; wherein, the distributed service client is used to support distributed service capabilities; the application project references the distributed service capabilities; Check whether the object implementation class of the successfully initialized distributed service client is a preset object implementation class; If the object implementation class of the successfully initialized distributed service client is the preset object implementation class, then check whether the connection of the distributed service corresponding to the distributed service client is available; If the connection to the distributed service corresponding to the distributed service client is available, then the preset object implementation class is replaced with the target object implementation class corresponding to the distributed service client.

2. The method according to claim 1, characterized in that, The step of ensuring successful initialization of the distributed service client upon application project startup includes: When the application project starts, the distributed service client is initialized using the target object implementation class corresponding to the distributed service client. If the target object implementation class fails to initialize the distributed service client, then the preset object implementation class is used to initialize the distributed service client successfully.

3. The method according to claim 2, characterized in that, After initializing the distributed service client using the target object implementation class corresponding to the distributed service client, the process further includes: During the initialization process of the distributed service client, capture the abnormal information of the distributed service client; If an exception is detected in the distributed service client, it is determined that the target object implementation class failed to initialize the distributed service client successfully.

4. The method according to claim 1, characterized in that, The step of ensuring successful initialization of the distributed service client upon application project startup includes: When the application project starts, the distributed service client is initialized successfully using a preset object implementation class.

5. The method according to claim 1, characterized in that, After detecting whether the connection to the distributed service corresponding to the distributed service client is available, the method further includes: If the connection to the distributed service corresponding to the distributed service client is unavailable, a scheduled task is started; the scheduled task is used to return to execute the step of detecting whether the connection to the distributed service corresponding to the distributed service client is available according to a target time.

6. The method according to any one of claims 1 to 5, characterized in that, If the connection to the distributed service corresponding to the distributed service client is available, then after replacing the preset object implementation class with the target object implementation class corresponding to the distributed service client, the method further includes: If an exception occurs after the target object implementation class replaces the preset object implementation class, then the preset object implementation class is used to replace the target object implementation class, and a scheduled task is started; the scheduled task is used to return to execute the step of detecting whether the connection of the distributed service corresponding to the distributed service client is available according to the target time.

7. An application project initiation processing device, characterized in that, The device includes: An initialization module is used to ensure that the distributed service client is successfully initialized when the application project starts; wherein, the distributed service client is used to support distributed service capabilities; and the application project references the distributed service capabilities. The class detection module is used to detect whether the object implementation class of the successfully initialized distributed service client is a preset object implementation class; The service detection module is used to detect whether the connection of the distributed service corresponding to the distributed service client is available if the object implementation class of the successfully initialized distributed service client is the preset object implementation class. The class replacement module is used to replace the preset object implementation class with the target object implementation class corresponding to the distributed service client if the connection to the distributed service corresponding to the distributed service client is available.

8. The apparatus according to claim 7, characterized in that, The initialization module is used to initialize the distributed service client using the target object implementation class corresponding to the distributed service client when the application project starts; if the target object implementation class fails to initialize the distributed service client, a preset object implementation class is used to initialize the distributed service client successfully.

9. The apparatus according to claim 8, characterized in that, The initialization module is further configured to capture exception information of the distributed service client during the initialization process of the distributed service client; if exception information of the distributed service client is captured, it is determined that the target object implementation class has failed to initialize the distributed service client successfully.

10. The apparatus according to claim 7, characterized in that, The initialization module is used to initialize the distributed service client successfully using a preset object implementation class when the application project starts.

11. The apparatus according to claim 7, characterized in that, The device further includes: a first retry module, configured to start a scheduled task if the connection to the distributed service corresponding to the distributed service client is unavailable; the scheduled task is configured to return to execute the step of detecting whether the connection to the distributed service corresponding to the distributed service client is available according to a target time.

12. The apparatus according to any one of claims 7 to 11, characterized in that, The device further includes: a second retry module, configured to replace the target object implementation class with the preset object implementation class and start a timed task if an exception occurs after the target object implementation class replaces the preset object implementation class; the timed task is configured to return to execute the step of detecting whether the connection of the distributed service corresponding to the distributed service client is available according to a target time.

13. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

14. 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 method according to any one of claims 1 to 6.

15. 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 method according to any one of claims 1 to 6.