Method and device for realizing alarm communication based on periodic scheduling

By creating and persisting message communication units in periodic task scheduling, and using delay queues and custom channel executors, the problems of large memory resource consumption and poor flexibility are solved, efficient alarm communication and flexible scheduling configuration are achieved, and the system is enhanced. The stability and reliability of the system are achieved.

CN119135518AInactive Publication Date: 2024-12-13杭州玳数科技有限公司
View PDF 16 Cites 0 Cited by

Patent Information

Application Number
CN202411624352.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-14
Publication Date
2024-12-13
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The prior art consumes high memory resources and poor flexibility in periodic task scheduling, and is especially not suitable for dynamic message communication scenarios.

Method used

Using a periodic scheduling method, by creating a message communication unit and persisting it to the database, performing custom periodic scheduling components to search and process messages regularly, using delay queues and custom channel executors to push alarm information, supports a variety of Alarm method, flexible scheduling configuration, and a retry mechanism.

Benefits of technology

It significantly improves processing efficiency, supports multiple alarm modes, provides flexible scheduling configuration and enhanced stability and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119135518A_ABST
    Figure CN119135518A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a device for realizing alarm communication based on periodic scheduling, relates to the technical field of big data, and solves the problems of high memory resource consumption and poor flexibility during periodic task scheduling in the prior art. According to the method, the message communication unit in the database is regularly retrieved and processed, the retrieved message communication unit is timely forwarded to the self-defined alarm executor, and the alarm information is pushed to the specified client through the self-defined alarm executor by a preset alarm channel. By adopting the caching technology, frequent I / O operation on the database is effectively reduced, the processing efficiency is remarkably improved, alarm channels can be customized according to different application scenes, and flexible and diversified notification solutions are provided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of big data technology, and in particular to a method and device for realizing alarm communication based on periodic scheduling. Background Art

[0002] Periodic scheduling usually relies on a user-defined schedule to execute tasks. This scheduling method has regularity. Currently, the QuartzJob component is a common tool for handling such tasks. The QuartzJob component is a core component in the Quartz framework, which is used to define tasks that need to be executed regularly. It is mainly used to configure tasks before the program starts. However, QuartzJob may not be suitable for situations where alarms need to be sent during program operation, because it is not suitable for dynamic message communication scenarios.

[0003] Another type, ScheduledExecutorService, is an interface in the Java concurrent package (java.util.concurrent), which provides a mechanism for scheduling and executing scheduled tasks. It is a subinterface of ExecutorService, which is specifically used to schedule the execution of tasks. ScheduledExecutorService can handle task scheduling during program execution, and it manages the execution of scheduled tasks through a thread pool. However, each task execution requires the allocation of an independent thread, which may result in a large consumption of memory resources when processing a large number of tasks. In addition, once a task is submitted, its periodicity can no longer be adjusted, which limits its flexibility. Summary of the invention

[0004] The purpose of the present application is to overcome the problems of large memory resource consumption and poor flexibility in periodic task scheduling in the prior art, and to provide a method and device for realizing alarm communication based on periodic scheduling.

[0005] In a first aspect, a method for realizing alarm communication based on periodic scheduling is provided, comprising:

[0006] Creating a message communication unit for caching and transmitting notification information, and persisting the message communication unit in a database;

[0007] Periodically executing a custom periodic scheduling component, wherein the custom periodic scheduling component is used to retrieve and process message communication units in a database, and forward the retrieved message communication units to a custom alarm executor in a timely manner;

[0008] Use a custom alarm executor to push alarm information to the specified client via the preset alarm channel.

[0009] In some possible implementations, creating a message communication unit for caching and transmitting notification information includes:

[0010] Set the alarm cycle and alarm channel of the operation unit content, which is used to send notifications through the alarm channel when the alarm is triggered;

[0011] Encapsulate the operation unit content, alarm cycle and alarm channel into a message communication unit, and add a message communication unit cache layer;

[0012] Adds a message communication unit to the message communication unit cache layer.

[0013] In some possible implementations, the message communication unit is persisted in a database, including: using a capacity mechanism strategy and a time mechanism strategy to persist the data in the message communication unit cache layer in the database, and maintaining a version number for each message communication unit. If the message communication unit already exists in the database, the version number of the message communication unit is incremented during an update.

[0014] In some possible implementations, the capacity mechanism strategy is that if the capacity in the message communication unit cache layer exceeds a preset value, the data is written into the database in batches; the time mechanism strategy is that if the capacity is less than a preset value, the non-persistent data detected before the start of a new day is written into the database in batches.

[0015] In some possible implementations, retrieving and processing a message communication unit in a database, and forwarding the retrieved message communication unit to a custom alarm executor in a timely manner, includes:

[0016] Regularly running a custom periodic scheduling component through a timer task, retrieving a message communication unit from the database, and passing the retrieved communication unit to a custom date parser;

[0017] The custom date parser parses the scheduling configuration from the message communication unit and extracts the start time and frequency type to filter out the message communication unit with a valid scheduling date that matches the current date. For the filtered message communication unit, the specific deferred execution time of the day is calculated, and the message communication unit and the deferred execution time are passed to the delay queue;

[0018] The delay queue stores the message communication units and schedules the sending of the messages according to the preset delayed sending time;

[0019] Check whether there is a message communication unit in the delay queue, obtain the message communication unit to be sent, re-pull the latest information of the message communication unit from the database, and compare the version numbers. If the version numbers are consistent, send the message communication unit to the custom alarm executor; otherwise, destroy the message communication unit.

[0020] In some possible implementations, the custom alarm executor is used to receive a message communication unit from a custom periodic scheduling component, extract the alarm channel type from the message communication unit, and pass the message communication unit to a corresponding custom channel executor, and the custom channel executor calls a send() method to send an alarm through a corresponding alarm channel, wherein new alarm channels can be added by implementing the buildSession() method and the send() method.

[0021] In some possible implementations, the execution status of the send() method is monitored. If the sending fails, the message communication unit will be added to a custom retry queue, and an upper limit on the number of retries will be set and the number of retries will be recorded.

[0022] In a second aspect, a device for implementing alarm communication based on periodic scheduling is provided, comprising:

[0023] An encapsulation module, used to create a message communication unit for caching and transmitting notification information, and persist the message communication unit in a database;

[0024] A timed task module, used for periodically executing a custom periodic scheduling component, wherein the custom periodic scheduling component is used to retrieve and process message communication units in a database, and forward the retrieved message communication units to a custom alarm executor in a timely manner;

[0025] The alarm execution module is used to push the alarm information to the specified client through the preset alarm channel via the custom alarm executor.

[0026] In a third aspect, a computer-readable storage medium is provided, wherein the computer-readable medium stores a program code for execution by a device, wherein the program code includes steps for executing the method in any one of the implementations of the first aspect described above.

[0027] In a fourth aspect, an electronic device is provided, comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements a method as in any one of the implementations in the first aspect above.

[0028] This application has the following beneficial effects:

[0029] 1. When processing the message communication unit, this application effectively reduces the frequent I / O operations on the database by adopting the cache technology, significantly improves the processing efficiency, and supports multiple alarm modes;

[0030] 2. This application integrates scheduled tasks and delay queues, allowing users to easily configure and adjust the scheduling time of alarms through a simple user interface. In addition, the custom channel executor can be customized according to different application scenarios, providing flexible and diverse notification solutions;

[0031] 3. This application also has a retry mechanism to ensure that the alarm message can be automatically resent when the sending fails, thereby enhancing the stability and reliability of the alarm system. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application.

[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0034] Figure 1 It is a flow chart of the method for realizing alarm communication based on periodic scheduling of the present application;

[0035] Figure 2 is a flowchart of a method for realizing alarm communication based on periodic scheduling according to Embodiment 1 of the present application;

[0036] Figure 3 This is a flowchart of pushing alarm information in the method for realizing alarm communication based on periodic scheduling in Example 1 of the present application;

[0037] Figure 4 It is a schematic diagram of a user interface for setting scheduling attributes in the method for realizing alarm communication based on periodic scheduling in Example 1 of the present application;

[0038] Figure 5 It is a structural block diagram of a device for realizing alarm communication based on periodic scheduling according to Embodiment 2 of the present application;

[0039] Figure 6 It is a schematic diagram of the internal structure of the electronic device of Example 4 of the present application.

[0040] Reference numerals:

[0041] 100, encapsulation module; 200, scheduled task module; 300, alarm execution module. DETAILED DESCRIPTION

[0042] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0043] Example 1

[0044] like Figure 1 and Figure 2 As shown, a method for realizing alarm communication based on periodic scheduling involved in Embodiment 1 of the present application includes:

[0045] S100, creating a message communication unit for caching and transmitting notification information, and persisting the message communication unit in a database, the purpose is to create a message communication unit for storing and transmitting notification information, and persisting it in a database, specifically including the following steps:

[0046] S101, can be Figure 4 In the user interface shown, set a specific alarm period (for example, specify a specific time on a certain day) for the operation unit content (for example, table data quality analysis function) and select an alarm channel, such as DingTalk, SMS, email, etc., to send a notification through the set alarm channel when the alarm is triggered.

[0047] S102. Encapsulate the operation unit content, alarm cycle and alarm channel information into a message communication unit (NotifyBean), and add a Cache Buffer (message communication unit cache layer).

[0048] S103, adding the message communication unit (Notify Bean) to the message communication unit cache layer (CacheBuffer) for temporary storage.

[0049] S104. Implement the capacity mechanism strategy and the time mechanism strategy to persist the data in the cache buffer of the message communication unit to the database. At the same time, maintain a version number for each message communication unit (Notify Bean), which is initially set to 1. Of course, the initial version number can also be set to other numbers. If the message communication unit already exists in the database, its version number will be incremented when it is updated to ensure the continuity and consistency of version control. By adopting cache technology, the frequent I / O operations on the database are effectively reduced, and the processing efficiency is significantly improved.

[0050] Capacity mechanism strategy: When the capacity in the cache exceeds 1,000, write to the database in batches.

[0051] Time mechanism strategy: When the capacity is less than 1,000, it is detected that there is still unpersisted data to be written to the database in batches before the start of a new day.

[0052] S200, regularly executing a custom periodic scheduling component, wherein the custom periodic scheduling component is used to retrieve and process the message communication unit in the database, and forward the retrieved message communication unit to the custom alarm executor in a timely manner, the purpose is that the custom periodic scheduling component (Schedule Job) obtains the message communication unit in the database, parses the scheduling cycle (Schedule Conf), and for the alarms planned to be executed on the same day, the custom periodic scheduling component (ScheduleJob) sends these message communication units to the custom alarm executor (Alarm Executor) in a timely manner, specifically including the following steps:

[0053] S201. The scheduled task (Quart Job) is triggered at 0:00 every day. Of course, you can also set other times to trigger the scheduled task according to your needs. After the scheduled task is triggered, the custom periodic scheduling component retrieves the message communication units from the database and passes them to the custom date parser (Date Parse).

[0054] S202. The custom date parser (Date Parse) parses the schedule configuration (Schedule Conf) from the message communication unit, mainly extracts the start time (StartTime) and the frequency type (i.e., Period Type, including day, week, and month), and selects the message communication unit (Notify Bean) with a valid schedule date that matches the current date, and then calculates the specific delayed execution time (Delay Time) of the day for those that meet the conditions, and passes the message communication unit (NotifyBean) and the delayed execution time (Delay Time) to the delay queue (Delay Queue).

[0055] S203, the delay queue (Delay Queue) is responsible for storing the message communication unit (Notify Bean) and arranging the sending of the message according to the preset delayed sending time (Delay Time).

[0056] S204, check whether there is a message in the queue through the IsEmpty() method of the delay queue, and obtain the message communication unit (Notify Bean) to be sent. Then, re-pull the latest information of the message communication unit from the database and compare the version number (Version). If the version number is consistent, the message communication unit is sent to the custom alarm executor (AlarmExecutor); otherwise, the message communication unit is destroyed.

[0057] It should be noted that in this embodiment, scheduled tasks and delay queues are integrated, allowing users to easily configure and adjust the scheduling time of alarms through a simple user interface.

[0058] S300, such as Figure 3 As shown, the alarm information is pushed to the specified client through the preset alarm channel through the custom alarm executor. The purpose is to receive the alarm information sent by the custom scheduling component through the custom alarm executor, and through the predetermined alarm channel (for example: email, SMS or instant messaging platform, where the instant messaging platform includes DingTalk, WeChat, QQ, etc.), ensure that the alarm message is pushed to the specified client in time. The custom channel executor can be customized according to different application scenarios to provide flexible and diverse notification solutions.

[0059] It should be noted that the custom alarm executor (Alarm Executor) is responsible for receiving the message communication unit (Notify Bean) from the custom periodic scheduling component, and extracting the alarm channel type (Notify Type) from it to determine the message delivery path. The message is then passed to the corresponding custom channel executor (Notify Executor). In addition, the scalability of this embodiment is reflected in that by implementing the buildSession() method and the send() method, new alarm channels can be easily added without modifying the existing code, thereby ensuring the flexibility of the system and future expansion needs.

[0060] In addition, the custom channel executor (Notify Executor) calls the send() method to send the alert through the corresponding channel.

[0061] like Figure 3As shown, in order to enhance the stability and reliability of the alarm system, the execution status of the send() method can also be monitored. If the sending fails, the message will be added to the custom retry queue (Retry Queue), and the number of retries and the upper limit of the number of retries will be recorded. For example, if the upper limit of the number of retries is set to 3 times, the message will not be resent after the number of retries reaches 3, so as to ensure that the alarm message can be automatically resent when the alarm message fails to be sent.

[0062] Example 2

[0063] like Figure 5 As shown, a device for realizing alarm communication based on periodic scheduling according to Embodiment 2 of the present application includes:

[0064] The encapsulation module 100 is used to create a message communication unit for caching and transmitting notification information, and persist the message communication unit in a database;

[0065] The timer task module 200 is used to periodically execute the custom periodic scheduling component, wherein the custom periodic scheduling component is used to retrieve and process the message communication unit in the database, and forward the retrieved message communication unit to the custom alarm executor in a timely manner;

[0066] The alarm execution module 300 is used to push the alarm information to the designated client through the preset alarm channel via the custom alarm executor.

[0067] It should be noted that other specific implementations of the device for implementing alarm communication based on periodic scheduling in this embodiment can refer to the specific implementation of the method for implementing alarm communication based on periodic scheduling mentioned above, and will not be repeated here to avoid redundancy.

[0068] Example 3

[0069] A computer-readable storage medium according to Embodiment 3 of the present application, wherein the computer-readable storage medium stores a program code for execution by a device, wherein the program code includes steps for executing a method in any one of the implementations in Embodiment 1 of the present application;

[0070] Among them, the computer-readable storage medium can be a read-only memory (ROM), a static storage device, a dynamic storage device or a random access memory (RAM); the computer-readable storage medium can store program code, and when the program stored in the computer-readable storage medium is executed by the processor, the processor is used to execute the steps of the method in any one of the implementation methods in Example 1 of the present application.

[0071] Example 4

[0072] like Figure 6 As shown, an electronic device involved in Embodiment 4 of the present application includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, and when the program or instruction is executed by the processor, a method in any one of the implementations in Embodiment 1 of the present application is implemented;

[0073] Among them, the processor can adopt a general-purpose central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), a graphics processing unit (GPU) or one or more integrated circuits to execute relevant programs to implement the method in any one of the implementation methods in Example 1 of the present application.

[0074] The processor may also be an integrated circuit electronic device with signal processing capability. In the implementation process, each step of the method in any implementation of Embodiment 1 of the present application may be completed by an integrated logic circuit of hardware in the processor or by instructions in software form.

[0075] The above-mentioned processor may also be a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware decoding processor, or may be executed by a combination of hardware and software modules in a decoding processor. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory, and completes the functions required to be performed by the unit included in the data processing device of the embodiment of the present application in combination with its hardware, or executes the method in any one of the implementation modes in the embodiment 1 of the present application.

[0076] The above are only preferred specific implementations of the present application; however, the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical solution and its improved ideas of the present application within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.

Claims

1. A method for realizing alarm communication based on periodic scheduling, characterized in that: include: Creating a message communication unit for caching and transmitting notification information, and persisting the message communication unit in a database; Periodically executing a custom periodic scheduling component, wherein the custom periodic scheduling component is used to retrieve and process message communication units in a database, and forward the retrieved message communication units to a custom alarm executor in a timely manner; Use a custom alarm executor to push alarm information to the specified client via the preset alarm channel.

2. The method for realizing alarm communication based on periodic scheduling according to claim 1, characterized in that: Create a message communication unit for caching and transmitting notification information, including: Set the alarm cycle and alarm channel of the operation unit content, which is used to send notifications through the alarm channel when the alarm is triggered; Encapsulate the operation unit content, alarm cycle and alarm channel into a message communication unit, and add a message communication unit cache layer; Adds a message communication unit to the message communication unit cache layer.

3. The method for realizing alarm communication based on periodic scheduling according to claim 2, characterized in that: The message communication unit is persisted in the database, including: using a capacity mechanism strategy and a time mechanism strategy to persist the data in the message communication unit cache layer in the database, and maintaining a version number for each message communication unit. If the message communication unit already exists in the database, the version number of the message communication unit is incremented during the update.

4. The method for realizing alarm communication based on periodic scheduling according to claim 3, characterized in that: The capacity mechanism strategy is that if the capacity in the message communication unit cache layer exceeds the preset value, the data is written into the database in batches; the time mechanism strategy is that if the capacity is less than the preset value, the non-persistent data detected before the start of a new day is written into the database in batches.

5. The method for realizing alarm communication based on periodic scheduling according to any one of claims 1 to 4, characterized in that: Retrieve and process the message communication unit in the database, and forward the retrieved message communication unit to the custom alarm executor in a timely manner, including: Regularly running a custom periodic scheduling component through a timer task, retrieving a message communication unit from the database, and passing the retrieved communication unit to a custom date parser; The custom date parser parses the scheduling configuration from the message communication unit and extracts the start time and frequency type to filter out the message communication unit with a valid scheduling date that matches the current date. For the filtered message communication unit, the specific deferred execution time of the day is calculated, and the message communication unit and the deferred execution time are passed to the delay queue; The delay queue stores the message communication units and schedules the sending of the messages according to the preset delayed sending time; Check whether there is a message communication unit in the delay queue, obtain the message communication unit to be sent, re-pull the latest information of the message communication unit from the database, and compare the version numbers. If the version numbers are consistent, send the message communication unit to the custom alarm executor; otherwise, destroy the message communication unit.

6. The method for realizing alarm communication based on periodic scheduling according to claim 3 or 4, characterized in that: The custom alarm executor is used to receive a message communication unit from a custom periodic scheduling component, extract an alarm channel type from the message communication unit, and pass the message communication unit to a corresponding custom channel executor, and the custom channel executor calls a send() method to send an alarm through a corresponding alarm channel, wherein a new alarm channel can be added by implementing the buildSession() method and the send() method.

7. The method for realizing alarm communication based on periodic scheduling according to claim 6, characterized in that: Also includes: Monitor the execution status of the send() method. If the sending fails, the message communication unit will be added to the custom retry queue, and the upper limit of the number of retries will be set and the number of retries will be recorded.

8. A device for realizing alarm communication based on periodic scheduling, characterized in that: include: An encapsulation module, used to create a message communication unit for caching and transmitting notification information, and persist the message communication unit in a database; A timed task module, used for periodically executing a custom periodic scheduling component, wherein the custom periodic scheduling component is used to retrieve and process message communication units in a database, and forward the retrieved message communication units to a custom alarm executor in a timely manner; The alarm execution module is used to push the alarm information to the specified client through the preset alarm channel via the custom alarm executor.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program code for execution by a device, wherein the program code includes steps for executing the method according to any one of claims 1 to 7.

10. An electronic device, characterized in that: The electronic device comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction implements the method as claimed in any one of claims 1 to 7 when executed by the processor.

Citation Information

Patent Citations

  • Alarm handling method and alarm handling device

    CN102981941A

  • JMS channel link monitoring and alarming method and JMS channel link monitoring and alarming system in dispatching automation system

    CN106656543A

  • Business data monitoring and warning device and method thereof

    CN111190798A

  • Alarm processing method and system under high concurrency and large flow and related device

    CN111416733A

  • Alarm monitoring method in cloud environment

    CN112532456A