WO2022062347A1 - Data transmission method and apparatus, and electronic device and storage medium - Google Patents

Data transmission method and apparatus, and electronic device and storage medium Download PDF

Info

Publication number
WO2022062347A1
WO2022062347A1 PCT/CN2021/082757 CN2021082757W WO2022062347A1 WO 2022062347 A1 WO2022062347 A1 WO 2022062347A1 CN 2021082757 W CN2021082757 W CN 2021082757W WO 2022062347 A1 WO2022062347 A1 WO 2022062347A1
Authority
WO
WIPO (PCT)
Prior art keywords
resource
receiving port
data
resource receiving
state
Prior art date
Application number
PCT/CN2021/082757
Other languages
French (fr)
Chinese (zh)
Inventor
曹如海
李强
张炜
宣月波
Original Assignee
苏州科达科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 苏州科达科技股份有限公司 filed Critical 苏州科达科技股份有限公司
Publication of WO2022062347A1 publication Critical patent/WO2022062347A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/55Push-based network services

Definitions

  • the present invention relates to the technical field of data transmission, in particular to a data transmission method, device, electronic device and storage medium.
  • An open platform means that a software system exposes its application programming interface or functions so that external programs can increase the functions of the software system or use the resources of the software system without changing the source code of the software system.
  • an external program wants to obtain the real-time changing data inside the software system
  • the existing data transmission method is that the software system will provide the corresponding interface open data through the open platform, and the external system will obtain the data regularly through the open data interface.
  • embodiments of the present invention provide a data transmission method, apparatus, electronic device, and storage medium, so as to solve the problem of low transmission efficiency of real-time data.
  • an embodiment of the present invention provides a data transmission method, including:
  • the resource type corresponds to the source of the resource
  • the corresponding relationship between resource types and resource sources is used to determine the target resource source corresponding to the target resource type, and real-time data can be extracted from the target resource source and pushed to the resource receiving port, thereby achieving The purpose of real-time data push, and use the resource type to share the same real-time push mechanism.
  • the reverse push is used to avoid excessive external requests and increase the pressure on the server, which improves the real-time performance of data transmission.
  • the pushing the real-time data to at least one of the resource receiving ports includes:
  • the real-time data is pushed to the at least one resource receiving port according to the state information of the at least one resource receiving port.
  • the data transmission method provided by the embodiment of the present invention can ensure the reliability of real-time data push by pushing real-time data based on the state information of at least one resource receiving port.
  • the pushing the real-time data to at least one of the resource receiving ports according to the state information of at least one of the resource receiving ports includes:
  • the state information of the collected resource receiving port is the resource receiving port in the normal state
  • the resource receiving port based on the retry state performs data push corresponding to the retry mode
  • the pushing the real-time data to at least one of the resource receiving ports according to the state information of the at least one resource receiving port includes:
  • Collecting the status information of the resource receiving port is the resource receiving port in the retry state
  • the resource receiving port in the retry state performs data push corresponding to the retry mode.
  • the data transmission method provided by the embodiment of the present invention can improve the efficiency of data transmission by pushing data to the resource receiving port in a normal state in parallel; and when the preset thread push is abnormal, the state information of the resource receiving port is set to retry , and push the data in the retry mode to realize the normal to retry state flow to ensure the normal push of the data.
  • the resource receiving port based on the retry state performs data push corresponding to the retry mode, including:
  • the resource receiving port based on the abnormal state performs data push corresponding to the abnormal mode.
  • the state information of the resource receiving port is set to be in recovery, so as to realize the state flow from retry to recovery, which provides guarantee for data push
  • the flow of the resource receiving port from the retry state to the abnormal state is realized, which provides a guarantee for the normal push of the data.
  • the pushing the real-time data to at least one of the resource receiving ports according to the state information of at least one of the resource receiving ports includes:
  • Data push corresponding to the mode in recovery is performed based on the resource receiving port in recovery.
  • the resource registration request further carries configuration information, and the corresponding resource receiving port is based on the restoration.
  • Data push in recovery mode including:
  • the data push corresponding to the normal mode is performed based on the resource receiving port in the normal state.
  • the interrupted and resumed transmission can be performed from the interrupted position to ensure that the data is not lost; and when the historical data push does not fail, the state of the resource receiving port can be changed from recovery to normal.
  • the flow of data provides a guarantee for the recovery of interrupted push data.
  • the performing data push corresponding to the recovering mode based on the resource receiving port under recovery includes:
  • the state information of the resource receiving port in the restoration is set to be abnormal, and the resource receiving port based on the abnormal state performs data push corresponding to the abnormal mode.
  • the state of the resource receiving port is directly set to be abnormal, and no retry is performed, so as to avoid multiple retries of data transmission. , which improves the real-time performance of data transmission.
  • the pushing the real-time data to at least one of the resource receiving ports according to the state information of at least one of the resource receiving ports includes:
  • the state information of the collected resource receiving port is the resource receiving port in an abnormal state
  • the resource receiving port based on the abnormal state performs data push corresponding to the abnormal mode.
  • the abnormal state-based resource receiving port performs data push corresponding to the abnormal mode, including:
  • the state of the resource receiving port receiving the abnormal state is updated to normal information
  • Data push corresponding to the mode in recovery is performed based on the resource receiving port in recovery.
  • the local when the state of the resource receiving port in the abnormal state is updated to normal externally, the local does not directly set the state of the resource receiving port to normal, but first sets it to recovering , and enter the state flow from abnormal to recovery, which provides a guarantee for the normal transmission of data.
  • the resource registration request carries configuration information
  • the configuration information includes data filtering conditions. information, and push the real-time data to at least one of the resource receiving ports, including:
  • the filtered real-time data is pushed to the at least one resource receiving port.
  • the real-time data is filtered before the real-time data is transmitted, so that the transmitted real-time data can meet external requirements.
  • an embodiment of the present invention further provides a data transmission device, including:
  • a receiving module configured to receive a resource registration request for at least one target resource type, where the resource registration request carries configuration information of a corresponding resource receiving port;
  • a determining module configured to determine the target resource source corresponding to the target resource type based on the resource registration request
  • an extraction module for extracting real-time data from the target resource source
  • a push module configured to push the real-time data to at least one of the resource receiving ports.
  • the data transmission device utilizes the corresponding relationship between resource types and resource sources to determine the target resource source corresponding to the target resource type, so that real-time data can be extracted from the target resource source and pushed to the resource receiving port, thereby achieving The purpose of real-time data push, and use the resource type to share the same real-time push mechanism to avoid providing multiple data interfaces to the outside, and reverse the push to avoid excessive external requests and increase the pressure on the server, which improves data transmission. real-time.
  • an embodiment of the present invention provides an electronic device, including: a memory and a processor, the memory and the processor are connected in communication with each other, the memory stores computer instructions, and the processor By executing the computer instructions, the data transmission method described in the first aspect or any one of the implementation manners of the first aspect is executed.
  • an embodiment of the present invention provides a computer-readable storage medium, where the computer-readable storage medium stores computer instructions, and the computer instructions are used to cause the computer to execute the first aspect or any one of the first aspect.
  • FIG. 1 shows an optional application scenario of the data transmission method according to the embodiment of the present invention
  • FIG. 2 is a flowchart of a data transmission method according to an embodiment of the present invention.
  • FIG. 3 is a flowchart of a data transmission method according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of an internal data flow mechanism according to an embodiment of the present invention.
  • FIG. 5 is a flowchart of a data transmission method according to an embodiment of the present invention.
  • FIG. 6 is an architectural diagram of a data transmission method according to an embodiment of the present invention.
  • FIG. 7 is a structural block diagram of a data transmission apparatus according to an embodiment of the present invention.
  • FIG. 8 is a schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present invention.
  • FIG. 1 is an optional application scenario of the data transmission method provided by the embodiment of the present invention.
  • the data transmission system includes an electronic device (that is, it may also be referred to as a local device hereinafter) and at least one external system (which may also be referred to as an external program).
  • the electronic device establishes the corresponding relationship between the resource type and the resource source, and then provides the resource type to the outside world.
  • the external device selects the target resource type it needs from the resource types provided by the electronic device, and sends the resource registration to the electronic device. ask.
  • the electronic device After receiving the resource registration request sent by the external system, the electronic device uses the corresponding relationship between the resource type and the resource source to determine the target resource source corresponding to the target resource type, extracts real-time data from the target resource source, and separates it according to the requirements of each external system. The status information of the resource receiving port is pushed.
  • the external system does not need to request data regularly. It only needs to provide a resource receiving port, and then it can receive the corresponding data when there is data, so that it only needs to focus on business processing, and does not need to repeatedly process the corresponding docking work. Easy function extension.
  • the external system since different types of open data sources have been abstracted into resource types in the electronic device, the external system only knows the resource type but does not know the specific internal data source, so it is easy to switch the internal data source without having to use the electronic device. Provide an open interface to the outside world, the external system cannot perceive the change of the data source, and the internal migration and expansion are convenient. The content of the data transmission method will be described in detail below.
  • an embodiment of a data transmission method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings may be executed in a computer system such as a set of computer-executable instructions, and, although in the A logical order is shown in the flowcharts, but in some cases steps shown or described may be performed in an order different from that herein.
  • FIG. 2 is a flowchart of the data transmission method according to an embodiment of the present invention, as shown in FIG. 2 , the process includes the following steps:
  • the resource type corresponds to the resource source.
  • the resource type is a serial number description of a message to be opened locally, wherein a message subscription push system is maintained locally.
  • the format of the specific number of the resource type can be set according to the actual situation, and it is only necessary to ensure that the outside world can know the corresponding resource through the resource type. For example, it can consist of the resource type name, the resource type description, and the external format of the resource message.
  • the electronic device provides it to the external system to know, and the external system can know the data usage of the external representative of the resource type according to the resource type, so that in the subsequent steps, it can send a resource registration request to the electronic device to request that it wants to obtain The real-time data corresponding to the resource type of .
  • the resource source may be a third-party data system, database, data engine or data warehouse, etc.
  • the specific form of the resource source is not limited here, as long as it can provide data.
  • S12 Receive a resource registration request for at least one target resource type.
  • the resource registration request corresponds to a resource receiving port.
  • the electronic device provides the local resource type to the external system to know, then the external system can request to obtain real-time data corresponding to the target resource type by sending a resource registration request to the electronic device based on its own needs.
  • Each resource registration request corresponds to the information of the resource receiving port, and the resource receiving port is used for receiving real-time data corresponding to the target resource type.
  • the resource registration request received by the electronic device may be a resource registration request for the same target resource type sent by at least one external system, then the electronic device can perform the same processing on the same target resource type, Then send them to different external systems respectively.
  • the external system 1 corresponds to the resource receiving port a
  • the external system 2 corresponds to the resource receiving port b
  • the external system 3 corresponds to the resource receiving port c.
  • the electronic device receives a resource registration request for the same target resource type sent by the external system 1, the external system 2, and the external system 3, the electronic device can determine the resource receiving port and target corresponding to each external system by using the resource registration request.
  • the real-time data can be pushed to the corresponding resource receiving ports, so that it can be received by each external system.
  • the resource registration request received by the electronic device may also be a resource registration request for at least one target resource type sent by at least one external system, and the electronic device may perform the same processing for the resource registration request of the same target resource type. Then, send them to the corresponding resource receiving ports respectively.
  • the external system 1 requests the target resource type c2, the external system 2 requests the target resource type c1, and the external system 3 requests the target resource type c2. Since the external system 1 and the external system 3 request the same target resource type, the electronic device can perform the same operation on the external system 1 and the external system 3. After the real-time data 1 is subsequently extracted, it is pushed to the corresponding The resource receiving port a and the resource receiving port c of the electronic device can extract the real-time data 2 for the external system 2, and push the real-time data 2 to the corresponding resource receiving port b.
  • the electronic device receives at least one resource registration request for the same target resource type as an example for detailed description.
  • the electronic device can determine the target resource source corresponding to the target resource type by querying the correspondence between the target resource type and the resource source.
  • one runner and at least one main listener are maintained in the electronic device.
  • the runner uses the target resource type corresponding to the resource registration request to determine the main listener to be activated.
  • the main listener corresponding to the target resource type is started to extract real-time data from the target resource source corresponding to the target resource type.
  • the timing of starting the main listener is that when at least one external system has registered its corresponding resource type, the listener will be triggered to start, so as to avoid wasting resources by running the listener vacantly.
  • a general master listener can be created in the electronic device, and the externally provided interfaces of the master listener include a monitoring source interface and a real-time data push interface, wherein the monitoring source interface is used to extract real-time data from resource sources. Data, the real-time data push interface is used to push the extracted real-time data to the corresponding resource receiving port.
  • the resource sources are of multiple types, adapters corresponding to the resource sources of each type can also be set in the general master listener for performing corresponding data conversion and the like.
  • master listeners corresponding to resource sources may also be created in the electronic device, and each resource source corresponds to a master listener.
  • resource sources include databases, data warehouses, and digital engines
  • corresponding master listeners can be created for databases, data warehouses, and digital engines respectively.
  • the specific setting can be made according to the actual situation. It only needs to ensure that it can extract real-time data from the determined resource source, and will extract the real-time data. Just push it to the corresponding resource receiving port.
  • a message subscription and push system is maintained in the electronic device.
  • the new resource source is added to the message subscription and push system according to the different resource sources.
  • the update of the message subscription push system can be realized, so that the resource type in the electronic device can be known by the external system in time, and the system will select the corresponding
  • the processing method acquires data, processes it according to a series of filtering processing functions, and sends it to the resource receiving port provided by the external system.
  • the electronic device can extract real-time data from the target resource source using the master listener determined by the target resource source.
  • the external system knows the data usage of the external representation of the resource type according to the description of the resource type, registers the resource type corresponding to the data it wants to acquire through the interface provided by the internal program in the external open platform, and provides the relevant resource receiving port. After extracting the real-time data, the electronic device pushes the real-time data to it by using the status information of each resource receiving port.
  • the resource registration request may also carry data filtering rules, as well as configuration information such as the frequency of data push and whether the data needs to be resumed at a breakpoint.
  • configuration information will be stored by the internal message subscription push system, and then after the internal resource type is registered by the external system, after obtaining the data according to the processing method of the resource type, the configuration information of the external system is used to filter the rules and decide whether to send the external system to the external system.
  • the system pushes data.
  • the state information of each resource receiving port is used to push real-time data to it.
  • the corresponding relationship between resource types and resource sources is used to determine the target resource source corresponding to the target resource type, and real-time data can be extracted from the target resource source and pushed to the resource receiving port, so as to achieve data
  • the purpose of real-time push is to use resource types to share the same real-time push mechanism. For the outside world, it only knows the resource type but not the specific resource source, so it is easy to switch internal data sources and avoid providing multiple data interfaces to the outside world. Reverse push is used to avoid excessive external requests and increase the pressure on the server, which improves the real-time performance of data transmission.
  • FIG. 3 is a flowchart of the data transmission method according to an embodiment of the present invention, as shown in FIG. 3 , the process includes the following steps:
  • the resource type corresponds to the resource source.
  • the resource registration request corresponds to a resource receiving port.
  • the electronic device further determines state information of at least one resource receiving port based on the resource registration request, and pushes real-time data to at least one resource receiving port according to the state information of at least one resource receiving port.
  • the state information includes one of normal, retry, abnormal and recovery.
  • the electronic device pushes real-time data to each resource receiving port according to the status information. Specifically, it can be divided into the following processing methods:
  • the state information of the resource receiving port collected by the electronic device is the resource receiving port in the normal state, and data push corresponding to the normal mode is performed based on the normal resource receiving port.
  • data push in the normal mode reference may be made to the related description of S252 and its subsequent steps below.
  • the state information of the resource receiving port collected by the electronic device is the resource receiving port in the retry state, and data push corresponding to the retry mode is performed based on the retrying resource receiving port.
  • the data push in the retry mode may refer to the related description of S256 below.
  • the state information of the resource receiving port collected by the electronic device is the resource receiving port in the abnormal state, and the data push corresponding to the abnormal mode is performed based on the abnormal resource receiving port.
  • the data push in the abnormal mode reference may be made to the relevant description of step (6) in S255 below.
  • the state information of the resource receiving port collected by the electronic device is the resource receiving port in the recovering state, and data push corresponding to the recovering mode is performed based on the resource receiving port in the recovering state.
  • the data push in the recovery mode may refer to the relevant description of step (4) in S256 below.
  • the electronic device pushes data in different modes based on the status of each resource receiving port.
  • the status information of the same resource receiving port may change. For example, it can change from a normal state to a retry state, from a retry state to an abnormal state, from an abnormal state to a recovering state, and so on.
  • the state information of the resource receiving port as the normal state as an example, the state change after the resource is received and the processing mode corresponding to each state will be described in detail.
  • the above S25 includes the following steps:
  • the electronic device can use the resource registration request to determine the state information of at least one resource receiving interface.
  • the state information of the collected resource receiving ports is the resource receiving ports in the normal state.
  • the electronic device utilizes the state information of each resource receiving port, and collects the resource receiving port whose state information is the normal state, so as to push the data in the normal mode.
  • the electronic device may create a corresponding number of threads according to the number of resource receiving ports in the normal state, that is, the created threads correspond to the resource receiving ports in the normal state one-to-one. After the thread is created, the electronic device uses the corresponding thread to push the real-time data to the resource receiving port in the normal state, so as to realize the parallel push of the real-time data.
  • the electronic device judges in real time whether the push of each thread is abnormal. Taking the preset thread as an example, the electronic device judges in real time whether the push of the preset thread is abnormal, and the abnormality may be whether the real-time data is pushed successfully.
  • S254 is executed to determine whether a push exception occurs.
  • the electronic device determines that the real-time data push of the preset thread is abnormal, the data push of the preset thread is stopped, and the status information of the resource receiving port corresponding to the preset thread is set to retry.
  • the resource receiving port a of the external system 1 and the resource receiving port b of the external system 2 are resource receiving ports in the normal state, then the electronic device creates two threads, such as thread 1 and thread 2, and uses thread 1 and thread 2 to send resources to the resource. Receiving ports a and b send real-time data. If during the real-time data sending process, the electronic device determines that the data push of thread 1 is abnormal and the data push of thread 2 is normal, then the electronic device will set the status information of the resource receiving port a corresponding to thread 1 to retry, and Stop the data push of thread 1. The thread 2 still pushes real-time data to the resource receiving port b normally.
  • the electronic device After the electronic device sets the state information of the resource receiving port corresponding to the preset thread to retry, it can push the data corresponding to the retry mode.
  • the above S256 may be the following steps, and it may also be understood that the data push in the retry mode may include the following steps:
  • the electronic device opens another thread to push the currently failed data to it again.
  • the preset condition may be a preset number of times, or within a preset time interval, etc., and may be specifically set according to the actual situation, which is not limited herein.
  • step (3) When the currently failed data is successfully pushed to the resource receiving port in the retry state within the condition, step (3) is performed; otherwise, step (5) is performed.
  • the electronic device can use a separate thread to push the data that has failed to be pushed up to three times to the resource receiving port in the retry state. If all three pushes fail, step (5) is performed; otherwise, step (3) is performed.
  • the state information of the resource receiving port in the retry state is set as recovering.
  • the state information of the resource receiving port in the retry state is set as recovering.
  • the state information of the resource receiving port is set to recovering to realize the state flow from retry to recovery, which provides guarantee for data push.
  • step (4) may include the following steps, and it can also be understood that the data push mode of the recovery mode includes the following steps:
  • the configuration information may include a flag for pushing interrupted data at the resource receiving port.
  • the flag for pushing interrupted data is 1, it means that the resource receiving port needs to push the interrupted data, and then it needs to push the interrupted data from the interrupted position to the current position.
  • the historical data is pushed to the resource receiving port in recovery; when the flag bit of the interrupted data is pushed to 0, it means that the resource receiving port does not need to push the interrupted data.
  • Electronic devices can create sub-listeners when breakpoint teleportation is required.
  • the sub-listener is created according to the configuration information of the resource registration request of the external system and needs to be created when the state is recovering to obtain historical data when the breakpoint is returned.
  • the sub-listener is a method for obtaining historical data between the interruption point of the resource source and the latest real-time point.
  • step 4.5 When there is no push failure, go to step 4.5); otherwise, go to step 4.7).
  • the state information of the resource receiving port in recovery is set to normal.
  • the interrupted and resumed transmission can be performed from the interrupted position to ensure that the data is not lost; and when the historical data push does not fail, the state of the resource receiving port can be transferred from the recovery to the normal flow, which provides the recovery of the interrupted push data. guaranteed.
  • the state information of the resource receiving port being restored is set as abnormal, and then data push corresponding to the abnormal mode is performed based on the resource receiving port of the abnormal state.
  • the state of the resource receiving port is set to be abnormal directly, and no retry is performed, so as to avoid multiple retries of data transmission and improve the real-time performance of data transmission.
  • the state of the resource receiving port in the retry state is set to be abnormal.
  • the state of the resource receiving port in the retry state is set as abnormal.
  • the resource receiving port in the retry state does not successfully push the data that fails to push the current push within the preset conditions, the resource receiving port is realized from the retry to the abnormal state flow, which provides a guarantee for the normal push of the data.
  • step (6) may include steps, and it may also be understood that the data push of the abnormal mode includes the following steps:
  • the state of the resource receiving port receiving the abnormal state is updated to normal information.
  • the electronic device When the electronic device determines that the resource receiving port is abnormal, it can send alarm information to the external system, so that the external system can perform corresponding processing on the resource receiving port. After the external system finishes processing the resource receiving port, it may send status update information to the electronic device to request to update the state of the resource receiving port in the abnormal state to a normal state.
  • the electronic device After receiving the information sent by the external system to update the state of the resource receiving port in the abnormal state to normal, the electronic device first determines whether the state of the resource receiving port in the abnormal state stored locally is abnormal. When the state of the resource receiving port of the set abnormal state is abnormal, step 6.3) is performed; otherwise, step 4.6) is performed.
  • the electronic device determines that the state of the resource receiving port of the abnormal state stored locally is still abnormal, the electronic device first sets its state information as recovering.
  • step (4) For details, please refer to the description of the above step (4), which will not be repeated here.
  • the local when the state of the resource receiving port in the abnormal state is updated to normal externally, the local does not directly set the state of the resource receiving port to normal, but first sets it to recovering, The state flow from abnormal to recovery provides a guarantee for the normal transmission of data.
  • the retry of the resource receiving ports of multiple external systems can be performed in parallel by multiple sub-processes.
  • the resource receiving port in the database is in an abnormal state, it is not updated to a normal state first, but is updated to a restoring state first.
  • FIG. 5 is a flowchart of the data transmission method according to an embodiment of the present invention, as shown in FIG. 5 . , the process includes the following steps:
  • the resource type corresponds to the resource source.
  • S32 Receive at least one resource registration request for the target resource type.
  • the resource registration request corresponds to the resource receiving port, wherein the resource registration request carries configuration information, and the configuration information includes data filtering conditions of the resource receiving port.
  • the above S35 includes the following steps:
  • the electronic device filters the extracted real-time data based on the data filtering conditions in the configuration information of each resource registration request.
  • S352 Push the filtered real-time data to at least one resource receiving port.
  • the electronic device can push real-time data to it according to the status information of each resource receiving port. For details, please refer to S25 of the embodiment shown in FIG. 3 , which will not be repeated here.
  • the filtered real-time data is empty, it is not necessary to push the data to the corresponding resource receiving port; if the filtered real-time data is not empty, it is necessary to push the filtered data to the corresponding resource receiving port according to the status information of each resource receiving port.
  • Real-time data if the filtered real-time data is empty, it is not necessary to push the data to the corresponding resource receiving port; if the filtered real-time data is not empty, it is necessary to push the filtered data to the corresponding resource receiving port according to the status information of each resource receiving port.
  • the real-time data is filtered before the real-time data is transmitted, so that the transmitted real-time data can meet external requirements.
  • the data transmission method includes the following processing flow:
  • Resource mapping Map resource sources to resource types.
  • the electronic device needs to open data to the outside world, and it will call the interface to bind the resource source with the resource type.
  • the resource mapping component will be responsible for creating the corresponding relationship between the two.
  • Resource type announcement Tell the external system which resource types are currently available for use during registration.
  • the external system calls the registration interface opened by the electronic device, and provides the registered resource type, resource receiving port information, and the status of the resource receiving port (the status of the receiving address will be updated immediately every time the external system is restarted), push type Name (it can be pushed in the form of HTTP, and can be extended), whether it is necessary to re-push interrupted data, the number of interrupted messages per re-push, and data filter conditions.
  • the state update interface opened by the open platform needs to be called to update the state of the resource receiving port.
  • the resource registration request sent by the external system will be stored in the database and cache for use by the internal state flow mechanism.
  • Resource listener monitor the data source of the mapping according to the resource type registered by the external system, obtain the required data from the resource source in real time, and send it to the filter for processing.
  • Filter Filter unnecessary real-time data according to the needs of external systems.
  • Data distribution processing encapsulate the data to be sent into a fixed structure and send it to the internal state flow mechanism for processing.
  • a) Encapsulate the real-time data into a fixed-format message, which can be JSON, provided that the format of the communication data is negotiated with the external system. Messages are hashed or encrypted as needed to prevent tampering or pushed using the https protocol, which also needs to be negotiated with external systems.
  • the data after data distribution and processing will carry the specified resource receiving port information, and filter the status of the resource receiving port.
  • step (8) If the state of the resource receiving port is normal, and collecting the interface information that the state of the resource receiving port is normal (normal), the process proceeds to step (8).
  • step (11) If the state of the resource receiving port is restoring, go to step (11).
  • Data push push data to the resource receiving port designated by the external system.
  • step (11) If successful, set the state of the resource receiving port as restoring, and then go to step (11).
  • Abnormal recovery recover the state of the abnormal resource receiving port.
  • step (12) Whether the interrupted data needs to be pushed according to the configuration, if necessary, go to step (12).
  • Breakpoint resume Interrupt and resume the interrupted data on demand.
  • step (9) If an exception occurs in the process of pushing the interrupted data, go to step (9);
  • the electronic device resource monitor monitors data in real time, provides the function of filtering data, distributes and pushes data to multiple external systems in parallel, thereby reducing the request pressure of external systems on internal servers, and data can be pushed in real time unless the interface is abnormal. Interrupted push, there are also options for data interrupted and resumed transmission, to ensure that data is not lost.
  • the electronic device will record the abnormal information when the real-time push data is abnormal, which is convenient for the administrator to quickly check the abnormal problem and guide the external system and electronic device to repair related problems.
  • the internal state transfer mechanism provides a guarantee for abnormal retry and recovery of interrupted push data.
  • a data transmission apparatus is also provided, and the apparatus is used to implement the above-mentioned embodiments and preferred implementations, and what has been described will not be repeated.
  • the term "module” may be a combination of software and/or hardware that implements a predetermined function.
  • the apparatus described in the following embodiments is preferably implemented in software, implementations in hardware, or a combination of software and hardware, are also possible and contemplated.
  • This embodiment provides a data transmission device, as shown in FIG. 7 , including:
  • a providing module 41 configured to provide a locally open resource type, the resource type corresponding to the source of the resource
  • a receiving module 42 configured to receive at least one resource registration request for the target resource type, the resource registration request corresponding to the resource receiving port;
  • Determining module 43 for determining the target resource source corresponding to the target resource type based on the resource registration request
  • Extraction module 44 for extracting real-time data from the target resource source
  • the push module 45 is configured to push the real-time data to at least one of the resource receiving ports.
  • the data transmission device uses the corresponding relationship between resource types and resource sources to determine the target resource source corresponding to the target resource type, so that real-time data can be extracted from the target resource source and pushed to the resource receiving port, so as to achieve data
  • the purpose of real-time push is to use resource types to share the same real-time push mechanism to avoid providing multiple data interfaces to the outside world.
  • Reverse push is used to avoid excessive external requests and increase the pressure on the server, which improves the efficiency of data transmission. real-time.
  • the data transmission apparatus in this embodiment is presented in the form of functional units, where units refer to ASIC circuits, processors and memories that execute one or more software or fixed programs, and/or other devices that can provide the above functions .
  • An embodiment of the present invention further provides an electronic device having the data transmission device shown in FIG. 7 .
  • FIG. 8 is a schematic structural diagram of an electronic device provided by an optional embodiment of the present invention.
  • the electronic device may include: at least one processor 51, such as a CPU (Central Processing Unit, central processing unit). processor), at least one communication interface 53, memory 54, at least one communication bus 52.
  • the communication bus 52 is used to realize the connection and communication between these components.
  • the communication interface 53 may include a display screen (Display) and a keyboard (Keyboard), and the optional communication interface 53 may also include a standard wired interface and a wireless interface.
  • the memory 54 may be a high-speed RAM memory (Random Access Memory, volatile random access memory), or may be a non-volatile memory (non-volatile memory), such as at least one disk memory.
  • the memory 54 can optionally also be at least one storage device located away from the aforementioned processor 51 .
  • the processor 51 may be combined with the device described in FIG. 7 , the memory 54 stores application programs, and the processor 51 calls the program codes stored in the memory 54 for executing any of the above method steps.
  • the communication bus 52 may be a peripheral component interconnect (PCI for short) bus or an extended industry standard architecture (EISA for short) bus or the like.
  • PCI peripheral component interconnect
  • EISA extended industry standard architecture
  • the communication bus 52 can be divided into an address bus, a data bus, a control bus, and the like. For ease of presentation, only one thick line is used in FIG. 8, but it does not mean that there is only one bus or one type of bus.
  • the memory 54 may include volatile memory (English: volatile memory), such as random-access memory (English: random-access memory, abbreviation: RAM); the memory may also include non-volatile memory (English: non-volatile memory) memory), such as flash memory (English: flash memory), hard disk (English: hard disk drive, abbreviation: HDD) or solid-state hard disk (English: solid-state drive, abbreviation: SSD); the memory 54 may also include the above types of combination of memory.
  • volatile memory English: volatile memory
  • RAM random-access memory
  • flash memory English: flash memory
  • hard disk English: hard disk drive, abbreviation: HDD
  • solid-state hard disk English: solid-state drive, abbreviation: SSD
  • the memory 54 may also include the above types of combination of memory.
  • the processor 51 may be a central processing unit (English: central processing unit, abbreviation: CPU), a network processor (English: network processor, abbreviation: NP), or a combination of CPU and NP.
  • CPU central processing unit
  • NP network processor
  • the processor 51 may further include a hardware chip.
  • the above-mentioned hardware chip may be an application-specific integrated circuit (English: application-specific integrated circuit, abbreviation: ASIC), a programmable logic device (English: programmable logic device, abbreviation: PLD) or a combination thereof.
  • the above-mentioned PLD can be a complex programmable logic device (English: complex programmable logic device, abbreviation: CPLD), field programmable logic gate array (English: field-programmable gate array, abbreviation: FPGA), general array logic (English: generic array logic, abbreviation: GAL) or any combination thereof.
  • memory 54 is also used to store program instructions.
  • the processor 51 may invoke program instructions to implement the data transmission methods shown in the embodiments of FIGS. 2 , 3 and 5 of the present application.
  • An embodiment of the present invention further provides a non-transitory computer storage medium, where the computer storage medium stores computer-executable instructions, and the computer-executable instructions can execute the data transmission method in any of the foregoing method embodiments.
  • the storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a flash memory (Flash Memory), a hard disk (Hard) Disk Drive, abbreviation: HDD) or solid-state drive (Solid-State Drive, SSD), etc.; the storage medium may also include a combination of the above-mentioned types of memories.

Abstract

The present invention relates to the technical field of data transmission, and in particular to a data transmission method and apparatus, and an electronic device and a storage medium. The method comprises providing a resource type that is locally opened, wherein the resource type corresponds to a resource source; receiving a resource registration request for at least one target resource type, wherein the resource registration request corresponds to a resource receiving port; determining, on the basis of the resource registration request, a target resource source corresponding to the target resource type; extracting real-time data from the target resource source; and pushing the real-time data to at least one resource receiving port. The same real-time push mechanism is shared by using a resource type, and for the outside, only the resource type is known, whereas the specific resource source is not known, such that the provision of a plurality of data interfaces for the outside is avoided, and the increase in the pressure of a server caused by excessive external requests is avoided by means of reverse pushing, thereby improving the real-time performance of data transmission.

Description

数据传输方法、装置、电子设备及存储介质Data transmission method, device, electronic device and storage medium 技术领域technical field
本发明涉及数据传输技术领域,具体涉及数据传输方法、装置、电子设备及存储介质。The present invention relates to the technical field of data transmission, in particular to a data transmission method, device, electronic device and storage medium.
背景技术Background technique
开放平台是指软件系统通过公开其应用程序编程接口或函数来使外部的程序可以增加该软件系统的功能或使用该软件系统的资源,而不需要更改该软件系统的源代码。在外部的程序想要获取软件系统内部的实时性变化的数据时,现有的数据传输方法是软件系统会通过开放平台提供相应的接口开放数据,外部系统通过开放数据接口定时获取数据。An open platform means that a software system exposes its application programming interface or functions so that external programs can increase the functions of the software system or use the resources of the software system without changing the source code of the software system. When an external program wants to obtain the real-time changing data inside the software system, the existing data transmission method is that the software system will provide the corresponding interface open data through the open platform, and the external system will obtain the data regularly through the open data interface.
然而,上述数据传输方法中,若外部系统数量增大,且实时性要求高,外部系统会不断的定时请求接口,导致内部服务器的压力增大,从而实时性会降低,影响实时数据传输的效率。However, in the above data transmission method, if the number of external systems increases and the real-time requirements are high, the external systems will continuously request the interface at regular intervals, which will increase the pressure on the internal server, thereby reducing the real-time performance and affecting the efficiency of real-time data transmission. .
发明内容SUMMARY OF THE INVENTION
有鉴于此,本发明实施例提供了一种数据传输方法、装置、电子设备及存储介质,以解决实时数据的传输效率较低问题。In view of this, embodiments of the present invention provide a data transmission method, apparatus, electronic device, and storage medium, so as to solve the problem of low transmission efficiency of real-time data.
根据第一方面,本发明实施例提供了一种数据传输方法,包括:According to a first aspect, an embodiment of the present invention provides a data transmission method, including:
提供本地开放的资源类型,所述资源类型与资源来源对应;Provide a locally open resource type, the resource type corresponds to the source of the resource;
接收对至少一个目标资源类型的资源注册请求,所述资源注册请求与资源接收口对应;receiving a resource registration request for at least one target resource type, where the resource registration request corresponds to a resource receiving port;
基于所述资源注册请求,确定所述目标资源类型对应的目标资源来源;determining a target resource source corresponding to the target resource type based on the resource registration request;
从所述目标资源来源中提取出实时数据;extracting real-time data from the target resource source;
向至少一个所述资源接收口推送所述实时数据。Pushing the real-time data to at least one of the resource receiving ports.
本发明实施例提供的数据传输方法,利用资源类型与资源来源的 对应关系,确定目标资源类型对应的目标资源来源,即可从目标资源来源中提取出实时数据并推送给资源接收口,从而达到数据实时推送的目的,且利用资源类型来共用同一条实时推送机制,对于外部而言,其只知资源类型而不知具体的资源来源,从而易于切换内部数据来源,避免给外部提供多个数据接口,以逆向反转推送来避免外部请求过多导致服务器的压力增大,提高了数据传输的实时性。In the data transmission method provided by the embodiment of the present invention, the corresponding relationship between resource types and resource sources is used to determine the target resource source corresponding to the target resource type, and real-time data can be extracted from the target resource source and pushed to the resource receiving port, thereby achieving The purpose of real-time data push, and use the resource type to share the same real-time push mechanism. For the outside, it only knows the resource type but not the specific resource source, so it is easy to switch the internal data source and avoid providing multiple data interfaces to the outside. , the reverse push is used to avoid excessive external requests and increase the pressure on the server, which improves the real-time performance of data transmission.
结合第一方面,在第一方面第一实施方式中,所述向至少一个所述资源接收口推送所述实时数据,包括:With reference to the first aspect, in a first implementation manner of the first aspect, the pushing the real-time data to at least one of the resource receiving ports includes:
基于所述资源注册请求,确定所述至少一个资源接收口的状态信息,所述状态信息包括正常、重试、异常以及恢复中的一种;determining, based on the resource registration request, status information of the at least one resource receiving port, where the status information includes one of normal, retry, abnormal, and recovery;
根据所述至少一个资源接收口的状态信息,向至少一个所述资源接收口推送所述实时数据。The real-time data is pushed to the at least one resource receiving port according to the state information of the at least one resource receiving port.
本发明实施例提供的数据传输方法,通过基于至少一个资源接收口的状态信息进行实时数据的推送,可以保证实时数据推送的可靠性。The data transmission method provided by the embodiment of the present invention can ensure the reliability of real-time data push by pushing real-time data based on the state information of at least one resource receiving port.
结合第一方面第一实施方式,在第一方面第二实施方式中,所述根据至少一个所述资源接收口的状态信息,向至少一个所述资源接收口推送所述实时数据,包括:With reference to the first embodiment of the first aspect, in the second embodiment of the first aspect, the pushing the real-time data to at least one of the resource receiving ports according to the state information of at least one of the resource receiving ports includes:
收集资源接收口的状态信息为正常状态的资源接收口;The state information of the collected resource receiving port is the resource receiving port in the normal state;
利用至少一个线程将所述实时数据并行推送给正常状态的资源接收口;Utilize at least one thread to push the real-time data to the normal resource receiving port in parallel;
判断预设线程的推送是否异常;Determine whether the push of the preset thread is abnormal;
当所述预设线程的推送异常时,停止所述预设线程的实时数据推送并将所述预设线程对应的资源接收口的状态信息设置为重试;When the push of the preset thread is abnormal, stop the real-time data push of the preset thread and set the status information of the resource receiving port corresponding to the preset thread to retry;
基于重试状态的资源接收口进行对应于重试模式的数据推送;The resource receiving port based on the retry state performs data push corresponding to the retry mode;
或,or,
所述根据至少一个所述资源接收口的状态信息,向至少一个所述资源接收口推送所述实时数据,包括:The pushing the real-time data to at least one of the resource receiving ports according to the state information of the at least one resource receiving port includes:
收集资源接收口的状态信息为重试状态的资源接收口;Collecting the status information of the resource receiving port is the resource receiving port in the retry state;
停止向所述重试状态的资源接收口推送实时数据并将所述资源接收口的状态信息设置为重试;Stop pushing real-time data to the resource receiving port in the retry state and set the state information of the resource receiving port to retry;
基于重试状态的资源接收口进行对应于重试模式的数据推送。The resource receiving port in the retry state performs data push corresponding to the retry mode.
本发明实施例提供的数据传输方法,通过向正常状态的资源接收口并行推送数据,可以提高数据传输的效率;且在预设线程推送异常时,将该资源接收口的状态信息设置为重试,并对其进行重试模式的数据推送,实现正常到重试的状态流转以保证数据的正常推送。The data transmission method provided by the embodiment of the present invention can improve the efficiency of data transmission by pushing data to the resource receiving port in a normal state in parallel; and when the preset thread push is abnormal, the state information of the resource receiving port is set to retry , and push the data in the retry mode to realize the normal to retry state flow to ensure the normal push of the data.
结合第一方面第二实施方式,在第一方面第三实施方式中,所述基于重试状态的资源接收口进行对应于重试模式的数据推送,包括:With reference to the second embodiment of the first aspect, in the third embodiment of the first aspect, the resource receiving port based on the retry state performs data push corresponding to the retry mode, including:
另开线程向所述重试状态的资源接收口再次推送当前推送失败的数据;Open another thread to push the currently failed data to the resource receiving port in the retry state again;
判断在预设条件内向所述重试状态的资源接收口是否成功推送所述当前推送失败的数据;judging whether the data of the current push failure is successfully pushed to the resource receiving port in the retry state within a preset condition;
当在预设条件内向所述重试状态的资源接收口成功推送所述当前推送失败的数据时,将所述重试状态的资源接收口的状态信息设置为恢复中;When successfully pushing the currently failed data to the resource receiving port in the retry state within the preset condition, setting the state information of the resource receiving port in the retry state as recovering;
基于所述恢复中的资源接收口进行对应于恢复中模式的数据推送;Perform data push corresponding to the mode in recovery based on the resource receiving port in recovery;
或,or,
当在预设条件内向所述重试状态的资源接收口并未成功推送所述当前推送失败的数据时,将所述重试状态的资源接收口的状态设置为异常;When the currently failed data is not pushed successfully to the resource receiving port in the retry state within the preset condition, setting the state of the resource receiving port in the retry state as abnormal;
基于异常状态的资源接收口进行对应于异常模式的数据推送。The resource receiving port based on the abnormal state performs data push corresponding to the abnormal mode.
本发明实施例提供的数据传输方法,在重试模式中若数据推送成功,则将资源接收口的状态信息设置为恢复中,实现重试到恢复中的状态流转,为数据的推送提供了保障;或者,在重试状态的资源接收 口在预设条件内并未成功推送当前推送失败的数据时,实现资源接收口从重试状态到异常状态的流转,为数据的正常推送提供了保障。In the data transmission method provided by the embodiment of the present invention, if the data push is successful in the retry mode, the state information of the resource receiving port is set to be in recovery, so as to realize the state flow from retry to recovery, which provides guarantee for data push Or, when the resource receiving port in the retry state does not successfully push the data that fails to push the current push within the preset conditions, the flow of the resource receiving port from the retry state to the abnormal state is realized, which provides a guarantee for the normal push of the data.
结合第一方面第一实施方式,在第一方面第四实施方式中,所述根据至少一个所述资源接收口的状态信息,向至少一个所述资源接收口推送所述实时数据,包括:With reference to the first embodiment of the first aspect, in the fourth embodiment of the first aspect, the pushing the real-time data to at least one of the resource receiving ports according to the state information of at least one of the resource receiving ports includes:
收集资源接收口的状态信息为恢复中的资源接收口;Collecting the status information of the resource receiving port is the resource receiving port being restored;
基于所述恢复中的资源接收口进行对应于恢复中模式的数据推送。Data push corresponding to the mode in recovery is performed based on the resource receiving port in recovery.
结合第一方面第三实施方式,或第四实施方式,在第一方面第五实施方式中,所述资源注册请求中还携带有配置信息,所述基于所述恢复中的资源接收口进行对应于恢复中模式的数据推送,包括:With reference to the third embodiment or the fourth embodiment of the first aspect, in the fifth embodiment of the first aspect, the resource registration request further carries configuration information, and the corresponding resource receiving port is based on the restoration. Data push in recovery mode, including:
提取所述恢复中的资源接收口的配置信息;extracting the configuration information of the resource receiving port in the restoration;
基于所述配置信息判断是否需要推送中断的数据;Determine whether the interrupted data needs to be pushed based on the configuration information;
当需要推送中断的数据时,读取从中断位置至当前位置之间的历史数据;When the interrupted data needs to be pushed, read the historical data from the interrupted position to the current position;
将所述历史数据推送至所述恢复中的资源接收口,并在推送过程中判断是否出现推送失败;Pushing the historical data to the resource receiving port in the restoration, and judging whether the push fails during the pushing process;
当没有出现推送失败时,将所述恢复中的资源接收口的状态信息设置为正常;When there is no push failure, set the status information of the resource receiving port in the recovery to normal;
基于正常状态的资源接收口进行对应于正常模式的数据推送。The data push corresponding to the normal mode is performed based on the resource receiving port in the normal state.
本发明实施例提供的数据传输方法,在恢复中模式中可以从中断位置进行中断续传,保证数据不丢失;且在历史数据推送不出现失败时,实现资源接收口的状态从恢复中到正常的流转,为恢复中断的推送数据提供了保障。In the data transmission method provided by the embodiment of the present invention, in the recovery mode, the interrupted and resumed transmission can be performed from the interrupted position to ensure that the data is not lost; and when the historical data push does not fail, the state of the resource receiving port can be changed from recovery to normal. The flow of data provides a guarantee for the recovery of interrupted push data.
结合第一方面第五实施方式,在第一方面第六实施方式中,所述基于所述恢复中的资源接收口进行对应于恢复中模式的数据推送,包括:With reference to the fifth implementation manner of the first aspect, in the sixth implementation manner of the first aspect, the performing data push corresponding to the recovering mode based on the resource receiving port under recovery includes:
当出现推送失败时,将所述恢复中的资源接收口的状态信息设置为异常,基于异常状态的资源接收口进行对应于异常模式的数据推送。When a push failure occurs, the state information of the resource receiving port in the restoration is set to be abnormal, and the resource receiving port based on the abnormal state performs data push corresponding to the abnormal mode.
本发明实施例提供的数据传输方法,在恢复中模式中,若数据推送出现失败,则直接将该资源接收口的状态设置为异常,不再进行重试,以避免数据传输的多次重试,提高了数据传输的实时性。In the data transmission method provided by the embodiment of the present invention, in the recovery mode, if the data push fails, the state of the resource receiving port is directly set to be abnormal, and no retry is performed, so as to avoid multiple retries of data transmission. , which improves the real-time performance of data transmission.
结合第一方面第一实施方式,在第一方面第七实施方式中,所述根据至少一个所述资源接收口的状态信息,向至少一个所述资源接收口推送所述实时数据,包括:With reference to the first embodiment of the first aspect, in the seventh embodiment of the first aspect, the pushing the real-time data to at least one of the resource receiving ports according to the state information of at least one of the resource receiving ports includes:
收集资源接收口的状态信息为异常状态的资源接收口;The state information of the collected resource receiving port is the resource receiving port in an abnormal state;
基于异常状态的资源接收口进行对应于异常模式的数据推送。The resource receiving port based on the abnormal state performs data push corresponding to the abnormal mode.
结合第一方面第三实施方式,或第六实施方式或第七实施方式,在第一方面第八实施方式中,所述基于异常状态的资源接收口进行对应于异常模式的数据推送,包括:With reference to the third embodiment, or the sixth embodiment or the seventh embodiment of the first aspect, in the eighth embodiment of the first aspect, the abnormal state-based resource receiving port performs data push corresponding to the abnormal mode, including:
接收所述异常状态的资源接收口的状态更新为正常的信息;The state of the resource receiving port receiving the abnormal state is updated to normal information;
判断设置的所述异常状态的资源接收口的状态是否为异常;Determine whether the state of the set resource receiving port of the abnormal state is abnormal;
当设置的所述异常状态的资源接收口的状态为异常时,将所述异常状态的资源接收口的状态信息设置为恢复中;When the set state of the resource receiving port in the abnormal state is abnormal, setting the state information of the resource receiving port in the abnormal state as recovering;
基于恢复中的资源接收口进行对应于恢复中模式的数据推送。Data push corresponding to the mode in recovery is performed based on the resource receiving port in recovery.
本发明实施例提供的数据传输方法,在外部将异常状态的资源接收口的状态更新为正常时,本地并不直接将该资源接收口的状态设置为正常,而是先将其设置为恢复中,进入异常到恢复中的状态流转,为数据的正常传输提供了保障。In the data transmission method provided by the embodiment of the present invention, when the state of the resource receiving port in the abnormal state is updated to normal externally, the local does not directly set the state of the resource receiving port to normal, but first sets it to recovering , and enter the state flow from abnormal to recovery, which provides a guarantee for the normal transmission of data.
结合第一方面第一实施方式,在第一方面第九实施方式中,所述资源注册请求携带有配置信息,所述配置信息包括数据过滤条件,所述根据至少一个所述资源接收口的状态信息,向至少一个所述资源接收口推送所述实时数据,包括:With reference to the first embodiment of the first aspect, in the ninth embodiment of the first aspect, the resource registration request carries configuration information, and the configuration information includes data filtering conditions. information, and push the real-time data to at least one of the resource receiving ports, including:
利用所述数据过滤条件对所述实时数据进行过滤;Filter the real-time data by using the data filter condition;
基于至少一个所述资源接收口的状态信息,向至少一个所述资源接收口推送过滤后的实时数据。Based on the state information of the at least one resource receiving port, the filtered real-time data is pushed to the at least one resource receiving port.
本发明实施例提供的数据传输方法,在实时数据传输之前先对其进行过滤,以使得传输的实时数据能够满足外部的需求。In the data transmission method provided by the embodiment of the present invention, the real-time data is filtered before the real-time data is transmitted, so that the transmitted real-time data can meet external requirements.
根据第二方面,本发明实施例还提供了一种数据传输装置,包括:According to a second aspect, an embodiment of the present invention further provides a data transmission device, including:
提供模块,用于提供本地开放的资源类型,所述资源类型与资源来源对应;providing a module for providing a locally open resource type, the resource type corresponding to the resource source;
接收模块,用于接收对至少一个目标资源类型的资源注册请求,所述资源注册请求携带有对应的资源接收口的配置信息;a receiving module, configured to receive a resource registration request for at least one target resource type, where the resource registration request carries configuration information of a corresponding resource receiving port;
确定模块,用于基于所述资源注册请求,确定所述目标资源类型对应的目标资源来源;a determining module, configured to determine the target resource source corresponding to the target resource type based on the resource registration request;
提取模块,用于从所述目标资源来源中提取出实时数据;an extraction module, for extracting real-time data from the target resource source;
推送模块,用于向至少一个所述资源接收口推送所述实时数据。A push module, configured to push the real-time data to at least one of the resource receiving ports.
本发明实施例提供的数据传输装置,利用资源类型与资源来源的对应关系,确定目标资源类型对应的目标资源来源,即可从目标资源来源中提取出实时数据并推送给资源接收口,从而达到数据实时推送的目的,且利用资源类型来共用同一条实时推送机制,以避免给外部提供多个数据接口,以逆向反转推送来避免外部请求过多导致服务器的压力增大,提高了数据传输的实时性。The data transmission device provided by the embodiment of the present invention utilizes the corresponding relationship between resource types and resource sources to determine the target resource source corresponding to the target resource type, so that real-time data can be extracted from the target resource source and pushed to the resource receiving port, thereby achieving The purpose of real-time data push, and use the resource type to share the same real-time push mechanism to avoid providing multiple data interfaces to the outside, and reverse the push to avoid excessive external requests and increase the pressure on the server, which improves data transmission. real-time.
根据第三方面,本发明实施例提供了一种电子设备,包括:存储器和处理器,所述存储器和所述处理器之间互相通信连接,所述存储器中存储有计算机指令,所述处理器通过执行所述计算机指令,从而执行第一方面或者第一方面的任意一种实施方式中所述的数据传输方法。According to a third aspect, an embodiment of the present invention provides an electronic device, including: a memory and a processor, the memory and the processor are connected in communication with each other, the memory stores computer instructions, and the processor By executing the computer instructions, the data transmission method described in the first aspect or any one of the implementation manners of the first aspect is executed.
根据第四方面,本发明实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储计算机指令,所述计算机指令用于使所述计算机执行第一方面或者第一方面的任意一种实施方式中所述的 数据传输方法。According to a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, where the computer-readable storage medium stores computer instructions, and the computer instructions are used to cause the computer to execute the first aspect or any one of the first aspect. A data transmission method described in an embodiment.
附图说明Description of drawings
为了更清楚地说明本发明具体实施方式或现有技术中的技术方案,下面将对具体实施方式或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施方式,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the specific embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the specific embodiments or the prior art. Obviously, the accompanying drawings in the following description The drawings are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without creative efforts.
图1示出了本发明实施例的数据传输方法的一种可选的应用场景;FIG. 1 shows an optional application scenario of the data transmission method according to the embodiment of the present invention;
图2是根据本发明实施例的数据传输方法的流程图;2 is a flowchart of a data transmission method according to an embodiment of the present invention;
图3是根据本发明实施例的数据传输方法的流程图;3 is a flowchart of a data transmission method according to an embodiment of the present invention;
图4是根据本发明实施例的内部数据流转机制的示意图;4 is a schematic diagram of an internal data flow mechanism according to an embodiment of the present invention;
图5是根据本发明实施例的数据传输方法的流程图;5 is a flowchart of a data transmission method according to an embodiment of the present invention;
图6是根据本发明实施例的数据传输方法的架构图;6 is an architectural diagram of a data transmission method according to an embodiment of the present invention;
图7是根据本发明实施例的数据传输装置的结构框图;7 is a structural block diagram of a data transmission apparatus according to an embodiment of the present invention;
图8是本发明实施例提供的电子设备的硬件结构示意图。FIG. 8 is a schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present invention.
具体实施方式detailed description
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments These are some embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of the present invention.
图1为本发明实施例提供的数据传输方法的一个可选的应用场景。如图1所示,在该数据传输系统中包括有电子设备(即,下文也可以称之为本地)、至少一个外部系统(也可以称之为外部程序)。FIG. 1 is an optional application scenario of the data transmission method provided by the embodiment of the present invention. As shown in FIG. 1 , the data transmission system includes an electronic device (that is, it may also be referred to as a local device hereinafter) and at least one external system (which may also be referred to as an external program).
其中,电子设备在其内部建立资源类型与资源来源的对应关系,再向外界提供资源类型,外部设备从电子设备提供的资源类型中选择其所需要的目标资源类型,并向电子设备发送资源注册请求。Among them, the electronic device establishes the corresponding relationship between the resource type and the resource source, and then provides the resource type to the outside world. The external device selects the target resource type it needs from the resource types provided by the electronic device, and sends the resource registration to the electronic device. ask.
电子设备在接收到外部系统发送的资源注册请求之后,利用资源类型与资源来源的对应关系,确定目标资源类型对应的目标资源来源,从目标资源来源中提取出实时数据并分别按照各个外部系统的资源接收口的状态信息进行推送。After receiving the resource registration request sent by the external system, the electronic device uses the corresponding relationship between the resource type and the resource source to determine the target resource source corresponding to the target resource type, extracts real-time data from the target resource source, and separates it according to the requirements of each external system. The status information of the resource receiving port is pushed.
对于外部系统而言,其也无需定时请求获取数据,它只需提供资源接收口,即可在有数据的时候收到相应的数据从而只需专注业务处理,而无需重复处理相应的对接工作,易于功能扩展。For the external system, it does not need to request data regularly. It only needs to provide a resource receiving port, and then it can receive the corresponding data when there is data, so that it only needs to focus on business processing, and does not need to repeatedly process the corresponding docking work. Easy function extension.
该数据传输系统中,由于在电子设备中已经将不同种类的开放数据源抽象成资源类型,外部系统只知资源类型而不知具体的内部数据源,从而易于切换内部数据来源,不必在电子设备中提供对外开放接口,外部系统感知不到数据源的变化,内部迁移扩展方便。其中,关于数据传输的方法的内容,具体将在下文中进行详细描述。In the data transmission system, since different types of open data sources have been abstracted into resource types in the electronic device, the external system only knows the resource type but does not know the specific internal data source, so it is easy to switch the internal data source without having to use the electronic device. Provide an open interface to the outside world, the external system cannot perceive the change of the data source, and the internal migration and expansion are convenient. The content of the data transmission method will be described in detail below.
根据本发明实施例,提供了一种数据传输方法实施例,需要说明的是,在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。According to an embodiment of the present invention, an embodiment of a data transmission method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings may be executed in a computer system such as a set of computer-executable instructions, and, although in the A logical order is shown in the flowcharts, but in some cases steps shown or described may be performed in an order different from that herein.
在本实施例中提供了一种数据传输方法,可用于上述的电子设备,如服务器、电脑、平板电脑等,图2是根据本发明实施例的数据传输方法的流程图,如图2所示,该流程包括如下步骤:In this embodiment, a data transmission method is provided, which can be used for the above-mentioned electronic devices, such as servers, computers, tablet computers, etc. FIG. 2 is a flowchart of the data transmission method according to an embodiment of the present invention, as shown in FIG. 2 , the process includes the following steps:
S11,提供本地开放的资源类型。S11, providing a locally open resource type.
其中,所述资源类型与资源来源对应。The resource type corresponds to the resource source.
所述的资源类型是本地要对外开放的消息的一种编号说明,其中,本地维护有消息订阅推送系统。资源类型的具体编号的格式可以根据实际情况进行相应的设置,只需保证外界通过该资源类型能够知晓其 对应的资源。例如,它可以是由资源类型名称、资源类型描述以及资源消息的对外格式组成。电子设备将它提供给外部系统知晓,外部系统根据资源类型就能够知晓了资源类型对外代表的数据用途,从而在后续的步骤中就可以通过向电子设备发送资源注册请求,以请求它想要获取的资源类型对应的实时数据。The resource type is a serial number description of a message to be opened locally, wherein a message subscription push system is maintained locally. The format of the specific number of the resource type can be set according to the actual situation, and it is only necessary to ensure that the outside world can know the corresponding resource through the resource type. For example, it can consist of the resource type name, the resource type description, and the external format of the resource message. The electronic device provides it to the external system to know, and the external system can know the data usage of the external representative of the resource type according to the resource type, so that in the subsequent steps, it can send a resource registration request to the electronic device to request that it wants to obtain The real-time data corresponding to the resource type of .
电子设备在获取到一个新增的资源来源时,只需在电子设备中基于新增的资源来源及其对应的资源类型,更新资源类型与资源来源的对应关系即可,而不需要额外设置对外的接口。所述的资源来源可以是第三方数据系统、数据库、数据引擎或数据仓库等等,在此对资源来源的具体形式并不做任何限制,只需其能够提供数据即可。When the electronic device acquires a new resource source, it only needs to update the corresponding relationship between the resource type and the resource source based on the new resource source and its corresponding resource type in the electronic device, without additional external settings. Interface. The resource source may be a third-party data system, database, data engine or data warehouse, etc. The specific form of the resource source is not limited here, as long as it can provide data.
S12,接收对至少一个目标资源类型的资源注册请求。S12: Receive a resource registration request for at least one target resource type.
所述资源注册请求与资源接收口对应。The resource registration request corresponds to a resource receiving port.
电子设备将本地的资源类型提供给外部系统知晓,那么外部系统基于自身的需求就可以通过向电子设备发送资源注册请求,以请求获取目标资源类型对应的实时数据。在每个资源注册请求中均对应有资源接收口的信息,所述的资源接收口用于接收目标资源类型对应的实时数据。The electronic device provides the local resource type to the external system to know, then the external system can request to obtain real-time data corresponding to the target resource type by sending a resource registration request to the electronic device based on its own needs. Each resource registration request corresponds to the information of the resource receiving port, and the resource receiving port is used for receiving real-time data corresponding to the target resource type.
如图1所示,电子设备所接收到的资源注册请求可以是至少一个外部系统发送的对于同一个目标资源类型的资源注册请求,那么电子设备就可以对同一个目标资源类型进行相同的处理,再分别发送给不同的外部系统。As shown in Figure 1, the resource registration request received by the electronic device may be a resource registration request for the same target resource type sent by at least one external system, then the electronic device can perform the same processing on the same target resource type, Then send them to different external systems respectively.
例如,外部系统1对应于资源接收口a,外部系统2对应于资源接收口b,外部系统3对应于资源接收口c。若电子设备接收到外部系统1、外部系统2以及外部系统3发送的对于同一目标资源类型的资源注册请求,那么,电子设备利用资源注册请求就可以确定出各个外部系统对应的资源接收口以及目标资源类型对应的目标资源接收口。后续在提取出实时数据之后,就可以将实时数据分别推送至相应 的资源接收口,从而就可以被各个外部系统所接收到。For example, the external system 1 corresponds to the resource receiving port a, the external system 2 corresponds to the resource receiving port b, and the external system 3 corresponds to the resource receiving port c. If the electronic device receives a resource registration request for the same target resource type sent by the external system 1, the external system 2, and the external system 3, the electronic device can determine the resource receiving port and target corresponding to each external system by using the resource registration request. The target resource receiving port corresponding to the resource type. After the real-time data is extracted, the real-time data can be pushed to the corresponding resource receiving ports, so that it can be received by each external system.
可选地,电子设备所接收到的资源注册请求也可以是至少一个外部系统发送的对于至少一个目标资源类型的资源注册请求,电子设备可以针对同一个目标资源类型的资源注册请求进行相同的处理后,在分别发送给相应的资源接收口。Optionally, the resource registration request received by the electronic device may also be a resource registration request for at least one target resource type sent by at least one external system, and the electronic device may perform the same processing for the resource registration request of the same target resource type. Then, send them to the corresponding resource receiving ports respectively.
例如,继续沿用上文所述的实施例,外部系统1请求目标资源类型c2,外部系统2请求目标资源类型c1,外部系统3请求目标资源类型c2。由于外部系统1以及外部系统3请求的是相同的目标资源类型,那么在电子设备中就可以针对外部系统1以及外部系统3进行相同的操作,后续提取出实时数据1之后,在分别推送给相应的资源接收口a以及资源接收口c;电子设备可以针对外部系统2提取出实时数据2,将实时数据2推送给相应的资源接收口b。For example, continuing to use the above-mentioned embodiment, the external system 1 requests the target resource type c2, the external system 2 requests the target resource type c1, and the external system 3 requests the target resource type c2. Since the external system 1 and the external system 3 request the same target resource type, the electronic device can perform the same operation on the external system 1 and the external system 3. After the real-time data 1 is subsequently extracted, it is pushed to the corresponding The resource receiving port a and the resource receiving port c of the electronic device can extract the real-time data 2 for the external system 2, and push the real-time data 2 to the corresponding resource receiving port b.
在此对电子设备所接收到的资源注册请求并不做任何限制,具体可以根据实际情况进行相应的设置。在下文的描述中,以电子设备接收到的是针对同一个目标资源类型的至少一个资源注册请求为例进行详细描述。There is no restriction on the resource registration request received by the electronic device, and specific settings can be made according to the actual situation. In the following description, the electronic device receives at least one resource registration request for the same target resource type as an example for detailed description.
S13,基于资源注册请求,确定目标资源类型对应的目标资源来源。S13, based on the resource registration request, determine the target resource source corresponding to the target resource type.
如上所述,电子设备在接收到各个外部系统发送的资源注册请求之后,通过查询目标资源类型与资源来源的对应关系,就可以确定出目标资源类型对应的目标资源来源。As described above, after receiving the resource registration request sent by each external system, the electronic device can determine the target resource source corresponding to the target resource type by querying the correspondence between the target resource type and the resource source.
例如,在电子设备中维护有一个运转器以及至少一个主监听器,当电子设备接收到资源注册请求之后,运转器利用资源注册请求对应的目标资源类型,确定出需要启动的主监听器。在确定出目标资源类型之后,启动所述目标资源类型对应的主监听器,以从目标资源类型对应的目标资源来源中提取出实时数据。其中,主监听器启动的时机是当至少有一个外部系统注册了其对应的资源类型时,才会触发监听 器启动以避免监听器空置运行浪费资源。For example, one runner and at least one main listener are maintained in the electronic device. After the electronic device receives the resource registration request, the runner uses the target resource type corresponding to the resource registration request to determine the main listener to be activated. After the target resource type is determined, the main listener corresponding to the target resource type is started to extract real-time data from the target resource source corresponding to the target resource type. Among them, the timing of starting the main listener is that when at least one external system has registered its corresponding resource type, the listener will be triggered to start, so as to avoid wasting resources by running the listener vacantly.
其中,在电子设备中可以创建有一个通用的主监听器,所述的主监听器对外提供的接口包括监听来源接口以及实时数据推送接口,其中,监听来源接口用于从资源来源中提取出实时数据,实时数据推送接口用于将提取出的实时数据推送给对应的资源接收口。当资源来源为多种类型时,在该通用的主监听器中还可以设置对应于各个类型的资源来源的适配器,用于进行相应的数据转换等等。Wherein, a general master listener can be created in the electronic device, and the externally provided interfaces of the master listener include a monitoring source interface and a real-time data push interface, wherein the monitoring source interface is used to extract real-time data from resource sources. Data, the real-time data push interface is used to push the extracted real-time data to the corresponding resource receiving port. When the resource sources are of multiple types, adapters corresponding to the resource sources of each type can also be set in the general master listener for performing corresponding data conversion and the like.
当然,也可以在电子设备中创建与资源来源对应的主监听器,每个资源来源对应于一个主监听器。例如,资源来源包括数据库、数据仓库以及数字引擎,那么就可以针对数据库、数据仓库以及数字引擎分别创建对应的主监听器。在此对主监听器的具体设置方式并不做任何限制,具体可以根据实际情况进行相应的设置,只需保证其能够从确定出的资源来源中提取出实时数据,并将提取出的实时数据推送给相应的资源接收口即可。Of course, master listeners corresponding to resource sources may also be created in the electronic device, and each resource source corresponds to a master listener. For example, if resource sources include databases, data warehouses, and digital engines, corresponding master listeners can be created for databases, data warehouses, and digital engines respectively. There is no restriction on the specific setting method of the main listener here. The specific setting can be made according to the actual situation. It only needs to ensure that it can extract real-time data from the determined resource source, and will extract the real-time data. Just push it to the corresponding resource receiving port.
具体地,如上文所述,在电子设备中维护有一个消息订阅推送系统,电子设备在接收到资源注册请求之后,随着资源来源的不同,将新增的资源来源加入到本消息订阅推送系统,只需要更新资源类型与资源来源的对应关系,就可以实现对消息订阅推送系统的更新,从而使得电子设备中的资源类型能够及时被外部系统所知晓,本系统会根据资源对应关系选取相应的处理方法获取数据并根据一系列过滤处理功能处理后发送到外部系统提供的资源接收口。Specifically, as mentioned above, a message subscription and push system is maintained in the electronic device. After the electronic device receives the resource registration request, the new resource source is added to the message subscription and push system according to the different resource sources. , only need to update the corresponding relationship between the resource type and the resource source, the update of the message subscription push system can be realized, so that the resource type in the electronic device can be known by the external system in time, and the system will select the corresponding The processing method acquires data, processes it according to a series of filtering processing functions, and sends it to the resource receiving port provided by the external system.
S14,从目标资源来源中提取出实时数据。S14, extracting real-time data from the target resource source.
如上文所述,电子设备可以利用目标资源来源确定出的主监听器从目标资源来源中提取出实时数据。As described above, the electronic device can extract real-time data from the target resource source using the master listener determined by the target resource source.
S15,向至少一个资源接收口推送实时数据。S15, push real-time data to at least one resource receiving port.
外部系统根据资源类型的描述知晓了资源类型对外代表的数据用途,通过内部程序在对外开放平台中提供的接口注册它想要获取的 数据对应的资源类型,并提供相关的资源接收口。电子设备在提取出实时数据之后,利用各个资源接收口的状态信息向其进行实时数据的推送。The external system knows the data usage of the external representation of the resource type according to the description of the resource type, registers the resource type corresponding to the data it wants to acquire through the interface provided by the internal program in the external open platform, and provides the relevant resource receiving port. After extracting the real-time data, the electronic device pushes the real-time data to it by using the status information of each resource receiving port.
可选地,在资源注册请求中还可以携带有对数据的过滤规则,以及数据推送的频率和数据是否需要断点续传等配置信息。这些配置信息将被内部消息订阅推送系统所存储,然后内部资源类型被外部系统注册后,根据资源类型的处理方法获取数据后,再利用外部系统的配置信息进行规则的过滤处理,决定是否往外部系统推送数据。在确定出需要往外部系统推送数据时,再利用各个资源接收口的状态信息向其推送实时数据。Optionally, the resource registration request may also carry data filtering rules, as well as configuration information such as the frequency of data push and whether the data needs to be resumed at a breakpoint. These configuration information will be stored by the internal message subscription push system, and then after the internal resource type is registered by the external system, after obtaining the data according to the processing method of the resource type, the configuration information of the external system is used to filter the rules and decide whether to send the external system to the external system. The system pushes data. When it is determined that data needs to be pushed to the external system, the state information of each resource receiving port is used to push real-time data to it.
本实施例提供的数据传输方法,利用资源类型与资源来源的对应关系,确定目标资源类型对应的目标资源来源,即可从目标资源来源中提取出实时数据并推送给资源接收口,从而达到数据实时推送的目的,且利用资源类型来共用同一条实时推送机制,对于外部而言,其只知资源类型而不知具体的资源来源,从而易于切换内部数据来源,避免给外部提供多个数据接口,以逆向反转推送来避免外部请求过多导致服务器的压力增大,提高了数据传输的实时性。In the data transmission method provided in this embodiment, the corresponding relationship between resource types and resource sources is used to determine the target resource source corresponding to the target resource type, and real-time data can be extracted from the target resource source and pushed to the resource receiving port, so as to achieve data The purpose of real-time push is to use resource types to share the same real-time push mechanism. For the outside world, it only knows the resource type but not the specific resource source, so it is easy to switch internal data sources and avoid providing multiple data interfaces to the outside world. Reverse push is used to avoid excessive external requests and increase the pressure on the server, which improves the real-time performance of data transmission.
在本实施例中提供了一种数据传输方法,可用于上述的电子设备,如服务器、电脑、平板电脑等,图3是根据本发明实施例的数据传输方法的流程图,如图3所示,该流程包括如下步骤:In this embodiment, a data transmission method is provided, which can be used for the above-mentioned electronic devices, such as servers, computers, tablet computers, etc. FIG. 3 is a flowchart of the data transmission method according to an embodiment of the present invention, as shown in FIG. 3 , the process includes the following steps:
S21,提供本地开放的资源类型。S21, providing a locally open resource type.
其中,所述资源类型与资源来源对应。The resource type corresponds to the resource source.
详细请参见图2所示实施例的S11,在此不再赘述。For details, please refer to S11 of the embodiment shown in FIG. 2 , which will not be repeated here.
S22,接收对至少一个目标资源类型的资源注册请求。S22: Receive a resource registration request for at least one target resource type.
所述资源注册请求与资源接收口对应。The resource registration request corresponds to a resource receiving port.
详细请参见图2所示实施例的S12,在此不再赘述。For details, please refer to S12 of the embodiment shown in FIG. 2 , which will not be repeated here.
S23,基于资源注册请求,确定目标资源类型对应的目标资源来 源。S23, based on the resource registration request, determine the target resource source corresponding to the target resource type.
详细请参见图2所示实施例的S13,在此不再赘述。For details, please refer to S13 of the embodiment shown in FIG. 2 , which will not be repeated here.
S24,从目标资源来源中提取出实时数据。S24, extracting real-time data from the target resource source.
详细请参见图2所示实施例的S14,在此不再赘述。For details, please refer to S14 of the embodiment shown in FIG. 2 , which will not be repeated here.
S25,向至少一个资源接收口推送实时数据。S25, push real-time data to at least one resource receiving port.
电子设备还基于资源注册请求确定出至少一个资源接收口的状态信息,并根据至少一个资源接收口的状态信息,向至少一个所述资源接收口推送实时数据。其中,所述状态信息包括正常、重试、异常以及恢复中的一种。The electronic device further determines state information of at least one resource receiving port based on the resource registration request, and pushes real-time data to at least one resource receiving port according to the state information of at least one resource receiving port. Wherein, the state information includes one of normal, retry, abnormal and recovery.
如上文所述,电子设备依据各个资源接收口的状态信息向其推送实时数据。具体地,可以分为如下处理方式:As mentioned above, the electronic device pushes real-time data to each resource receiving port according to the status information. Specifically, it can be divided into the following processing methods:
(1)正常状态的资源接收口(1) Resource receiving port in normal state
电子设备收集资源接收口的状态信息为正常状态的资源接收口,基于正常的资源接收口进行对应于正常模式的数据推送。其中,正常模式的数据推送可以参见下文中S252及其后续步骤的相关描述。The state information of the resource receiving port collected by the electronic device is the resource receiving port in the normal state, and data push corresponding to the normal mode is performed based on the normal resource receiving port. For the data push in the normal mode, reference may be made to the related description of S252 and its subsequent steps below.
(2)重试状态的资源接收口(2) Resource receiving port in retry state
电子设备收集资源接收口的状态信息为重试状态的资源接收口,基于重试的资源接收口进行对应于重试模式的数据推送。其中,重试模式的数据推送可以参见下文中S256的相关描述。The state information of the resource receiving port collected by the electronic device is the resource receiving port in the retry state, and data push corresponding to the retry mode is performed based on the retrying resource receiving port. The data push in the retry mode may refer to the related description of S256 below.
(3)异常状态的资源接收口(3) Resource receiving port in abnormal state
电子设备收集资源接收口的状态信息为异常状态的资源接收口,基于异常的资源接收口进行对应于异常模式的数据推送。其中,异常模式的数据推送可以参见下文S255中的步骤(6)的相关描述。The state information of the resource receiving port collected by the electronic device is the resource receiving port in the abnormal state, and the data push corresponding to the abnormal mode is performed based on the abnormal resource receiving port. For the data push in the abnormal mode, reference may be made to the relevant description of step (6) in S255 below.
(4)恢复中状态的资源接收口(4) Resource receiving port in recovery state
电子设备收集资源接收口的状态信息为恢复中状态的资源接收口,基于恢复中的资源接收口进行对应于恢复中模式的数据推送。其 中,恢复中模式的数据推送可以参见下文S256中的步骤(4)的相关描述。The state information of the resource receiving port collected by the electronic device is the resource receiving port in the recovering state, and data push corresponding to the recovering mode is performed based on the resource receiving port in the recovering state. The data push in the recovery mode may refer to the relevant description of step (4) in S256 below.
由以上可知,电子设备基于各个资源接收口的状态,进行不同模式的数据推送。其中,需要说明的是,在数据推送过程中,同一资源接收口的状态信息可以发生变化。例如,可以从正常状态变化为重试状态,可以从重试状态变化为异常状态,从异常状态变化为恢复中状态等等。在下文的描述中,以资源接收口的状态信息为正常状态为例,对资源接收后的状态变化及各个状态对应的处理模式进行详细描述。It can be seen from the above that the electronic device pushes data in different modes based on the status of each resource receiving port. Among them, it should be noted that during the data push process, the status information of the same resource receiving port may change. For example, it can change from a normal state to a retry state, from a retry state to an abnormal state, from an abnormal state to a recovering state, and so on. In the following description, taking the state information of the resource receiving port as the normal state as an example, the state change after the resource is received and the processing mode corresponding to each state will be described in detail.
具体地,上述S25包括如下步骤:Specifically, the above S25 includes the following steps:
S251,基于资源注册请求,确定至少一个资源接收口的状态信息。S251 , based on the resource registration request, determine the status information of at least one resource receiving port.
由于资源注册请求是与资源接收接口对应的,而在电子设备中存储有各个资源接收接口的实时状态信息,因此,电子设备可以利用资源注册请求确定至少一个资源接收口的状态信息。Since the resource registration request corresponds to the resource receiving interface, and real-time status information of each resource receiving interface is stored in the electronic device, the electronic device can use the resource registration request to determine the state information of at least one resource receiving interface.
S252,收集资源接收口的状态信息为正常状态的资源接收口。S252, the state information of the collected resource receiving ports is the resource receiving ports in the normal state.
电子设备利用各个资源接收口的状态信息,从中收集出状态信息为正常状态的资源接收口,以对其进行正常模式的数据推送。The electronic device utilizes the state information of each resource receiving port, and collects the resource receiving port whose state information is the normal state, so as to push the data in the normal mode.
S253,利用至少一个线程将实时数据并行推送给正常状态的资源接收口。S253, using at least one thread to push the real-time data to the resource receiving port in the normal state in parallel.
电子设备可以依据正常状态的资源接收口的数量创建相应数量的线程,即,创建的线程与正常状态的资源接收口一一对应。在创建出线程之后,电子设备利用相应的线程将实时数据推送给正常状态的资源接收口,实现实时数据的并行推送。The electronic device may create a corresponding number of threads according to the number of resource receiving ports in the normal state, that is, the created threads correspond to the resource receiving ports in the normal state one-to-one. After the thread is created, the electronic device uses the corresponding thread to push the real-time data to the resource receiving port in the normal state, so as to realize the parallel push of the real-time data.
S254,判断预设线程的推送是否异常。S254, determine whether the push of the preset thread is abnormal.
电子设备在各个线程的数据推送过程中,实时判断各个线程的推送是否异常。以预设线程为例,电子设备实时判断预设线程的推送是否异常,所述的异常可以是实时数据是否推送成功,当所述线程的推送异常时,执行S255;否则,在实时数据的推送过程中执行S254, 确定是否出现推送异常的情况。During the data push process of each thread, the electronic device judges in real time whether the push of each thread is abnormal. Taking the preset thread as an example, the electronic device judges in real time whether the push of the preset thread is abnormal, and the abnormality may be whether the real-time data is pushed successfully. During the process, S254 is executed to determine whether a push exception occurs.
S255,停止预设线程的实时数据推送并将预设线程对应的资源接收口的状态信息设置为重试。S255, stop the real-time data push of the preset thread and set the state information of the resource receiving port corresponding to the preset thread to retry.
在电子设备确定出预设线程的实时数据推送出现异常,那么就会停止该预设线程的数据推送,并将预设线程对应的资源接收口的状态信息设置为重试。When the electronic device determines that the real-time data push of the preset thread is abnormal, the data push of the preset thread is stopped, and the status information of the resource receiving port corresponding to the preset thread is set to retry.
外部系统1的资源接收口a以及外部系统2的资源接收口b为正常状态的资源接收口,那么电子设备创建2个线程,例如线程1以及线程2,并利用线程1以及线程2分别向资源接收口a和b发送实时数据。若在实时数据发送过程中,电子设备确定出线程1的数据推送出现异常,线程2的数据推送正常,那么电子设备就会将线程1对应的资源接收口a的状态信息设置为重试,并停止线程1的数据推送。其中,线程2还是正常向资源接收口b推送实时数据。The resource receiving port a of the external system 1 and the resource receiving port b of the external system 2 are resource receiving ports in the normal state, then the electronic device creates two threads, such as thread 1 and thread 2, and uses thread 1 and thread 2 to send resources to the resource. Receiving ports a and b send real-time data. If during the real-time data sending process, the electronic device determines that the data push of thread 1 is abnormal and the data push of thread 2 is normal, then the electronic device will set the status information of the resource receiving port a corresponding to thread 1 to retry, and Stop the data push of thread 1. The thread 2 still pushes real-time data to the resource receiving port b normally.
S256,基于重试状态的资源接收口进行对应于重试模式的数据推送。S256, push data corresponding to the retry mode based on the resource receiving port in the retry state.
电子设备在将预设线程对应的资源接收口的状态信息设置为重试之后,就可以对其进行对应于重试模式的数据推送。After the electronic device sets the state information of the resource receiving port corresponding to the preset thread to retry, it can push the data corresponding to the retry mode.
通过向正常状态的资源接收口并行推送数据,可以提高数据传输的效率;且在预设线程推送异常时,将该资源接收口的状态信息设置为重试,并对其进行重试模式的数据推送,实现正常到重试的状态流转以保证数据的正常推送。By pushing data to the resource receiving port in the normal state in parallel, the efficiency of data transmission can be improved; and when the preset thread pushes abnormality, the state information of the resource receiving port is set to retry, and the data in the retry mode is performed. Push, to achieve normal to retry state flow to ensure the normal push of data.
具体地,上述S256可以如下步骤,也可以理解为重试模式的数据推送可以包括如下步骤:Specifically, the above S256 may be the following steps, and it may also be understood that the data push in the retry mode may include the following steps:
(1)另开线程向重试状态的资源接收口再次推送当前推送失败的数据。(1) Open another thread to push the currently failed data to the resource receiving port in the retry state again.
继续沿用上述的实施例,对于资源接收口a而言,电子设备另开一个线程向其再次推送当前推送失败的数据。Continuing to use the above-mentioned embodiment, for the resource receiving port a, the electronic device opens another thread to push the currently failed data to it again.
(2)判断在预设条件内向重试状态的资源接收口是否成功推送当前推送失败的数据。(2) Judging whether the data that is currently failed to be pushed is successfully pushed to the resource receiving port in the retry state within the preset condition.
其中,所述的预设条件可以是预设次数,也可以是预设时间间隔内等等,具体可以根据实际情况进行相应的设置,在此并不做任何限制。Wherein, the preset condition may be a preset number of times, or within a preset time interval, etc., and may be specifically set according to the actual situation, which is not limited herein.
当在条件内向重试状态的资源接收口成功推送当前推送失败的数据时,执行步骤(3);否则,执行步骤(5)。例如,电子设备可以利用另开的线程向重试状态的资源接收口最多推送3次当前推送失败的数据,若3次推送均失败,则执行步骤(5);否则,执行步骤(3)。When the currently failed data is successfully pushed to the resource receiving port in the retry state within the condition, step (3) is performed; otherwise, step (5) is performed. For example, the electronic device can use a separate thread to push the data that has failed to be pushed up to three times to the resource receiving port in the retry state. If all three pushes fail, step (5) is performed; otherwise, step (3) is performed.
(3)将重试状态的资源接收口的状态信息设置为恢复中。(3) The state information of the resource receiving port in the retry state is set as recovering.
电子设备在重试过程中,若当前推送失败的数据推送成功,则将重试状态的资源接收口的状态信息设置为恢复中。During the retry process of the electronic device, if the currently failed data is successfully pushed, the state information of the resource receiving port in the retry state is set as recovering.
在重试模式中若数据推送成功,则将资源接收口的状态信息设置为恢复中,实现重试到恢复中的状态流转,为数据的推送提供了保障。In the retry mode, if the data push is successful, the state information of the resource receiving port is set to recovering to realize the state flow from retry to recovery, which provides guarantee for data push.
(4)基于恢复中的资源接收口进行对应于恢复中模式的数据推送。(4) Push data corresponding to the mode in recovery based on the resource receiving port in recovery.
具体地,上述步骤(4)可以包括如下步骤,也可以理解恢复中模式的数据推送方式包括如下步骤:Specifically, the above step (4) may include the following steps, and it can also be understood that the data push mode of the recovery mode includes the following steps:
4.1)提取恢复中的资源接收口的配置信息。4.1) Extract the configuration information of the resource receiving port in recovery.
所述的配置信息可以包括资源接收口推送中断数据的标志,当推送中断数据的标志为1时,表示该资源接收口需要推送中断的数据,则就需要将从中断位置到当前位置之间的历史数据推送给恢复中的资源接收口;当推送中断数据的标志位0时,表示该资源接收口不需要推送中断的数据。The configuration information may include a flag for pushing interrupted data at the resource receiving port. When the flag for pushing interrupted data is 1, it means that the resource receiving port needs to push the interrupted data, and then it needs to push the interrupted data from the interrupted position to the current position. The historical data is pushed to the resource receiving port in recovery; when the flag bit of the interrupted data is pushed to 0, it means that the resource receiving port does not need to push the interrupted data.
4.2)基于配置信息判断是否需要推送中断的数据。4.2) Determine whether the interrupted data needs to be pushed based on the configuration information.
当需要推送中断的数据时,执行4.3);否则,直接向恢复中的资源接收口推送实时数据。When the interrupted data needs to be pushed, execute 4.3); otherwise, directly push the real-time data to the resource receiving port in recovery.
4.3)读取从中断位置至当前位置之间的历史数据。4.3) Read the historical data from the interrupted position to the current position.
在需要进行断点传送时,电子设备可以创建子监听器。子监听器是根据外部系统的资源注册请求的配置信息中指定需要在断点回传时才会被在状态为恢复中时创建以获取历史数据。其中,所述的子监听器是获取资源来源的中断点到最新的实时点之间的历史数据的一个方法。Electronic devices can create sub-listeners when breakpoint teleportation is required. The sub-listener is created according to the configuration information of the resource registration request of the external system and needs to be created when the state is recovering to obtain historical data when the breakpoint is returned. Wherein, the sub-listener is a method for obtaining historical data between the interruption point of the resource source and the latest real-time point.
4.4)将历史数据推送至恢复中的资源接收口,并在推送过程中判断是否出现推送失败。4.4) Push the historical data to the recovering resource receiving port, and judge whether the push fails during the push process.
当没有出现推送失败时,执行步骤4.5);否则,执行步骤4.7)。When there is no push failure, go to step 4.5); otherwise, go to step 4.7).
4.5)将恢复中的资源接收口的状态信息设置为正常。4.5) Set the status information of the resource receiving port in recovery to normal.
电子设备在向恢复中的资源接收口成功推送历史数据时,则将恢复中的资源接收口的状态信息设置为正常。When the electronic device successfully pushes historical data to the resource receiving port in recovery, the state information of the resource receiving port in recovery is set to normal.
4.6)基于正常状态的资源接收口进行对应于正常模式的数据推送。4.6) Push data corresponding to the normal mode based on the resource receiving port in the normal state.
在恢复中模式中可以从中断位置进行中断续传,保证数据不丢失;且在历史数据推送不出现失败时,实现资源接收口的状态从恢复中到正常的流转,为恢复中断的推送数据提供了保障。In the recovering mode, the interrupted and resumed transmission can be performed from the interrupted position to ensure that the data is not lost; and when the historical data push does not fail, the state of the resource receiving port can be transferred from the recovery to the normal flow, which provides the recovery of the interrupted push data. guaranteed.
具体请参见上述S252及其后续步骤的相关描述,在此不再赘述。For details, please refer to the relevant descriptions of the above S252 and subsequent steps, which will not be repeated here.
4.7)将恢复中的资源接收口的状态信息设置为异常,基于异常状态的资源接收口进行对应于异常模式的数据推送。4.7) Set the status information of the resource receiving port in recovery as abnormal, and push the data corresponding to the abnormal mode based on the resource receiving port of the abnormal state.
当电子设备在向恢复中的资源接收口推送历史数据时出现异常,则将恢复中的资源接收口的状态信息设置为异常,然后基于异常状态的资源接收口进行对应于异常模式的数据推送。When an abnormality occurs when the electronic device pushes historical data to the resource receiving port being restored, the state information of the resource receiving port being restored is set as abnormal, and then data push corresponding to the abnormal mode is performed based on the resource receiving port of the abnormal state.
在恢复中模式中,若数据推送出现失败,则直接将该资源接收口的状态设置为异常,不再进行重试,以避免数据传输的多次重试,提高了数据传输的实时性。In the recovering mode, if the data push fails, the state of the resource receiving port is set to be abnormal directly, and no retry is performed, so as to avoid multiple retries of data transmission and improve the real-time performance of data transmission.
(5)将重试状态的资源接收口的状态设置为异常。(5) The state of the resource receiving port in the retry state is set to be abnormal.
当电子设备在向重试状态的资源接收口推送当前推送失败的数据失败时,将重试状态的资源接收口的状态设置为异常。在重试状态的资源接收口在预设条件内并未成功推送当前推送失败的数据时,实现资源接收口从重试到异常的状态流转,为数据的正常推送提供了保障。When the electronic device fails to push the currently failed data to the resource receiving port in the retry state, the state of the resource receiving port in the retry state is set as abnormal. When the resource receiving port in the retry state does not successfully push the data that fails to push the current push within the preset conditions, the resource receiving port is realized from the retry to the abnormal state flow, which provides a guarantee for the normal push of the data.
(6)基于异常状态的资源接收口进行对应于异常模式的数据推送。(6) Push data corresponding to the abnormal mode based on the resource receiving port of the abnormal state.
具体地,上述步骤(6)可以包括步骤,也可以理解为异常模式的数据推送包括如下步骤:Specifically, the above step (6) may include steps, and it may also be understood that the data push of the abnormal mode includes the following steps:
6.1)接收异常状态的资源接收口的状态更新为正常的信息。6.1) The state of the resource receiving port receiving the abnormal state is updated to normal information.
电子设备在确定出资源接收口异常时,可以向外部系统发送告警信息,以使得外部系统对该资源接收口进行相应的处理。在外部系统在对该资源接收口处理完成之后,可以向电子设备发送状态更新信息,以请求将该异常状态的资源接收口的状态更新为正常状态。When the electronic device determines that the resource receiving port is abnormal, it can send alarm information to the external system, so that the external system can perform corresponding processing on the resource receiving port. After the external system finishes processing the resource receiving port, it may send status update information to the electronic device to request to update the state of the resource receiving port in the abnormal state to a normal state.
6.2)判断设置的异常状态的资源接收口的状态是否为异常。6.2) Determine whether the state of the resource receiving port of the set abnormal state is abnormal.
电子设备在接收到外部系统发送的将异常状态的资源接收口的状态更新为正常的信息之后,首先判断在本地存储的该异常状态的资源接收口的状态是否为异常。当设置的异常状态的资源接收口的状态为异常时,执行步骤6.3);否则,执行步骤4.6)。After receiving the information sent by the external system to update the state of the resource receiving port in the abnormal state to normal, the electronic device first determines whether the state of the resource receiving port in the abnormal state stored locally is abnormal. When the state of the resource receiving port of the set abnormal state is abnormal, step 6.3) is performed; otherwise, step 4.6) is performed.
6.3)将异常状态的资源接收口的状态信息设置为恢复中。6.3) Set the status information of the resource receiving port in the abnormal state to recovering.
在电子设备确定出本地所存储的异常状态的资源接收口的状态仍为异常时,电子设备先将其状态信息设置为恢复中。When the electronic device determines that the state of the resource receiving port of the abnormal state stored locally is still abnormal, the electronic device first sets its state information as recovering.
6.4)基于恢复中的资源接收口进行对应于恢复中模式的数据推送。6.4) Based on the resource receiving port in recovery, perform data push corresponding to the mode in recovery.
详细请参见上述步骤(4)的描述,在此不再赘述。For details, please refer to the description of the above step (4), which will not be repeated here.
本实施例提供的数据传输方法,在外部将异常状态的资源接收口的状态更新为正常时,本地并不直接将该资源接收口的状态设置为正 常,而是先将其设置为恢复中,进入异常到恢复中的状态流转,为数据的正常传输提供了保障。In the data transmission method provided by this embodiment, when the state of the resource receiving port in the abnormal state is updated to normal externally, the local does not directly set the state of the resource receiving port to normal, but first sets it to recovering, The state flow from abnormal to recovery provides a guarantee for the normal transmission of data.
内部状态流转机制如图4所示,具体的状态转换规则如下:The internal state flow mechanism is shown in Figure 4, and the specific state transition rules are as follows:
(1)正常状态到重试状态(1) Normal state to retry state
a)多个外部系统可以注册同一个资源类型,内部监听器获取数据后,并行的启动多个主流程推送数据。a) Multiple external systems can register the same resource type. After the internal listener obtains the data, it starts multiple main processes in parallel to push the data.
b)当数据推送出现了异常,变更数据推送异常的外部系统资源接收口的状态为重试(retry)。b) When an exception occurs in the data push, change the status of the external system resource receiving port of the data push exception to retry.
c)主流程停止推送新的实时数据到当前外部系统的资源接收口。c) The main process stops pushing new real-time data to the resource receiving port of the current external system.
d)启动子流程处理重试推送,进入步骤(2)。d) Start the sub-process to retry the push, and go to step (2).
(2)重试状态到异常状态(2) Retry state to abnormal state
a)可以多个子流程并行执行多个外部系统的资源接收口的重试。a) The retry of the resource receiving ports of multiple external systems can be performed in parallel by multiple sub-processes.
b)三次重新尝试推送数据到当前外部系统的资源接收口。b) Retry three times to push data to the resource receiving port of the current external system.
c)当三次重试仍然出现异常,变更资源接收口的状态为异常(anomaly)。c) When an exception still occurs after three retries, change the status of the resource receiving port to anomaly.
d)关闭重试子流程。d) Close the retry subprocess.
(3)重试状态到恢复中状态(3) Retry state to recovering state
a)三次重新尝试推送数据到当前外部系统的资源接收接口。a) Three retries to push data to the resource receiving interface of the current external system.
b)当任何一次推送数据成功,停止重试,变更资源接收接口的状态为恢复中(restoring)。b) When any push data is successful, stop retrying, and change the status of the resource receiving interface to restoring.
c)关闭重试子流程。c) Close the retry subprocess.
(4)异常状态到恢复中状态(4) Abnormal state to recovery state
a)外部系统启动后应通过向电子设备发送更新资源接收口的状态为正常的信息a) After the external system is started, it should update the information that the status of the resource receiving port is normal by sending to the electronic device
b)电子设备接收到资源接收口的状态要变更为正常时,先检查目前数据库中该资源接收口状态是不是正常状态。b) When the electronic device receives that the state of the resource receiving port is to be changed to normal, first check whether the state of the resource receiving port in the current database is normal.
c)如果数据库中的该资源接收口是正常状态,则不作任何处理。c) If the resource receiving port in the database is in a normal state, do nothing.
d)如果数据库中的该资源接收口是异常状态,则先不更新为正常状态,先更新为恢复中(restoring)。d) If the resource receiving port in the database is in an abnormal state, it is not updated to a normal state first, but is updated to a restoring state first.
e)启动恢复流程,进入步骤(5)和(6)。e) Start the recovery process and go to steps (5) and (6).
(5)恢复中状态到重试状态(5) Restoring state to retry state
a)读取所有资源接收口状态为恢复中(restoring)的资源接收口配置信息。a) Read the configuration information of all resource receiving ports whose state is restoring (restoring).
b)根据是否需要恢复中断数据开启恢复子流程推送中断的数据。b) Start the recovery sub-process to push the interrupted data according to whether it is necessary to restore the interrupted data.
c)在推送中断的数据时发生异常,不再重试,立即变更资源接收口的状态为异常(anomaly),关闭中断数据恢复子流程,子流程中包括子监听器。c) An exception occurs when the interrupted data is pushed, no retry is required, the state of the resource receiving port is immediately changed to anomaly, and the interrupted data recovery sub-process is closed, and the sub-process includes a sub-listener.
d)重复步骤(5)。d) Repeat step (5).
(6)恢复中状态到正常状态(6) Restoring state to normal state
a)读取所有资源接收口状态为恢复中(restoring)的资源接收口配置信息。a) Read the configuration information of all resource receiving ports whose state is restoring (restoring).
b)根据需要推送中断的数据。b) Push the interrupted data as needed.
c)所有中断的数据推送完毕没有异常,则变更状态为正常(normal)。c) All interrupted data are pushed and there is no abnormality, then the change state is normal.
d)关闭恢复流程。d) Close the recovery process.
在本实施例中提供了一种数据传输方法,可用于上述的电子设备,如服务器、电脑、平板电脑等,图5是根据本发明实施例的数据传输方法的流程图,如图5所示,该流程包括如下步骤:In this embodiment, a data transmission method is provided, which can be used for the above-mentioned electronic devices, such as servers, computers, tablet computers, etc. FIG. 5 is a flowchart of the data transmission method according to an embodiment of the present invention, as shown in FIG. 5 . , the process includes the following steps:
S31,提供本地开放的资源类型。S31, providing a locally open resource type.
所述资源类型与资源来源对应。The resource type corresponds to the resource source.
详细请参见图3所示实施例的S21,在此不再赘述。For details, please refer to S21 of the embodiment shown in FIG. 3 , which will not be repeated here.
S32,接收对目标资源类型的至少一个资源注册请求。S32: Receive at least one resource registration request for the target resource type.
所述资源注册请求与资源接收口对应,其中,资源注册请求携带 有配置信息,该配置信息包括资源接收口的数据过滤条件。The resource registration request corresponds to the resource receiving port, wherein the resource registration request carries configuration information, and the configuration information includes data filtering conditions of the resource receiving port.
详细请参见图3所示实施例的S22,在此不再赘述。For details, please refer to S22 of the embodiment shown in FIG. 3 , which will not be repeated here.
S33,基于资源注册请求,确定目标资源类型对应的目标资源来源。S33, based on the resource registration request, determine the target resource source corresponding to the target resource type.
详细请参见图3所示实施例的S23,在此不再赘述。For details, please refer to S23 of the embodiment shown in FIG. 3 , which will not be repeated here.
S34,从目标资源来源中提取出实时数据。S34, extracting real-time data from the target resource source.
详细请参见图3所示实施例的S24,在此不再赘述。For details, please refer to S24 of the embodiment shown in FIG. 3 , which will not be repeated here.
S35,向至少一个资源接收口推送实时数据。S35, push real-time data to at least one resource receiving port.
具体地,上述S35包括如下步骤:Specifically, the above S35 includes the following steps:
S351,利用数据过滤条件对实时数据进行过滤。S351 , filtering the real-time data by using the data filtering condition.
电子设备基于各个资源注册请求的配置信息中的数据过滤条件,对提取出的实时数据进行过滤。The electronic device filters the extracted real-time data based on the data filtering conditions in the configuration information of each resource registration request.
S352,向至少一个资源接收口推送过滤后的实时数据。S352: Push the filtered real-time data to at least one resource receiving port.
对于过滤后的实时数据,电子设备可以依据各个资源接收口的状态信息,向其推送实时数据。详细请参见图3所示实施例的S25,在此不再赘述。For the filtered real-time data, the electronic device can push real-time data to it according to the status information of each resource receiving port. For details, please refer to S25 of the embodiment shown in FIG. 3 , which will not be repeated here.
其中,若过滤后的实时数据为空,在不需要向对应的资源接收口推送数据;若过滤后的实时数据不为空,则就需要依据各个资源接收口的状态信息向其推送过滤后的实时数据。Among them, if the filtered real-time data is empty, it is not necessary to push the data to the corresponding resource receiving port; if the filtered real-time data is not empty, it is necessary to push the filtered data to the corresponding resource receiving port according to the status information of each resource receiving port. Real-time data.
本实施例提供的数据传输方法,在实时数据传输之前先对其进行过滤,以使得传输的实时数据能够满足外部的需求。In the data transmission method provided in this embodiment, the real-time data is filtered before the real-time data is transmitted, so that the transmitted real-time data can meet external requirements.
作为本发明实施例的一种具体实施方式,如图6所示,所述的数据传输方法包括如下处理流程:As a specific implementation of the embodiment of the present invention, as shown in FIG. 6 , the data transmission method includes the following processing flow:
(1)资源映射:将资源来源映射成资源类型。(1) Resource mapping: Map resource sources to resource types.
a)电子设备需要对外开放数据,它将调用接口将资源来源与资源类型绑定。a) The electronic device needs to open data to the outside world, and it will call the interface to bind the resource source with the resource type.
b)资源映射部件将负责创建两者的对应关系。b) The resource mapping component will be responsible for creating the corresponding relationship between the two.
(2)资源类型公告:告诉外部系统目前可提供哪些资源类型在注册时使用。(2) Resource type announcement: Tell the external system which resource types are currently available for use during registration.
(3)所需资源注册与状态更新:外部系统根据所需资源类型进行注册以及状态更新操作。(3) Required resource registration and status update: The external system performs registration and status update operations according to the required resource type.
a)外部系统获取电子设备的权限。a) Permissions for external systems to obtain electronic devices.
b)外部系统调用电子设备对外开放的注册接口,并提供注册的资源类型、资源接收口信息、资源接收口的状态(每次外部系统重新启动好就要立即更新接收地址的状态)、推送类型名称(可以采用HTTP形式推送,可以扩展)、是否需要重新推送中断的数据的标记、每次重新推送中断的消息的数量、数据过滤条件。c)外部系统重启后需要调用开放平台对外开放的状态更新接口更新资源接收口的状态。外部系统发送的资源注册请求将被存入数据库和缓存供内部状态流转机制使用。b) The external system calls the registration interface opened by the electronic device, and provides the registered resource type, resource receiving port information, and the status of the resource receiving port (the status of the receiving address will be updated immediately every time the external system is restarted), push type Name (it can be pushed in the form of HTTP, and can be extended), whether it is necessary to re-push interrupted data, the number of interrupted messages per re-push, and data filter conditions. c) After the external system restarts, the state update interface opened by the open platform needs to be called to update the state of the resource receiving port. The resource registration request sent by the external system will be stored in the database and cache for use by the internal state flow mechanism.
(4)资源监听器:根据外部系统所注册需要的资源类型进行监听映射的数据来源,从资源来源中实时获取所需的数据,发给过滤器处理。(4) Resource listener: monitor the data source of the mapping according to the resource type registered by the external system, obtain the required data from the resource source in real time, and send it to the filter for processing.
a)使用轮循方式检测缓存中需要处理的资源类型。a) Use a round-robin approach to detect the type of resources that need to be processed in the cache.
b)为外部系统指定的资源类型创建各自的监听器,监听器对资源类型映射的数据来源进行监听。b) Create respective listeners for the resource types specified by the external system, and the listeners monitor the data sources mapped by the resource types.
c)一旦监听到有任何新实时数据,将实时数据发送给过滤器处理。c) Once any new real-time data is monitored, the real-time data is sent to the filter for processing.
(5)过滤器:根据外部系统的需求过滤不需要的实时数据。(5) Filter: Filter unnecessary real-time data according to the needs of external systems.
a)从缓存中获取外部系统的配置信息。a) Get the configuration information of the external system from the cache.
b)根据外部系统配置的过滤条件过滤实时数据。b) Filter the real-time data according to the filter conditions configured by the external system.
c)如果实时数据在过滤后还需要推送,则交给数据分发处理。c) If the real-time data needs to be pushed after filtering, it will be handed over to the data distribution process.
d)如果实时数据在过滤后无需推送,则抛弃不作推送处理。d) If the real-time data does not need to be pushed after filtering, it will be discarded and not pushed.
(6)数据分发处理:对需要发送的数据进行封装成固定结构的数据发给内部状态流转机制处理。(6) Data distribution processing: encapsulate the data to be sent into a fixed structure and send it to the internal state flow mechanism for processing.
a)将实时数据封装成固定格式的消息,可以是JSON,前提是要和外部系统协商好通讯数据的格式。消息根据需要进行hash或加密以防篡改或采用https协议推送,同样也需要与外部系统协商。a) Encapsulate the real-time data into a fixed-format message, which can be JSON, provided that the format of the communication data is negotiated with the external system. Messages are hashed or encrypted as needed to prevent tampering or pushed using the https protocol, which also needs to be negotiated with external systems.
b)从缓存中获取所有需要当前资源类型的数据的外部系统的资源接收口信息。b) Obtain the resource receiving port information of all external systems that need data of the current resource type from the cache.
c)将所有要处理的实时数据按资源接收口进行分类组装成传输数据,交给内部状态流转机制处理。c) Classify and assemble all the real-time data to be processed into transmission data according to the resource receiving port, and hand it over to the internal state transfer mechanism for processing.
(7)内部状态流转机制:用于正常推送、异常重试、异常恢复三种情况时的状态转换。转换规则:正常(normal)->重试(retry)->异常(anomaly)->恢复中(restoring)。(7) Internal state transfer mechanism: It is used for state transition in three cases: normal push, abnormal retry, and abnormal recovery. Conversion rules: normal->retry->anomaly->restoring.
a)对数据分发处理后的数据会带有指定的资源接收口信息,对资源接收口的状态进行过滤。a) The data after data distribution and processing will carry the specified resource receiving port information, and filter the status of the resource receiving port.
b)如果资源接收口状态是正常(normal),收集资源接收口的状态是正常(normal)的接口信息,则进入步骤(8)处理。b) If the state of the resource receiving port is normal, and collecting the interface information that the state of the resource receiving port is normal (normal), the process proceeds to step (8).
c)如果资源接收口状态是异常(anomaly),则抛弃不处理。c) If the status of the resource receiving port is abnormal (anomaly), it will be discarded and not processed.
d)如果资源接收口状态是恢复中(restoring),则进入步骤(11)。d) If the state of the resource receiving port is restoring, go to step (11).
(8)数据推送:将数据推送到外部系统指定的资源接收口。(8) Data push: push data to the resource receiving port designated by the external system.
a)采用多线程并行发送消息到各个外部系统对应的资源接收口。a) Using multi-threads to send messages to the corresponding resource receiving ports of each external system in parallel.
b)如果有任何一条线程推送出现了异常,则进入步骤(9)。b) If an exception occurs in any thread push, go to step (9).
c)没有异常则本次处理结束,再次进入步骤(4)。c) If there is no abnormality, the current processing ends, and the step (4) is entered again.
(9)异常重试:对有异常的推送再次推送信息,尝试3次。(9) Abnormal retry: Push the information again for the abnormal push, and try 3 times.
a)将数据推送有异常的资源接收口设置资源接收口的状态为重试(retry)。当设置为重试的资源接收口将停止主线的实时数据推送。a) Push the data to the resource receiving port with an exception and set the state of the resource receiving port to retry (retry). When the resource receiving port is set to retry, the real-time data push of the main line will be stopped.
b)另开线程尝试再次推送当前发送失败的数据到外部系统的资 源接收口,尝试3次。b) Open another thread and try to push the currently failed data to the resource receiving port of the external system again, and try 3 times.
c)如果成功,则设置资源接收口的状态为恢复中(restoring),则进入步骤(11)。c) If successful, set the state of the resource receiving port as restoring, and then go to step (11).
d)如果尝试后还是失败,则设置资源接收口的状态为异常(anomaly),并记录异常中断的数据位置,然后中断处理,等待外部系统调用状态更新进行状态恢复。d) If it still fails after the attempt, set the state of the resource receiving port to abnormal (anomaly), and record the data location of the abnormal interruption, then interrupt the processing, and wait for the external system call state update to restore the state.
(10)异常信息:管理员可以通过接口查看所有异常的推送信息。(10) Abnormal information: The administrator can view all abnormal push information through the interface.
(11)异常恢复:对异常的资源接收口的状态进行恢复。(11) Abnormal recovery: recover the state of the abnormal resource receiving port.
a)读取所有资源接收口状态为恢复中(restoring)的资源接收口配置信息a) Read the configuration information of all resource receiving ports whose status is restoring
b)根据配置是否需要推送中断的数据,如需要,则进入步骤(12)。b) Whether the interrupted data needs to be pushed according to the configuration, if necessary, go to step (12).
c)如无需推送中断的数据,则推送当前的实时数据,推送成功,资源接收口的状态从恢复中(restoring)到正常(normal)。c) If there is no need to push the interrupted data, the current real-time data is pushed, the push is successful, and the state of the resource receiving port changes from restoring to normal.
d)销毁当前子线资源监听器,以便共用主线资源监听器继续监听实时数据。d) Destroy the current sub-line resource listener so that the shared main-line resource listener can continue to monitor real-time data.
(12)断点续传:按需中断续传中断的数据。(12) Breakpoint resume: Interrupt and resume the interrupted data on demand.
a)创建子线资源监听器;a) Create a sub-line resource listener;
b)从异常中断的位置开始读取相应的数据;b) Read the corresponding data from the position of the abnormal interruption;
c)按指定的每次推送的数据量推送数据到外部系统的资源接收口,并记录每次成功推送的位置,直到追上目前最新的实时数据;c) Push data to the resource receiving port of the external system according to the specified amount of data pushed each time, and record the position of each successful push until it catches up with the latest real-time data;
d)如果在推送中断的数据过程中出现了异常,进入步骤(9);d) If an exception occurs in the process of pushing the interrupted data, go to step (9);
e)如果从中断位置到目前实时最新的位置的数据都已经推送完毕,并且没有异常出现,则变更资源接收口的状态从恢复中(restoring)到正常(normal)。e) If the data from the interrupted position to the latest real-time position has been pushed and no exception occurs, change the state of the resource receiving port from restoring to normal.
本实施例提供的数据传输方法的有益效果在于:The beneficial effects of the data transmission method provided by this embodiment are:
(1)将不同种类的开放数据源抽象成资源类型,外部系统只知 资源类型而不知具体的内部数据源,从而易于切换内部数据来源,不必在开放平台提供对外开放接口,外部系统感知不到数据源的变化,内部迁移扩展方便。(1) Different types of open data sources are abstracted into resource types. The external system only knows the resource type but does not know the specific internal data source, so it is easy to switch the internal data source. It is not necessary to provide an open interface on the open platform, and the external system cannot perceive it. Changes in data sources, internal migration and expansion are convenient.
(2)电子设备资源监听器实时监听数据,提供对数据进行过滤的功能,并行分发推送数据到多个外部系统,从而降低外部系统对内部服务器的请求压力,数据能实时推送,除非接口异常则中断推送,也有数据中断续传可供选择,保证数据不丢失。(2) The electronic device resource monitor monitors data in real time, provides the function of filtering data, distributes and pushes data to multiple external systems in parallel, thereby reducing the request pressure of external systems on internal servers, and data can be pushed in real time unless the interface is abnormal. Interrupted push, there are also options for data interrupted and resumed transmission, to ensure that data is not lost.
(3)电子设备对实时推送数据发生异常时会记录异常信息,便于管理员快速排查异常问题以便指导外部系统和电子设备修复相关问题。(3) The electronic device will record the abnormal information when the real-time push data is abnormal, which is convenient for the administrator to quickly check the abnormal problem and guide the external system and electronic device to repair related problems.
(4)内部状态流转机制为异常重试和恢复中断的推送数据提供了保障。(4) The internal state transfer mechanism provides a guarantee for abnormal retry and recovery of interrupted push data.
(5)此方案不与任何软件捆绑,从而易于扩展软件功能。如需增加一种抽象的资源类型,仅需配置数据来源与资源类型的映射而无需关注实时推送相关的处理。如果当前监听器不能处理该资源类型,通过扩展实现一个符合要求的监听器即可。(5) This solution is not bundled with any software, so it is easy to expand software functions. To add an abstract resource type, you only need to configure the mapping between data sources and resource types without paying attention to the processing related to real-time push. If the current listener cannot handle the resource type, you can implement a listener that meets the requirements by extension.
在本实施例中还提供了一种数据传输装置,该装置用于实现上述实施例及优选实施方式,已经进行过说明的不再赘述。如以下所使用的,术语“模块”可以实现预定功能的软件和/或硬件的组合。尽管以下实施例所描述的装置较佳地以软件来实现,但是硬件,或者软件和硬件的组合的实现也是可能并被构想的。In this embodiment, a data transmission apparatus is also provided, and the apparatus is used to implement the above-mentioned embodiments and preferred implementations, and what has been described will not be repeated. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, implementations in hardware, or a combination of software and hardware, are also possible and contemplated.
本实施例提供一种数据传输装置,如图7所示,包括:This embodiment provides a data transmission device, as shown in FIG. 7 , including:
提供模块41,用于提供本地开放的资源类型,所述资源类型与资源来源对应;a providing module 41, configured to provide a locally open resource type, the resource type corresponding to the source of the resource;
接收模块42,用于接收对目标资源类型的至少一个资源注册请求,所述资源注册请求与资源接收口对应;a receiving module 42, configured to receive at least one resource registration request for the target resource type, the resource registration request corresponding to the resource receiving port;
确定模块43,用于基于所述资源注册请求,确定所述目标资源 类型对应的目标资源来源;Determining module 43, for determining the target resource source corresponding to the target resource type based on the resource registration request;
提取模块44,用于从所述目标资源来源中提取出实时数据; Extraction module 44, for extracting real-time data from the target resource source;
推送模块45,用于向至少一个所述资源接收口推送所述实时数据。The push module 45 is configured to push the real-time data to at least one of the resource receiving ports.
本实施例提供的数据传输装置,利用资源类型与资源来源的对应关系,确定目标资源类型对应的目标资源来源,即可从目标资源来源中提取出实时数据并推送给资源接收口,从而达到数据实时推送的目的,且利用资源类型来共用同一条实时推送机制,以避免给外部提供多个数据接口,以逆向反转推送来避免外部请求过多导致服务器的压力增大,提高了数据传输的实时性。The data transmission device provided in this embodiment uses the corresponding relationship between resource types and resource sources to determine the target resource source corresponding to the target resource type, so that real-time data can be extracted from the target resource source and pushed to the resource receiving port, so as to achieve data The purpose of real-time push is to use resource types to share the same real-time push mechanism to avoid providing multiple data interfaces to the outside world. Reverse push is used to avoid excessive external requests and increase the pressure on the server, which improves the efficiency of data transmission. real-time.
本实施例中的数据传输装置是以功能单元的形式来呈现,这里的单元是指ASIC电路,执行一个或多个软件或固定程序的处理器和存储器,和/或其他可以提供上述功能的器件。The data transmission apparatus in this embodiment is presented in the form of functional units, where units refer to ASIC circuits, processors and memories that execute one or more software or fixed programs, and/or other devices that can provide the above functions .
上述各个模块的更进一步的功能描述与上述对应实施例相同,在此不再赘述。Further functional descriptions of the above-mentioned modules are the same as those of the above-mentioned corresponding embodiments, and are not repeated here.
本发明实施例还提供一种电子设备,具有上述图7所示的数据传输装置。An embodiment of the present invention further provides an electronic device having the data transmission device shown in FIG. 7 .
请参阅图8,图8是本发明可选实施例提供的一种电子设备的结构示意图,如图8所示,该电子设备可以包括:至少一个处理器51,例如CPU(Central Processing Unit,中央处理器),至少一个通信接口53,存储器54,至少一个通信总线52。其中,通信总线52用于实现这些组件之间的连接通信。其中,通信接口53可以包括显示屏(Display)、键盘(Keyboard),可选通信接口53还可以包括标准的有线接口、无线接口。存储器54可以是高速RAM存储器(Random Access Memory,易挥发性随机存取存储器),也可以是非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。存储器54 可选的还可以是至少一个位于远离前述处理器51的存储装置。其中处理器51可以结合图7所描述的装置,存储器54中存储应用程序,且处理器51调用存储器54中存储的程序代码,以用于执行上述任一方法步骤。Please refer to FIG. 8. FIG. 8 is a schematic structural diagram of an electronic device provided by an optional embodiment of the present invention. As shown in FIG. 8, the electronic device may include: at least one processor 51, such as a CPU (Central Processing Unit, central processing unit). processor), at least one communication interface 53, memory 54, at least one communication bus 52. Among them, the communication bus 52 is used to realize the connection and communication between these components. The communication interface 53 may include a display screen (Display) and a keyboard (Keyboard), and the optional communication interface 53 may also include a standard wired interface and a wireless interface. The memory 54 may be a high-speed RAM memory (Random Access Memory, volatile random access memory), or may be a non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 54 can optionally also be at least one storage device located away from the aforementioned processor 51 . The processor 51 may be combined with the device described in FIG. 7 , the memory 54 stores application programs, and the processor 51 calls the program codes stored in the memory 54 for executing any of the above method steps.
其中,通信总线52可以是外设部件互连标准(peripheral component interconnect,简称PCI)总线或扩展工业标准结构(extended industry standard architecture,简称EISA)总线等。通信总线52可以分为地址总线、数据总线、控制总线等。为便于表示,图8中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The communication bus 52 may be a peripheral component interconnect (PCI for short) bus or an extended industry standard architecture (EISA for short) bus or the like. The communication bus 52 can be divided into an address bus, a data bus, a control bus, and the like. For ease of presentation, only one thick line is used in FIG. 8, but it does not mean that there is only one bus or one type of bus.
其中,存储器54可以包括易失性存储器(英文:volatile memory),例如随机存取存储器(英文:random-access memory,缩写:RAM);存储器也可以包括非易失性存储器(英文:non-volatile memory),例如快闪存储器(英文:flash memory),硬盘(英文:hard disk drive,缩写:HDD)或固态硬盘(英文:solid-state drive,缩写:SSD);存储器54还可以包括上述种类的存储器的组合。The memory 54 may include volatile memory (English: volatile memory), such as random-access memory (English: random-access memory, abbreviation: RAM); the memory may also include non-volatile memory (English: non-volatile memory) memory), such as flash memory (English: flash memory), hard disk (English: hard disk drive, abbreviation: HDD) or solid-state hard disk (English: solid-state drive, abbreviation: SSD); the memory 54 may also include the above types of combination of memory.
其中,处理器51可以是中央处理器(英文:central processing unit,缩写:CPU),网络处理器(英文:network processor,缩写:NP)或者CPU和NP的组合。The processor 51 may be a central processing unit (English: central processing unit, abbreviation: CPU), a network processor (English: network processor, abbreviation: NP), or a combination of CPU and NP.
其中,处理器51还可以进一步包括硬件芯片。上述硬件芯片可以是专用集成电路(英文:application-specific integrated circuit,缩写:ASIC),可编程逻辑器件(英文:programmable logic device,缩写:PLD)或其组合。上述PLD可以是复杂可编程逻辑器件(英文:complex programmable logic device,缩写:CPLD),现场可编程逻辑门阵列(英文:field-programmable gate array,缩写:FPGA),通用阵列逻辑(英文:generic array logic,缩写:GAL)或其任意组合。The processor 51 may further include a hardware chip. The above-mentioned hardware chip may be an application-specific integrated circuit (English: application-specific integrated circuit, abbreviation: ASIC), a programmable logic device (English: programmable logic device, abbreviation: PLD) or a combination thereof. The above-mentioned PLD can be a complex programmable logic device (English: complex programmable logic device, abbreviation: CPLD), field programmable logic gate array (English: field-programmable gate array, abbreviation: FPGA), general array logic (English: generic array logic, abbreviation: GAL) or any combination thereof.
可选地,存储器54还用于存储程序指令。处理器51可以调用程序指令,实现如本申请图2、3以及5实施例中所示的数据传输方法。Optionally, memory 54 is also used to store program instructions. The processor 51 may invoke program instructions to implement the data transmission methods shown in the embodiments of FIGS. 2 , 3 and 5 of the present application.
本发明实施例还提供了一种非暂态计算机存储介质,所述计算机存储介质存储有计算机可执行指令,该计算机可执行指令可执行上述任意方法实施例中的数据传输方法。其中,所述存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)、随机存储记忆体(Random Access Memory,RAM)、快闪存储器(Flash Memory)、硬盘(Hard Disk Drive,缩写:HDD)或固态硬盘(Solid-State Drive,SSD)等;所述存储介质还可以包括上述种类的存储器的组合。An embodiment of the present invention further provides a non-transitory computer storage medium, where the computer storage medium stores computer-executable instructions, and the computer-executable instructions can execute the data transmission method in any of the foregoing method embodiments. Wherein, the storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a flash memory (Flash Memory), a hard disk (Hard) Disk Drive, abbreviation: HDD) or solid-state drive (Solid-State Drive, SSD), etc.; the storage medium may also include a combination of the above-mentioned types of memories.
虽然结合附图描述了本发明的实施例,但是本领域技术人员可以在不脱离本发明的精神和范围的情况下做出各种修改和变型,这样的修改和变型均落入由所附权利要求所限定的范围之内。Although the embodiments of the present invention have been described with reference to the accompanying drawings, various modifications and variations can be made by those skilled in the art without departing from the spirit and scope of the present invention, and such modifications and variations fall within the scope of the appended claims within the limits of the requirements.

Claims (13)

  1. 一种数据传输方法,其特征在于,包括:A data transmission method, comprising:
    提供本地开放的资源类型,所述资源类型与资源来源对应;Provide a locally open resource type, the resource type corresponds to the source of the resource;
    接收对至少一个目标资源类型的资源注册请求,所述资源注册请求与资源接收口对应;receiving a resource registration request for at least one target resource type, where the resource registration request corresponds to a resource receiving port;
    基于所述资源注册请求,确定所述目标资源类型对应的目标资源来源;determining a target resource source corresponding to the target resource type based on the resource registration request;
    从所述目标资源来源中提取出实时数据;extracting real-time data from the target resource source;
    向至少一个所述资源接收口推送所述实时数据。Pushing the real-time data to at least one of the resource receiving ports.
  2. 根据权利要求1所述的方法,其特征在于,所述向至少一个所述资源接收口推送所述实时数据,包括:The method according to claim 1, wherein the pushing the real-time data to at least one of the resource receiving ports comprises:
    基于所述资源注册请求,确定所述至少一个资源接收口的状态信息,所述状态信息包括正常、重试、异常以及恢复中的一种;determining, based on the resource registration request, status information of the at least one resource receiving port, where the status information includes one of normal, retry, abnormal, and recovery;
    根据所述至少一个资源接收口的状态信息,向至少一个所述资源接收口推送所述实时数据。The real-time data is pushed to the at least one resource receiving port according to the state information of the at least one resource receiving port.
  3. 根据权利要求2所述的方法,其特征在于,所述根据至少一个所述资源接收口的状态信息,向至少一个所述资源接收口推送所述实时数据,包括:The method according to claim 2, wherein the pushing the real-time data to at least one of the resource receiving ports according to the state information of the at least one resource receiving port comprises:
    收集资源接收口的状态信息为正常状态的资源接收口;The state information of the collected resource receiving port is the resource receiving port in the normal state;
    利用至少一个线程将所述实时数据并行推送给正常状态的资源接收口;Utilize at least one thread to push the real-time data to the normal resource receiving port in parallel;
    判断预设线程的推送是否异常;Determine whether the push of the preset thread is abnormal;
    当所述预设线程的推送异常时,停止所述预设线程的实时数据推送并将所述预设线程对应的资源接收口的状态信息设置为重试;When the push of the preset thread is abnormal, stop the real-time data push of the preset thread and set the status information of the resource receiving port corresponding to the preset thread to retry;
    基于重试状态的资源接收口进行对应于重试模式的数据推送;The resource receiving port based on the retry state performs data push corresponding to the retry mode;
    或,or,
    所述根据至少一个所述资源接收口的状态信息,向至少一个所述资源接收口推送所述实时数据,包括:The pushing the real-time data to at least one of the resource receiving ports according to the state information of the at least one resource receiving port includes:
    收集资源接收口的状态信息为重试状态的资源接收口;Collecting the status information of the resource receiving port is the resource receiving port in the retry state;
    停止向所述重试状态的资源接收口推送实时数据并将所述资源接收口的状态信息设置为重试;Stop pushing real-time data to the resource receiving port in the retry state and set the state information of the resource receiving port to retry;
    基于重试状态的资源接收口进行对应于重试模式的数据推送。The resource receiving port in the retry state performs data push corresponding to the retry mode.
  4. 根据权利要求3所述的方法,其特征在于,所述基于重试状态的资源接收口进行对应于重试模式的数据推送,包括:The method according to claim 3, wherein the data push corresponding to the retry mode is performed by the resource receiving port based on the retry state, comprising:
    另开线程向所述重试状态的资源接收口再次推送当前推送失败的数据;Open another thread to push the currently failed data to the resource receiving port in the retry state again;
    判断在预设条件内向所述重试状态的资源接收口是否成功推送所述当前推送失败的数据;judging whether the data of the current push failure is successfully pushed to the resource receiving port in the retry state within a preset condition;
    当在预设条件内向所述重试状态的资源接收口成功推送所述当前推送失败的数据时,将所述重试状态的资源接收口的状态信息设置为恢复中;When successfully pushing the currently failed data to the resource receiving port in the retry state within the preset condition, setting the state information of the resource receiving port in the retry state as recovering;
    基于所述恢复中的资源接收口进行对应于恢复中模式的数据推送;Perform data push corresponding to the mode in recovery based on the resource receiving port in recovery;
    或,or,
    当在预设条件内向所述重试状态的资源接收口并未成功推送所述当前推送失败的数据时,将所述重试状态的资源接收口的状态设置为异常;When the data of the current push failure is not successfully pushed to the resource receiving port in the retry state within the preset condition, setting the state of the resource receiving port in the retry state as abnormal;
    基于异常状态的资源接收口进行对应于异常模式的数据推送。The resource receiving port based on the abnormal state performs data push corresponding to the abnormal mode.
  5. 根据权利要求2所述的方法,其特征在于,所述根据至少一个所述资源接收口的状态信息,向至少一个所述资源接收口推送所述实时数据,包括:The method according to claim 2, wherein the pushing the real-time data to at least one of the resource receiving ports according to the state information of the at least one resource receiving port comprises:
    收集资源接收口的状态信息为恢复中的资源接收口;Collecting the status information of the resource receiving port is the resource receiving port being restored;
    基于所述恢复中的资源接收口进行对应于恢复中模式的数据推送。Data push corresponding to the mode in recovery is performed based on the resource receiving port in recovery.
  6. 根据权利要求4或5所述的方法,其特征在于,所述资 源注册请求中还携带有配置信息,所述基于所述恢复中的资源接收口进行对应于恢复中模式的数据推送,包括:The method according to claim 4 or 5, wherein the resource registration request also carries configuration information, and the data push corresponding to the mode in recovery is performed based on the resource receiving port in the recovery, including:
    提取所述恢复中的资源接收口的配置信息;extracting the configuration information of the resource receiving port in the restoration;
    基于所述配置信息判断是否需要推送中断的数据;Determine whether the interrupted data needs to be pushed based on the configuration information;
    当需要推送中断的数据时,读取从中断位置至当前位置之间的历史数据;When the interrupted data needs to be pushed, read the historical data from the interrupted position to the current position;
    将所述历史数据推送至所述恢复中的资源接收口,并在推送过程中判断是否出现推送失败;Pushing the historical data to the resource receiving port in the restoration, and judging whether the push fails during the pushing process;
    当没有出现推送失败时,将所述恢复中的资源接收口的状态信息设置为正常;When there is no push failure, set the status information of the resource receiving port in the recovery to normal;
    基于正常状态的资源接收口进行对应于正常模式的数据推送。The data push corresponding to the normal mode is performed based on the resource receiving port in the normal state.
  7. 根据权利要求6所述的方法,其特征在于,所述基于所述恢复中的资源接收口进行对应于恢复中模式的数据推送,包括:The method according to claim 6, wherein the performing data push corresponding to the mode in recovery based on the resource receiving port in recovery comprises:
    当出现推送失败时,将所述恢复中的资源接收口的状态信息设置为异常,基于异常状态的资源接收口进行对应于异常模式的数据推送。When a push failure occurs, the state information of the resource receiving port in the restoration is set to be abnormal, and the resource receiving port based on the abnormal state performs data push corresponding to the abnormal mode.
  8. 根据权利要求2所述的方法,其特征在于,所述根据至少一个所述资源接收口的状态信息,向至少一个所述资源接收口推送所述实时数据,包括:The method according to claim 2, wherein the pushing the real-time data to at least one of the resource receiving ports according to the state information of the at least one resource receiving port comprises:
    收集资源接收口的状态信息为异常状态的资源接收口;The state information of the collected resource receiving port is the resource receiving port in an abnormal state;
    基于异常状态的资源接收口进行对应于异常模式的数据推送。The resource receiving port based on the abnormal state performs data push corresponding to the abnormal mode.
  9. 根据权利要求4或7或8所述的方法,其特征在于,所述基于异常状态的资源接收口进行对应于异常模式的数据推送,包括:The method according to claim 4, 7 or 8, wherein the abnormal state-based resource receiving port performs data push corresponding to the abnormal mode, comprising:
    接收所述异常状态的资源接收口的状态更新为正常的信息;The state of the resource receiving port receiving the abnormal state is updated to normal information;
    判断设置的所述异常状态的资源接收口的状态是否为异常;Determine whether the state of the set resource receiving port of the abnormal state is abnormal;
    当设置的所述异常状态的资源接收口的状态为异常时,将所述异常状态的资源接收口的状态信息设置为恢复中;When the set state of the resource receiving port in the abnormal state is abnormal, setting the state information of the resource receiving port in the abnormal state as recovering;
    基于恢复中的资源接收口进行对应于恢复中模式的数据推送。Data push corresponding to the mode in recovery is performed based on the resource receiving port in recovery.
  10. 根据权利要求2所述的方法,其特征在于,所述资源注册请求携带有配置信息,所述配置信息包括数据过滤条件,所述根据至少一个所述资源接收口的状态信息,向至少一个所述资源接收口推送所述实时数据,包括:The method according to claim 2, wherein the resource registration request carries configuration information, and the configuration information includes data filtering conditions, and the request is sent to at least one of the resource receiving ports according to status information of at least one of the resource receiving ports. The resource receiving port pushes the real-time data, including:
    利用所述数据过滤条件对所述实时数据进行过滤;Filter the real-time data by using the data filter condition;
    基于至少一个所述资源接收口的状态信息,向至少一个所述资源接收口推送过滤后的实时数据。Based on the state information of the at least one resource receiving port, the filtered real-time data is pushed to the at least one resource receiving port.
  11. 一种数据传输装置,其特征在于,包括:A data transmission device, comprising:
    提供模块,用于提供本地开放的资源类型,所述资源类型与资源来源对应;providing a module for providing a locally open resource type, the resource type corresponding to the resource source;
    接收模块,用于接收对至少一个目标资源类型的资源注册请求,所述资源注册请求与资源接收口对应;a receiving module, configured to receive a resource registration request for at least one target resource type, where the resource registration request corresponds to a resource receiving port;
    确定模块,用于基于所述资源注册请求,确定所述目标资源类型对应的目标资源来源;a determining module, configured to determine the target resource source corresponding to the target resource type based on the resource registration request;
    提取模块,用于从所述目标资源来源中提取出实时数据;an extraction module, for extracting real-time data from the target resource source;
    推送模块,用于向至少一个所述资源接收口推送所述实时数据。A push module, configured to push the real-time data to at least one of the resource receiving ports.
  12. 一种电子设备,其特征在于,包括:An electronic device, comprising:
    存储器和处理器,所述存储器和所述处理器之间互相通信连接,所述存储器中存储有计算机指令,所述处理器通过执行所述计算机指令,从而执行权利要求1-10中任一项所述的数据传输方法。A memory and a processor, the memory and the processor are connected in communication with each other, the memory stores computer instructions, and the processor executes any one of claims 1-10 by executing the computer instructions the described data transmission method.
  13. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机指令,所述计算机指令用于使计算机执行权利要求1-10中任一项所述的数据传输方法。A computer-readable storage medium, characterized in that, the computer-readable storage medium stores computer instructions, and the computer instructions are used to cause a computer to execute the data transmission method according to any one of claims 1-10.
PCT/CN2021/082757 2020-09-22 2021-03-24 Data transmission method and apparatus, and electronic device and storage medium WO2022062347A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011003844.3 2020-09-22
CN202011003844.3A CN112134951A (en) 2020-09-22 2020-09-22 Data transmission method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2022062347A1 true WO2022062347A1 (en) 2022-03-31

Family

ID=73842463

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/082757 WO2022062347A1 (en) 2020-09-22 2021-03-24 Data transmission method and apparatus, and electronic device and storage medium

Country Status (2)

Country Link
CN (1) CN112134951A (en)
WO (1) WO2022062347A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112134951A (en) * 2020-09-22 2020-12-25 睿视(苏州)视频科技有限公司 Data transmission method and device, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107015996A (en) * 2016-01-28 2017-08-04 阿里巴巴集团控股有限公司 A kind of resource access method, apparatus and system
CN109634925A (en) * 2019-02-20 2019-04-16 平安科技(深圳)有限公司 Resource file downloading method, device, computer equipment and storage medium
US20200051127A1 (en) * 2015-03-06 2020-02-13 Amazon Technologies, Inc. Enhanced permissions management
US20200244767A1 (en) * 2019-01-28 2020-07-30 Adp, Llc Customized web services gateway
CN112134951A (en) * 2020-09-22 2020-12-25 睿视(苏州)视频科技有限公司 Data transmission method and device, electronic equipment and storage medium

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10425297B1 (en) * 2013-11-12 2019-09-24 Amazon Technologies, Inc. Adaptive polling based upon demand
JP6380031B2 (en) * 2014-11-14 2018-08-29 富士通株式会社 Message generation program, message generation apparatus, and message generation method
CN108062361A (en) * 2017-11-30 2018-05-22 深圳市友悦机器人科技有限公司 Early education equipment, resource supplying system and the method for updating early education device resource
CN108833580A (en) * 2018-07-02 2018-11-16 北京天华星航科技有限公司 A kind of cloud data processing method, device and cloud computing system
CN110731074B (en) * 2018-12-13 2023-01-31 Oppo广东移动通信有限公司 Subscription message processing method and device, computer equipment and storage medium
CN110213092A (en) * 2019-05-21 2019-09-06 深信服科技股份有限公司 Resource access method, platform management equipment, storage medium and the device of mixed cloud
CN110209949B (en) * 2019-06-11 2021-10-15 湖南快乐阳光互动娱乐传媒有限公司 Resource pushing method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200051127A1 (en) * 2015-03-06 2020-02-13 Amazon Technologies, Inc. Enhanced permissions management
CN107015996A (en) * 2016-01-28 2017-08-04 阿里巴巴集团控股有限公司 A kind of resource access method, apparatus and system
US20200244767A1 (en) * 2019-01-28 2020-07-30 Adp, Llc Customized web services gateway
CN109634925A (en) * 2019-02-20 2019-04-16 平安科技(深圳)有限公司 Resource file downloading method, device, computer equipment and storage medium
CN112134951A (en) * 2020-09-22 2020-12-25 睿视(苏州)视频科技有限公司 Data transmission method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN112134951A (en) 2020-12-25

Similar Documents

Publication Publication Date Title
US10261853B1 (en) Dynamic replication error retry and recovery
WO2018036148A1 (en) Server cluster system
US11706080B2 (en) Providing dynamic serviceability for software-defined data centers
WO2016202051A1 (en) Method and device for managing active and backup nodes in communication system and high-availability cluster
US10970190B2 (en) Hybrid log viewer with thin memory usage
WO2021184587A1 (en) Prometheus-based private cloud monitoring method and apparatus, and computer device and storage medium
CN113660350A (en) Distributed lock coordination method, device, equipment and storage medium
JP2006127201A (en) Storage system and conduction confirmation method
WO2012171349A1 (en) Method, apparatus and system for implementing distributed auto-incrementing counting
WO2022062347A1 (en) Data transmission method and apparatus, and electronic device and storage medium
CN111209265A (en) Database switching method and terminal equipment
CN108512753B (en) Method and device for transmitting messages in cluster file system
CN112929225A (en) Session exception handling method and device, computer equipment and storage medium
CN109726151B (en) Method, apparatus, and medium for managing input-output stack
WO2020000316A1 (en) Fault tolerance processing method, device, and server
WO2015070666A1 (en) Method, device and system for adjusting target system performance
US8880957B2 (en) Facilitating processing in a communications environment using stop signaling
WO2021238579A1 (en) Method for managing sata hard disk by means of storage system, and storage system
JP2015114952A (en) Network system, monitoring control unit, and software verification method
CN114528350A (en) Cluster split brain processing method, device and equipment and readable storage medium
WO2017101016A1 (en) Method and apparatus for synchronizing service request of storage node
WO2023185355A1 (en) Method and apparatus for achieving high availability of clustered virtual machines, device, and medium
EP4057582B1 (en) Device management method and apparatus
CN113391940B (en) Method and system for consolidating system service by breaking limit of watchdog
CN116302711B (en) Disaster recovery method and device based on cloud platform mirror image, electronic equipment and storage medium

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21870736

Country of ref document: EP

Kind code of ref document: A1