[go: up one dir, main page]

CN113127217A - Data distribution method, device, equipment and storage medium - Google Patents

Data distribution method, device, equipment and storage medium Download PDF

Info

Publication number
CN113127217A
CN113127217A CN201911404064.7A CN201911404064A CN113127217A CN 113127217 A CN113127217 A CN 113127217A CN 201911404064 A CN201911404064 A CN 201911404064A CN 113127217 A CN113127217 A CN 113127217A
Authority
CN
China
Prior art keywords
data
published
publishing
identifiers
identifier
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN201911404064.7A
Other languages
Chinese (zh)
Inventor
王天罡
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Mobile Communications Group Co Ltd
China Mobile Chengdu ICT Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
China Mobile Chengdu ICT Co Ltd
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 China Mobile Communications Group Co Ltd, China Mobile Chengdu ICT Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN201911404064.7A priority Critical patent/CN113127217A/en
Publication of CN113127217A publication Critical patent/CN113127217A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • G06F9/524Deadlock detection or avoidance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5011Pool
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明公开了一种数据发布方法、装置、设备及存储介质。该方法包括:将获取的多个待发布数据的数据标识加入第一线程池中,以用于数据获取端发送或接收消息队列MQ;根据每个待发布数据的数据标识,确定每个待发布数据的分布式缓存锁;根据数据标识,生成第一消息队列MQ,第一MQ包括数据标识;将第一MQ发送给数据发布端,以用于数据发布端根据第一MQ中的多个数据标识获取多个待发布数据;将多个待发布数据加入到第二线程池中,并向数据获取端发送第二MQ,发布待发布数据;第二MQ包括数据标识,能够保证多个客户端的高可用,节省资源。

Figure 201911404064

The invention discloses a data publishing method, device, equipment and storage medium. The method includes: adding the acquired data identifiers of a plurality of data to be published into a first thread pool, so that the data acquisition end can send or receive a message queue MQ; according to the data identifiers of each data to be published, determine each Distributed cache lock for data; generate a first message queue MQ according to the data identifier, and the first MQ includes a data identifier; send the first MQ to the data publishing end, so that the data publishing end can use the multiple data in the first MQ according to the data publishing end Identify multiple data to be published; add multiple data to be published to the second thread pool, and send a second MQ to the data acquisition end to publish the data to be published; the second MQ includes data identification, which can ensure that multiple clients High availability and resource saving.

Figure 201911404064

Description

数据发布方法、装置、设备及存储介质Data distribution method, apparatus, device and storage medium

技术领域technical field

本发明属于业务支撑技术领域,尤其涉及一种数据发布方法、装置、设备及存储介质。The invention belongs to the technical field of business support, and in particular relates to a data publishing method, device, equipment and storage medium.

背景技术Background technique

数据发布的方法为数据发布系统串行发布定时数据,效率低下。且如果只有一台机器,发生机器故障不能保证高可用。那么,数据获取端可以选择集群系统,利用数据库行锁来从多个客户端中选择一个获取锁的来获取数据,保证了获取数据的高可用。但是利用数据库行锁来从多个客户端中选择一个数据库行锁的来获取数据,只能有一个客户端进行数据发布,其他客户端都是处于闲置状态,造成资源的浪费。The method of data publishing is that the data publishing system publishes timing data serially, which is inefficient. And if there is only one machine, a machine failure cannot guarantee high availability. Then, the data acquisition end can choose the cluster system, and use the database row lock to select one of the multiple clients to acquire the lock to acquire the data, which ensures the high availability of the acquired data. However, using database row locks to select a database row lock from multiple clients to obtain data, only one client can publish data, and other clients are in an idle state, resulting in a waste of resources.

发明内容SUMMARY OF THE INVENTION

本发明实施例提供一种数据发布方法、装置、设备及存储介质,能够保证多个客户端的高可用,节省资源。Embodiments of the present invention provide a data publishing method, apparatus, device, and storage medium, which can ensure high availability of multiple clients and save resources.

第一方面,提供了一种数据发布方法,该方法应用于数据获取端,该方法包括:In a first aspect, a data publishing method is provided, the method is applied to a data acquisition end, and the method includes:

将获取的多个待发布数据的数据标识加入第一线程池中,以用于数据获取端发送或接收消息队列(Message Queuing,MQ);adding the acquired data identifiers of the data to be published into the first thread pool, so as to be used by the data acquiring end to send or receive a message queue (Message Queuing, MQ);

根据每个待发布数据的数据标识,确定每个待发布数据的分布式缓存锁;Determine the distributed cache lock of each to-be-published data according to the data identifier of each to-be-published data;

根据数据标识,生成第一消息队列MQ,第一MQ包括数据标识;Generate a first message queue MQ according to the data identifier, and the first MQ includes the data identifier;

将第一MQ发送给数据发布端,以用于数据发布端根据第一MQ中的多个数据标识获取多个待发布数据;将多个待发布数据加入到第二线程池中,并向数据获取端发送第二MQ,发布待发布数据;第二MQ包括数据标识。Send the first MQ to the data publishing end, so that the data publishing end can obtain a plurality of data to be published according to the multiple data identifiers in the first MQ; add the plurality of data to be published to the second thread pool, and send the data to the data The acquiring end sends the second MQ to publish the data to be published; the second MQ includes the data identifier.

在一种可能的实现方式中,该方法还包括:In a possible implementation, the method further includes:

确定待发布数据的数量;determine the amount of data to be published;

当待发布数据的数量大于预设数量时,获取预设数量的待发布数据;或者,When the quantity of data to be published is greater than the preset quantity, obtain the preset quantity of data to be published; or,

当待发布数据的数量不大于预设数量时,获取待发布数据。When the quantity of data to be published is not greater than the preset quantity, the data to be published is acquired.

在一种可能的实现方式中,该方法还包括:In a possible implementation, the method further includes:

确定分布式缓存锁的时间阈值;Determine the time threshold for distributed cache locks;

当分布式缓存锁的使用时间超过时间阈值时,释放分布式缓存锁。When the usage time of the distributed cache lock exceeds the time threshold, the distributed cache lock is released.

第二方面,提供了一种数据发布方法,该方法应用于数据发布端,该方法包括:In a second aspect, a data publishing method is provided, the method is applied to a data publishing end, and the method includes:

接收数据获取端发送的第一消息队列MQ;第一MQ中携带有每个待发布数据的数据标识;Receive the first message queue MQ sent by the data acquisition end; the first MQ carries the data identifier of each data to be published;

根据多个数据标识获取数据标识对应的待发布数据;Obtain the data to be published corresponding to the data identifiers according to the multiple data identifiers;

将待发布数据加入到第二线程池中,以用于数据发布端发送或接收MQ;Add to-be-published data to the second thread pool for the data publisher to send or receive MQ;

根据每个数据标识,发布每个数据标识对应的待发布数据。According to each data identifier, the to-be-published data corresponding to each data identifier is released.

在一种可能的实现方式中,根据每个数据标识,发布每个数据标识对应的待发布数据,包括:In a possible implementation manner, according to each data identifier, the to-be-published data corresponding to each data identifier is published, including:

根据每个数据标识,确定每个数据标识对应的待发布数据的发布页面;According to each data identifier, determine the release page of the to-be-released data corresponding to each data identifier;

当待发布数据的数据所占页面区域与发布页面对应时,发布待发布数据。When the page area occupied by the data of the to-be-published data corresponds to the publishing page, the to-be-published data is published.

在一种可能的实现方式中,该方法还包括:根据多个数据标识生成第二MQ,并将第二MQ发送给数据获取端,以用于数据获取端确定多个待发布数据发布。In a possible implementation manner, the method further includes: generating a second MQ according to the multiple data identifiers, and sending the second MQ to the data acquisition end, so that the data acquisition end determines a plurality of to-be-published data releases.

在一种可能的实现方式中,该方法还包括:In a possible implementation, the method further includes:

删除数据发布端与数据标识对应的历史数据。Delete the historical data corresponding to the data identifier on the data publisher.

在一种可能的实现方式中,该方法还包括:In a possible implementation, the method further includes:

根据数据标识生成第三MQ,第三MQ包括数据标识;Generate a third MQ according to the data identification, and the third MQ includes the data identification;

向终端发送第三MQ,以用于终端根据第三MQ中的数据标识,从数据库中获取待发布数据,并展示待发布数据。The third MQ is sent to the terminal, so that the terminal obtains the data to be published from the database according to the data identifier in the third MQ, and displays the data to be published.

在一种可能的实现方式中,该方法还包括:In a possible implementation, the method further includes:

当待发布数据发布异常时,删除数据发布端与数据标识对应的历史数据;When the release of the data to be released is abnormal, delete the historical data corresponding to the data identifier at the data release end;

根据多个数据标识生成第四MQ;Generate a fourth MQ according to multiple data identifiers;

向终端发送第四MQ,以用于终端确定待发布数据发布异常。A fourth MQ is sent to the terminal for the terminal to determine that the data to be published is abnormally published.

在一种可能的实现方式中,该方法还包括:In a possible implementation, the method further includes:

当待发布数据发布异常时,根据多个数据标识生成第四MQ;When the to-be-published data is published abnormally, a fourth MQ is generated according to multiple data identifiers;

根据第四MQ重新发布待发布数据。The to-be-published data is republished according to the fourth MQ.

在一种可能的实现方式中,该方法还包括:In a possible implementation, the method further includes:

当重新发布待发布数据的次数超过预设次数,更新待发布数据在数据库的状态为发布异常的待发布数据。When the number of times of republishing the data to be published exceeds the preset number of times, the state of the data to be published in the database is updated to be the data to be published with abnormal publishing.

第三方面,提供了一种数据发布装置,该装置应用于数据获取端,该装置包括:In a third aspect, a data publishing device is provided, the device is applied to a data acquisition end, and the device includes:

加入模块,用于将获取的多个待发布数据的数据标识加入第一线程池中;A joining module is used to add the acquired data identifiers of the plurality of data to be published into the first thread pool;

确定模块,用于根据每个待发布数据的数据标识,确定每个待发布数据的分布式缓存锁;A determination module, used for determining the distributed cache lock of each data to be released according to the data identifier of each data to be released;

生成模块,用于根据数据标识,生成第一消息队列MQ;a generating module for generating a first message queue MQ according to the data identifier;

发送模块,用于将第一MQ发送给数据发布端,以用于数据发布端根据第一MQ中的多个数据标识获取多个待发布数据;将多个待发布数据加入到第二线程池中,并向数据获取端发送第二MQ,发布待发布数据。The sending module is used to send the first MQ to the data publishing end, so that the data publishing end can obtain a plurality of data to be published according to the plurality of data identifiers in the first MQ; add the plurality of data to be published to the second thread pool , and send the second MQ to the data acquisition end to publish the data to be published.

第四方面,提供了一种数据发布装置,该装置应用于数据发布端,该装置包括:In a fourth aspect, a data publishing device is provided, the device is applied to a data publishing terminal, and the device includes:

接收模块,用于接收数据获取端发送的第一消息队列MQ;第一MQ中携带有每个待发布数据的数据标识;a receiving module, configured to receive the first message queue MQ sent by the data acquisition end; the first MQ carries the data identifier of each data to be published;

获取模块,用于根据多个数据标识获取数据标识对应的待发布数据;an acquisition module, configured to acquire the data to be published corresponding to the data identifiers according to the multiple data identifiers;

加入模块,用于将待发布数据加入到第二线程池中;A joining module is used to add the data to be published into the second thread pool;

发送模块,用于根据多个数据标识生成第二MQ,并将第二MQ发送给数据获取端,以用于数据获取端确定多个待发布数据发布;a sending module, configured to generate a second MQ according to multiple data identifiers, and send the second MQ to the data acquisition terminal, so that the data acquisition terminal can determine a plurality of data to be published for publication;

发布模块,用于根据每个数据标识,发布每个数据标识对应的待发布数据。The publishing module is configured to publish the data to be published corresponding to each data identification according to each data identification.

第五方面,提供了一种电子设备,该设备包括:处理器以及存储有计算机程序指令的存储器;处理器执行计算机程序指令时实现如第一方面或者第一方面的任一可能实现方式中的方法。In a fifth aspect, an electronic device is provided, the device includes: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the first aspect or any possible implementation manner of the first aspect is implemented method.

第六方面,提供了一种计算机存储介质,该计算机存储介质上存储有计算机程序指令,计算机程序指令被处理器执行时实现如第一方面或者第一方面的任一可能实现方式中的方法。In a sixth aspect, a computer storage medium is provided, where computer program instructions are stored thereon, and when the computer program instructions are executed by a processor, the method in the first aspect or any possible implementation manner of the first aspect is implemented.

基于提供的数据发布方法、装置、设备及存储介质,通过将获取的多个待发布数据的数据标识加入第一线程池中,以用于数据获取端发送或接收消息队列MQ;根据每个待发布数据的数据标识,确定每个待发布数据的分布式缓存锁;根据数据标识,生成第一消息队列MQ,第一MQ包括数据标识;将第一MQ发送给数据发布端,以用于数据发布端根据第一MQ中的多个数据标识获取多个待发布数据;将多个待发布数据加入到第二线程池中,并向数据获取端发送第二MQ,发布待发布数据;第二MQ包括数据标识,能够保证多个客户端的高可用,节省资源。Based on the provided data publishing method, device, device and storage medium, the acquired data identifiers of the data to be published are added to the first thread pool, so that the data acquisition end can send or receive the message queue MQ; Publish the data identifier of the data, and determine the distributed cache lock of each data to be published; generate a first message queue MQ according to the data identifier, and the first MQ includes the data identifier; send the first MQ to the data publisher for data The publishing end obtains a plurality of data to be published according to the plurality of data identifiers in the first MQ; adds the plurality of data to be published into the second thread pool, and sends the second MQ to the data obtaining end to publish the data to be published; the second MQ includes data identification, which can ensure high availability of multiple clients and save resources.

附图说明Description of drawings

为了更清楚地说明本发明实施例的技术方案,下面将对本发明实施例中所需要使用的附图作简单的介绍,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions of the embodiments of the present invention more clearly, the following briefly introduces the accompanying drawings that need to be used in the embodiments of the present invention. For those of ordinary skill in the art, without creative work, the Additional drawings can be obtained from these drawings.

图1是本发明实施例提供的一种任务发布方法的流程示意图;1 is a schematic flowchart of a task publishing method provided by an embodiment of the present invention;

图2是本发明实施例提供的另一种任务发布方法的流程示意图;2 is a schematic flowchart of another task publishing method provided by an embodiment of the present invention;

图3是本发明实施例提供的一种数据发布方法的流程示意图;3 is a schematic flowchart of a data publishing method provided by an embodiment of the present invention;

图4是本发明实施例提供的另一种数据发布方法的流程示意图;4 is a schematic flowchart of another data publishing method provided by an embodiment of the present invention;

图5是本发明实施例提供的又一种数据发布方法的流程示意图;5 is a schematic flowchart of another data publishing method provided by an embodiment of the present invention;

图6是本发明实施例提供的一种数据发布装置的结构示意图;6 is a schematic structural diagram of a data publishing apparatus provided by an embodiment of the present invention;

图7是本发明实施例提供的另一种数据发布装置的结构示意图;7 is a schematic structural diagram of another data distribution apparatus provided by an embodiment of the present invention;

图8是本发明实施例提供的电子设备的结构示意图。FIG. 8 is a schematic structural diagram of an electronic device provided by an embodiment of the present invention.

具体实施方式Detailed ways

下面将详细描述本发明的各个方面的特征和示例性实施例,为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及具体实施例,对本发明进行进一步详细描述。应理解,此处所描述的具体实施例仅被配置为解释本发明,并不被配置为限定本发明。对于本领域技术人员来说,本发明可以在不需要这些具体细节中的一些细节的情况下实施。下面对实施例的描述仅仅是为了通过示出本发明的示例来提供对本发明更好的理解。The features and exemplary embodiments of various aspects of the present invention will be described in detail below. In order to make the objectives, technical solutions and advantages of the present invention more clear, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only configured to explain the present invention, and are not configured to limit the present invention. It will be apparent to those skilled in the art that the present invention may be practiced without some of these specific details. The following description of the embodiments is only intended to provide a better understanding of the present invention by illustrating examples of the invention.

需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括……”限定的要素,并不排除在包括要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that, in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any relationship between these entities or operations. any such actual relationship or sequence exists. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, method, article or device that includes a list of elements includes not only those elements, but also includes not explicitly listed or other elements inherent to such a process, method, article or apparatus. Without further limitation, an element defined by the phrase "comprising" does not preclude the presence of additional identical elements in the process, method, article or device that includes the element.

目前,任务发布有下述两种方式。第一种数据发布方式如图1所示,系统查询所有的定时任务,然后遍历任务放入线程池串行执行任务。第二种数据发布方式如图2所示,定时任务获取端查询所有的定时任务,遍历所有的任务放入线程池;发送MQ到定时任务执行端。定时任务执行端接收MQ,然后分渠道查询需要发布的任务,执行发布任务的操作然后返回。Currently, there are two ways to release tasks. The first data release method is shown in Figure 1. The system queries all timing tasks, and then traverses the tasks and puts them into the thread pool to execute the tasks serially. The second data publishing method is shown in Figure 2. The timed task acquirer queries all timed tasks, traverses all tasks and puts them in the thread pool; sends MQ to the timed task execution end. The scheduled task execution end receives the MQ, then queries the tasks to be published by channel, executes the operation of publishing the task, and returns.

但是上述两种方式还存在下述问题:只有一个系统串行执行定时任务,效率低,如果只有一台机器,发生机器故障不能保证高可用。客户端选择集群系统来获取任务,保证了获取任务的高可用。但是利用数据库行锁来从多个客户端中选择一个获取锁的来获取任务,其他客户端都是处于闲置状态,造成资源的浪费。However, the above two methods still have the following problems: only one system executes timed tasks serially, which is inefficient. If there is only one machine, high availability cannot be guaranteed in the event of a machine failure. The client selects the cluster system to acquire tasks, which ensures the high availability of the acquired tasks. However, the database row lock is used to select one of multiple clients to acquire the lock to acquire the task, and other clients are in an idle state, resulting in a waste of resources.

因此,本发明实施例提供了一种数据发布方法、装置、设备及存储介质,能够保证多个客户端的高可用,节省资源。Therefore, the embodiments of the present invention provide a data publishing method, apparatus, device, and storage medium, which can ensure high availability of multiple clients and save resources.

为了方便理解本发明实施例,首先对本发明实施例中数据发布方法进行详细阐述。In order to facilitate understanding of the embodiments of the present invention, the data publishing method in the embodiments of the present invention is first described in detail.

图3是本发明实施例提供的一种数据发布方法的流程示意图。FIG. 3 is a schematic flowchart of a data publishing method provided by an embodiment of the present invention.

如图3所示,本发明实施例提供的数据发布方法,应用于数据获取端,包括:As shown in FIG. 3 , the data publishing method provided by the embodiment of the present invention, applied to the data acquisition end, includes:

S301:将获取的多个待发布数据的数据标识加入第一线程池中,以用于数据获取端发送或接收消息队列MQ。S301: Add the acquired data identifiers of the data to be published into the first thread pool, so that the data acquiring end sends or receives the message queue MQ.

待发布数据保存在数据库中,每一个待发布数据均对应有一个数据标识。例如,待发布数据为商家待发布的产品数据,那么,待发布数据的标识则为商家账号。The data to be published is stored in the database, and each data to be published corresponds to a data identifier. For example, if the data to be released is product data to be released by the merchant, then the identifier of the data to be released is the merchant account.

获取到多个待发布数据的数据标识后,将待发布数据加入到线程池中。线程池增加了多线程的执行效率。在本发明实施例中不仅保证了多个线程的执行效率,还保证的MQ的快速返回执行结果,防止MQ因为长时间不返回结果的重试。本发明实施例中的线程池可以是基于线程池执行器(Thread Pool Executor)基类实现。核心线程充足通过核心线程执行任务,核心线程都在执行任务则把任务放在链接阻塞队列(Linked Blocking Queue)里面等待执行。After acquiring the data identifiers of multiple data to be published, the data to be published is added to the thread pool. The thread pool increases the execution efficiency of multi-threading. In the embodiment of the present invention, not only the execution efficiency of multiple threads is ensured, but also the quick return of the execution result of the MQ is ensured, so as to prevent the MQ from retrying because the result does not return for a long time. The thread pool in the embodiment of the present invention may be implemented based on the base class of thread pool executor (Thread Pool Executor). The core thread is sufficient to execute the task through the core thread. If the core thread is executing the task, the task is placed in the Linked Blocking Queue to wait for execution.

此外,为了避免数据获取端中数据积压而造成内存资源浪费,在S301之前,还可以包括下述步骤:确定待发布数据的数量;In addition, in order to avoid the waste of memory resources caused by the backlog of data in the data acquisition end, before S301, the following steps may also be included: determining the quantity of data to be published;

当待发布数据的数量大于预设数量时,获取预设数量的待发布数据;或者,When the quantity of data to be published is greater than the preset quantity, obtain the preset quantity of data to be published; or,

当待发布数据的数量不大于预设数量时,获取待发布数据。When the quantity of data to be published is not greater than the preset quantity, the data to be published is acquired.

其中,在获取待发布数据标识之前,首先需要确定待发布数据的数量。例如,每次最多能够对1500个待发布数据进行数据发布。需要先确定待发布数据的数量。当待发布数据的数量超过1500个时,则只获取1500个待发布数据的数据标识。当待发布数据的数据未达到1500个时,可以获取所有待发布数据的数据标识。Wherein, before acquiring the identifier of the data to be published, it is first necessary to determine the quantity of the data to be published. For example, a maximum of 1500 pieces of data to be published can be published each time. The amount of data to be published needs to be determined first. When the number of data to be published exceeds 1500, only the data identifiers of the 1500 data to be published are acquired. When the data of the data to be published does not reach 1500, the data identifiers of all the data to be published can be obtained.

S302:根据每个待发布数据的数据标识,确定每个待发布数据的分布式缓存锁。S302: Determine the distributed cache lock of each data to be published according to the data identifier of each data to be published.

通过线程池中每个待发布数据的数据标识去获取待发布数据的分布式缓存锁。如果一个数据标识获取到一个数据获取端的分布式缓存锁,那么该数据获取端与其他的数据获取端就形成竞争,其他的数据获取端就不能在获取该数据标识的分布式缓存锁。通过数据标识获取分布式缓存锁能够保证数据获取端的高可用,而且能够同时获取待发布数据的数据标识。The distributed cache lock of the to-be-published data is obtained through the data identifier of each to-be-published data in the thread pool. If a data identifier acquires the distributed cache lock of a data acquirer, the data acquirer competes with other data acquirers, and other data acquirers cannot acquire the distributed cache lock of the data identifier. Obtaining the distributed cache lock through the data identifier can ensure the high availability of the data acquisition end, and can simultaneously acquire the data identifier of the data to be published.

其中,为了防止执行数据发布任务期间,数据获取端发生重启或者直接挂掉造成死锁,分布式缓存锁设置了时间阈值。Among them, in order to prevent deadlock caused by restarting or directly hanging up on the data acquisition end during the execution of the data publishing task, a time threshold is set for the distributed cache lock.

具体的,确定分布式缓存锁的时间阈值;Specifically, determining the time threshold of the distributed cache lock;

当分布式缓存锁的使用时间超过时间阈值时,释放分布式缓存锁。When the usage time of the distributed cache lock exceeds the time threshold, the distributed cache lock is released.

当一个数据标识使用该分布式缓存锁的时间超过了分布式缓存锁的时间阈值,那么,该分布式缓存锁将会被释放。释放后其他的数据发布任务就可以获取该分布式缓存锁,进而保证其他数据发布任务的执行。分批次获取任务,并通过MQ异步发送到数据发布端集群,数据发布端集群能够快速的接受任务。When the time that a data identifier uses the distributed cache lock exceeds the time threshold of the distributed cache lock, the distributed cache lock will be released. After the release, other data publishing tasks can acquire the distributed cache lock, thereby ensuring the execution of other data publishing tasks. Get tasks in batches and asynchronously send them to the data publisher cluster through MQ. The data publisher cluster can quickly accept tasks.

S303:根据数据标识,生成第一消息队列MQ,第一MQ包括数据标识。S303: Generate a first message queue MQ according to the data identifier, where the first MQ includes the data identifier.

获取分布式缓存锁后,根据数据标识生成第一MQ,其中,第一MQ中携带有多个数据标识,每个数据标识对应一个待发布数据。After the distributed cache lock is acquired, a first MQ is generated according to the data identifier, wherein the first MQ carries a plurality of data identifiers, and each data identifier corresponds to one piece of data to be published.

S304:将第一MQ发送给数据发布端,以用于数据发布端根据第一MQ中的多个数据标识获取多个待发布数据;将多个待发布数据加入到第二线程池中,并向数据获取端发送第二MQ,发布待发布数据;第二MQ包括数据标识。S304: Send the first MQ to the data publishing end, so that the data publishing end obtains a plurality of data to be published according to the plurality of data identifiers in the first MQ; add the plurality of data to be published into the second thread pool, and A second MQ is sent to the data acquisition end to publish the data to be published; the second MQ includes a data identifier.

将第一MQ发送给数据发布端。将第一MQ发送给数据发布端,保证了数据获取端可以继续获取数据发布任务,也保证了数据发布端不会重复执行同一个数据发布任务。Send the first MQ to the data publisher. Sending the first MQ to the data publishing end ensures that the data obtaining end can continue to obtain the data publishing task, and also ensures that the data publishing end does not repeatedly execute the same data publishing task.

数据发布端接收到第一MQ后,根据第一MQ中的数据标识,数据标识对应的待发布数据。获取到待发布数据后,将根据数据标识生成第二MQ,并将第二MQ发送给数据获取端。数据获取端接收到第二MQ后,数据获取端就能够确定数据发布端已经获取到待发布数据,并能够只能数据发布任务了。通过数据标识获取的分布式缓存锁,比数据库等分布式锁更轻便,集群多个数据获取端同时工作,不会造成资源的浪费,还能保证高可用。After the data publishing end receives the first MQ, according to the data identification in the first MQ, the data identification corresponds to the data to be published. After acquiring the data to be published, a second MQ will be generated according to the data identifier, and the second MQ will be sent to the data acquiring end. After the data acquisition end receives the second MQ, the data acquisition end can determine that the data publishing end has obtained the data to be published, and can only perform the data publishing task. Distributed cache locks obtained through data identification are lighter than distributed locks such as databases, and multiple data acquisition ends of the cluster work simultaneously, which will not cause waste of resources and ensure high availability.

本发明实施例提供的数据发布方法,通过将获取的多个待发布数据的数据标识加入第一线程池中,以用于数据获取端发送或接收消息队列MQ;根据每个待发布数据的数据标识,确定每个待发布数据的分布式缓存锁;根据数据标识,生成第一消息队列MQ,第一MQ包括数据标识;将第一MQ发送给数据发布端,以用于数据发布端根据第一MQ中的多个数据标识获取多个待发布数据;将多个待发布数据加入到第二线程池中,并向数据获取端发送第二MQ,发布待发布数据;第二MQ包括数据标识,能够保证多个客户端的高可用,节省资源。In the data publishing method provided by the embodiment of the present invention, the acquired data identifiers of the data to be published are added to the first thread pool, so that the data acquisition end can send or receive the message queue MQ; according to the data of each data to be published identifier, to determine the distributed cache lock of each data to be published; generate a first message queue MQ according to the data identifier, and the first MQ includes the data identifier; send the first MQ to the data publisher for the data publisher to use according to the first MQ Multiple data identifiers in one MQ obtain multiple data to be published; add multiple data to be published to the second thread pool, send the second MQ to the data acquisition end, and publish the data to be published; the second MQ includes data identifiers , which can ensure the high availability of multiple clients and save resources.

图4是本发明实施例提供的另一种数据发布方法的流程示意图。FIG. 4 is a schematic flowchart of another data publishing method provided by an embodiment of the present invention.

如图4所示,本发明实施例提供的一种数据发布方法,应用于数据发布端,包括:As shown in FIG. 4 , a data publishing method provided by an embodiment of the present invention, applied to a data publishing end, includes:

S401:接收数据获取端发送的第一消息队列MQ;第一MQ中携带有每个待发布数据的数据标识。S401: Receive a first message queue MQ sent by a data acquisition end; the first MQ carries a data identifier of each data to be published.

接收到第一MQ后,解析第一MQ,得到待发布数据的数据标识。其中第一MQ种包括多个数据标识。每个数据标识对应一个待发布数据。After receiving the first MQ, the first MQ is parsed to obtain the data identifier of the data to be published. The first MQ type includes multiple data identifiers. Each data identifier corresponds to a piece of data to be published.

S402:根据多个数据标识获取数据标识对应的待发布数据。S402: Acquire data to be published corresponding to the data identifiers according to the multiple data identifiers.

待发布数据存储在数据库中,当解析得到数据标识后,根据数据标识,从数据库中获取待发布数据。The data to be published is stored in the database, and after the data identification is obtained by parsing, the data to be published is obtained from the database according to the data identification.

在这里,待发布数据的发布渠道可能存在多个。例如,以待发布数据为商品数据为例,那么法发布数据的发布渠道可以是小程序,也可以是某个电商品台等。在获取待发布数据的时候,需要根据数据标识分渠道获取待发布数据。Here, there may be multiple release channels for the data to be released. For example, taking the data to be released as commodity data as an example, the release channel of the data can be a small program, or a certain e-commerce station, etc. When obtaining the data to be published, it is necessary to obtain the data to be published by channels according to the data identifier.

S403:将待发布数据加入到第二线程池中,以用于数据发布端发送或接收MQ。S403: Add the to-be-published data to the second thread pool for the data publishing end to send or receive MQ.

将获取的待发布数据放入第二线程池中,以用于生成第二MQ后,能够将第二MQ立即返回至数据获取端。After the acquired data to be published is put into the second thread pool for generating the second MQ, the second MQ can be immediately returned to the data acquisition end.

具体的,根据多个数据标识生成第二MQ,并将第二MQ发送给数据获取端,以用于数据获取端确定多个待发布数据发布。Specifically, the second MQ is generated according to the multiple data identifiers, and the second MQ is sent to the data acquisition end, so that the data acquisition end determines to publish a plurality of data to be published.

根据获取到待发布数据的数据标识生成第二MQ,并将第二MQ发送给数据获取端。数据获取端能够继续获取待发布数据的数据标识,进行下一个数据发布任务,不会造成MQ的积压。而待发布数据的数据发布任务能够异步执行,不会造成时间的增加。A second MQ is generated according to the acquired data identifier of the data to be published, and the second MQ is sent to the data acquiring end. The data acquisition end can continue to obtain the data identifier of the data to be published, and perform the next data publishing task without causing a backlog of MQ. The data publishing task of the data to be published can be executed asynchronously without increasing the time.

S404:根据每个数据标识,发布每个数据标识对应的待发布数据。S404: Publish the to-be-published data corresponding to each data identifier according to each data identifier.

获取到待发布数据后,遍历每个待发布数据的数据标识,进行待发布数据的发布。After the data to be published is acquired, the data identifier of each data to be published is traversed, and the data to be published is published.

具体的,根据每个数据标识,确定每个数据标识对应的待发布数据的发布页面;Specifically, according to each data identifier, determine the release page of the to-be-published data corresponding to each data identifier;

当待发布数据的数据所占页面区域与发布页面对应时,发布待发布数据。When the page area occupied by the data of the to-be-published data corresponds to the publishing page, the to-be-published data is published.

每个待发布数据对应有发布页面。例如,数据标识为商家账号,待发布数据为线上商家设置的某个时间点要发布的商品价格等商品数据,那么每个线上商家的会有设置好的数据显示页面。而待发布数据对应的发布页面是与数据显示页面相同的。那么就可以通过遍历数据标识,确定每个待发布数据的发布页面,然后将发布数据所占页面区域与发布页面进行对应。如果待发布数据所占的页面区域与发布页面是对应的,那么发布该待发布数据。Each data to be published corresponds to a publishing page. For example, if the data is identified as a merchant account, and the data to be released is commodity data such as commodity prices to be released at a certain time set by the online merchant, then each online merchant will have a set data display page. The release page corresponding to the data to be released is the same as the data display page. Then, by traversing the data identifiers, the publishing page of each data to be published can be determined, and then the page area occupied by the published data is corresponding to the publishing page. If the page area occupied by the data to be published corresponds to the published page, the data to be published is published.

如果待发布数据所占的页面区域与发布页面不是对应的,那么待发布数据发布异常。当待发布数据发布异常时,删除数据发布端与数据标识对应的历史数据;根据多个数据标识生成第四MQ;其中,第四MQ中包括多个数据标识。将第四MQ发送给终端。终端接收到第四MQ后,能够确定待发布数据发布异常,不需要从数据库中获取待发布数据进行展示。If the page area occupied by the to-be-published data does not correspond to the published page, the to-be-published data is published abnormally. When the to-be-published data is published abnormally, delete the historical data corresponding to the data identifier at the data publishing end; generate a fourth MQ according to the multiple data identifiers; wherein, the fourth MQ includes multiple data identifiers. Send the fourth MQ to the terminal. After receiving the fourth MQ, the terminal can determine that the data to be published is abnormally published, and does not need to obtain the data to be published from the database for display.

待发布数据发布异常后,数据发布端还可以基于数据标识进行数据发布重试。根据发布异常的待发布数据的数据标识,生成第四MQ。基于第四MQ重试待发布数据的发布。如果重试发布待发布数据的次数超过了预设次数,那么将发布异常的待发布数据在数据库中的状态更新为发布异常。After the release of the data to be released is abnormal, the data release end may also retry the data release based on the data identifier. A fourth MQ is generated according to the data identifier of the data to be published that is abnormally published. The publication of the to-be-published data is retried based on the fourth MQ. If the number of retries to publish the to-be-published data exceeds the preset number of times, the status in the database of the to-be-published data that is abnormally published is updated to the published abnormality.

待发布数据发布成功后,还需要删除数据发布端与数据标识对应的历史数据。避免了资源的占用。After the data to be published is successfully published, it is also necessary to delete the historical data corresponding to the data identifier on the data publishing side. Avoid resource occupancy.

此外,在S404之后,还可以包括下述步骤:In addition, after S404, the following steps may also be included:

根据数据标识生成第三MQ,第三MQ包括数据标识;Generate a third MQ according to the data identification, and the third MQ includes the data identification;

向终端发送第三MQ,以用于终端根据第三MQ中的数据标识,从数据库中获取待发布数据,并展示待发布数据。The third MQ is sent to the terminal, so that the terminal obtains the data to be published from the database according to the data identifier in the third MQ, and displays the data to be published.

待发布数据发布成功后,将根据数据标识生成第三MQ,并将第三MQ发送给终端。其中,第三MQ中包括数据标识。终端接收到第三MQ后,根据数据标识确定已经发布的待发布数据。其中,终端会根据数据标识从数据库中获取待发布数据,并展示待发布数据。After the data to be published is successfully published, a third MQ will be generated according to the data identifier, and the third MQ will be sent to the terminal. Wherein, the third MQ includes a data identifier. After receiving the third MQ, the terminal determines the data to be published that has been published according to the data identifier. The terminal acquires the data to be published from the database according to the data identifier, and displays the data to be published.

本发明实施例提供的一种数据发布方法,通过接收数据获取端发送的第一消息队列MQ;第一MQ中携带有每个待发布数据的数据标识;根据多个数据标识获取数据标识对应的待发布数据;将待发布数据加入到第二线程池中,以用于数据发布端发送或接收MQ;根据每个数据标识,发布每个数据标识对应的待发布数据,能够保证多个客户端的高可用,节省资源。A data publishing method provided by an embodiment of the present invention includes receiving a first message queue MQ sent by a data acquisition end; the first MQ carries a data identifier of each data to be published; and the corresponding data identifiers are acquired according to multiple data identifiers. Data to be published; the data to be published is added to the second thread pool for the data publisher to send or receive MQ; according to each data ID, the data to be published corresponding to each data ID is published, which can ensure the High availability and resource saving.

以商品促销,任务发布时间为凌晨,店铺装修系统的商家可能会设置几千个定时发布任务,需要准确快速的完成所有的定时任务为例,如图5所示,本发明实施例提供了又一种数据发布方法的流程示意图。Taking the product promotion and the task release time in the early morning, the merchant of the store decoration system may set thousands of timed release tasks, and all the timed tasks need to be completed accurately and quickly. As shown in FIG. 5, the embodiment of the present invention provides another A schematic flowchart of a data publishing method.

如图5所示,本发明实施例提供的数据发布方法包括:As shown in FIG. 5 , the data publishing method provided by the embodiment of the present invention includes:

S501:定时任务触发,例如,每30s触发一个任务发布。S501: Timed task triggering, for example, triggering a task release every 30s.

多个客户端同时工作查询当前时刻的所有定时发布任务。Multiple clients work at the same time to query all scheduled tasks at the current moment.

S502:客户端确定任务是否超出1500个。若是,执行S503,若否执行S504。S502: The client determines whether the number of tasks exceeds 1500. If yes, execute S503, if not, execute S504.

S503:客户端每次获取1500个任务。S503: The client obtains 1500 tasks each time.

S504:客户端获取全部任务。S504: The client obtains all tasks.

判断任务是否大于阈值,超过就将任务分为几个批次。Determine whether the task is greater than the threshold, and if it exceeds the threshold, divide the task into several batches.

S505:客户端遍历任务加入到线程池。S505: The client traversal task is added to the thread pool.

客户端将所有的任务加入到线程池中,方便后面发送MQ消息。The client adds all tasks to the thread pool, which is convenient for sending MQ messages later.

S506:以身份标识号(IDentity Document,ID)为钥匙(key)获取分布式锁。S506: Obtain a distributed lock with an ID (IDentity Document, ID) as a key (key).

客户端的线程池中,所有的任务会通过商家ID去竞争分布式缓存锁,如果一个商家ID获取到一个客户端的分布式缓存锁,其他的客户端就形成竞争,只能获取其他的商家分布式缓存锁,这样多个客户端不仅能保证高可用,而且能同时工作获取任务。In the thread pool of the client, all tasks will compete for the distributed cache lock through the merchant ID. If a merchant ID obtains the distributed cache lock of a client, other clients will form a competition and can only obtain the distributed cache lock of other merchants. Cache locks, so that multiple clients can not only ensure high availability, but also work to acquire tasks at the same time.

客户端通过商家ID获取的分布式缓存锁,并设置超时时间,防止执行任务期间发生机器重启或者直接挂掉造成死锁,超过这个时间会有其他的任务获取锁,接着执行其他的任务。The client obtains the distributed cache lock through the merchant ID, and sets a timeout to prevent the machine from restarting or directly hanging up during the execution of the task, causing deadlock. After this time, other tasks will acquire the lock and then execute other tasks.

S507:客户端发送MQ消息给服务端。S507: The client sends an MQ message to the server.

客户端获取到商家ID的分布式锁之后,构造MQ需要的参数,然后发送MQ信息到服务端,既可以并发获取任务,也可以保证不重复执行。After the client obtains the distributed lock of the merchant ID, it constructs the parameters required by MQ, and then sends the MQ information to the server, which can obtain tasks concurrently and ensure non-repetitive execution.

S508:服务端接收MQ。S508: The server receives the MQ.

S509:发布任务放入线程池MQ返回客户端。S509: The publishing task is put into the thread pool MQ and returned to the client.

服务端获取MQ消息传递的消息,通过主题(topic)机制,获取到任务之后将任务放到线程池中,这样可以使MQ消息立马返回,不会造成MQ消息的积压。发布任务会异步执行,不会造成时间的增加。The server obtains the message delivered by the MQ message, and puts the task into the thread pool after obtaining the task through the topic mechanism, so that the MQ message can be returned immediately without causing a backlog of MQ messages. The publishing task will be executed asynchronously and will not cause an increase in time.

S510:服务端发布前校验和更新数据库。S510: Check and update the database before the server publishes it.

S511:服务端更新缓存和发布MQ。如果数据发布异常,则执行S518;如果数据发布成功,则执行S513和S515。S511: The server updates the cache and publishes the MQ. If the data release is abnormal, execute S518; if the data release is successful, execute S513 and S515.

S513:服务端发布快照存储。S513: The server publishes snapshot storage.

服务端执行发布的流程,更新发布状态,删除当前定时发布店铺的缓存,发送MQ给下游系统,做一些发布快照的工作。这些所有操作都在一个事物中,如果发生异常会进行事物回滚。The server executes the publishing process, updates the publishing status, deletes the cache of the current regular publishing store, sends MQ to the downstream system, and does some work of publishing snapshots. All of these operations are in one transaction, and if an exception occurs, the transaction is rolled back.

S514:服务端发布结束。S514: The server-side publishing ends.

S515:应用程序(Application,App)端接收MQ。S515: The application (Application, App) side receives the MQ.

S516:App端首页接口数据更新。S516: Update the data of the home page interface of the App.

S517:用户查看最新数据。S517: The user checks the latest data.

S518:服务端更新缓存和发送MQ异常。S518: The server updates the cache and sends an MQ exception.

S519:服务端加入到队列中。S519: The server is added to the queue.

S520:服务端重新发送MQ到服务端。S520: The server resends the MQ to the server.

服务端的补偿机制,会利用MQ的重试机制进行三次重试进行发布的操作,如果还是失败,就会更新任务的状态是未成功的定时发布任务。The compensation mechanism of the server will use the retry mechanism of MQ to retry the publishing operation three times. If it still fails, it will update the status of the task to be an unsuccessful scheduled publishing task.

S521:出现发布的所有异常。S521: All published exceptions occurred.

S522:数据库状态不更新。S522: The database status is not updated.

S523:下次获取定时发布任务重新获取。S523: Re-acquire the scheduled release task next time.

客户端下一次查询定时发布任务时还会查询到这个任务继续执行,但是超过五分钟还未执行成功的就不会在执行此任务,进行日志分析,防止重试过多造成其他定时任务造成影响。The next time the client queries the scheduled task release, the task will continue to be queried, but if the task has not been successfully executed for more than five minutes, the task will not be executed, and log analysis will be performed to prevent other scheduled tasks from being affected by retries. .

本发明实施例中,分布式缓存锁在集群数量在10台以上时,效率会比其他分布式锁增加50%左右,因为每台机器都在查询执行任务,其他分布式锁是集群的一台机器在执行。MQ机制加上线程池技术在MQ重试达到三次及以上是效率会提升40%左右,MQ的重试相当于增加了定时发布的任务数量。整套本发明实施例在C端用户和B端商家侧都可以使用,提升整体的发布效率。In the embodiment of the present invention, when the number of distributed cache locks in the cluster is more than 10, the efficiency will be increased by about 50% compared with other distributed locks, because each machine is querying and executing tasks, and the other distributed locks are one of the cluster. The machine is executing. The MQ mechanism and the thread pool technology will increase the efficiency by about 40% when the MQ retry reaches three or more times. The MQ retry is equivalent to increasing the number of tasks published regularly. The entire set of embodiments of the present invention can be used on both the C-end user and the B-end merchant side, thereby improving the overall publishing efficiency.

下面对本发明实施例的本发明实施例所采用的技术手段进行详细阐述:The technical means adopted by the embodiments of the present invention are described in detail below:

本发明实施例是客户端使用线程池+分布式缓存锁+MQ消息通知机制+异常补偿机制实现,服务器端采用MQ消息通知机制+线程池技术+事务管理+异常补偿机制实现。整个本发明实施例使定时发布任务快速正确的执行,效率测试比第二套本发明实施例提升150%。The embodiment of the present invention is realized by the client using thread pool + distributed cache lock + MQ message notification mechanism + exception compensation mechanism, and the server side is realized by using MQ message notification mechanism + thread pool technology + transaction management + exception compensation mechanism. The entire embodiment of the present invention enables the timing release task to be executed quickly and correctly, and the efficiency test is improved by 150% compared with the second set of embodiments of the present invention.

本发明实施例中保证定时发布效率提升的几项技术连接具体如下:In the embodiment of the present invention, several technical connections for ensuring the improvement of timing release efficiency are as follows:

分布式缓存锁:通过ID去获取分布式缓存锁,获取到分布式锁并查询MQ相关的信息,接着发送MQ消息到服务器。客户端做了一个可能会出现死锁或者异常的补偿机制,如果客户端没有执行释放锁的功能,会通过增加超时时间的机制,超过了设定的时间,其他的ID可以获取到分布式缓存锁。这样客户端可以多台机器同时并行工作,利用ID保证只有一个客户端能够获取到定时任务,不会重复执行任务,获取任务就是并发获取,效率高,并且做到高可用。Distributed cache lock: Obtain the distributed cache lock by ID, obtain the distributed lock and query MQ related information, and then send the MQ message to the server. The client has made a compensation mechanism that may cause deadlock or abnormality. If the client does not perform the function of releasing the lock, it will increase the timeout period. If the set time is exceeded, other IDs can obtain the distributed cache. Lock. In this way, the client can work on multiple machines at the same time, and the ID can be used to ensure that only one client can obtain the scheduled task, and the task will not be executed repeatedly. The task is obtained concurrently, which is efficient and highly available.

MQ异步发送:基于投票方式实现,客户端和服务器注册同一个topic,这样可以进行消息的保存和发送通知。是多个客户端把查询的任务通过异步发送MQ到装修系统执行任务,多个服务器同时执行发布的任务效率高,并且发布的任务是另起的线池中执行,在中央处理器计算功能不多的情况下,又可以增加执行任务的数目,在中央处理器等待io的时候能执行等待的其他任务,提高任务的执行效率。MQ asynchronous sending: implemented based on voting, the client and server register the same topic, so that messages can be saved and notifications can be sent. It is that multiple clients send the query task to the decoration system asynchronously by sending MQ to execute the task. It is highly efficient for multiple servers to execute the published task at the same time, and the published task is executed in a separate line pool. In many cases, the number of tasks to be executed can be increased, and other tasks that are waiting can be executed when the central processor is waiting for io, thereby improving the execution efficiency of tasks.

线程池技术:线程池本身是增加多线程的执行效率,但是在本本发明实施例中,不仅保证了多个线程的执行效率,还保证的MQ消息的快速返回执行结果,防止MQ因为长时间不返回结果的重试。基于Thread Pool Executor基类实现。核心线程充足通过核心线程执行任务,核心线程都在执行任务则把任务放在Linked Blocking Queue队列里面等待执行。Thread pool technology: The thread pool itself increases the execution efficiency of multiple threads, but in this embodiment of the present invention, it not only ensures the execution efficiency of multiple threads, but also ensures the rapid return of the execution result of MQ messages, preventing MQ from being out of service for a long time. A retry to return the result. Implemented based on the Thread Pool Executor base class. The core thread is sufficient to execute the task through the core thread. If the core thread is executing the task, the task is placed in the Linked Blocking Queue queue for execution.

补偿机制:服务器会控制各种异常,保证定时任务的状态更新。客户端通过MQ机制进行重试发布的操作,但是超过五分钟还未执行成功的就不会在下一次查询此任务,会通过ID维度进行日志分析,防止重试过多造成其他定时任务造成影响。Compensation mechanism: The server will control various exceptions to ensure the status update of timed tasks. The client uses the MQ mechanism to retry the publishing operation, but if the task has not been successfully executed for more than five minutes, it will not query the task next time, and will perform log analysis through the ID dimension to prevent other scheduled tasks from being affected by too many retries.

图6是本发明实施例提供的一种数据发布装置的结构示意图。FIG. 6 is a schematic structural diagram of a data publishing apparatus according to an embodiment of the present invention.

如图6所示,本发明实施例提供的数据发布装置可以包括:加入模块601、确定模块602、生成模块603和发送模块604。As shown in FIG. 6 , the data publishing apparatus provided in the embodiment of the present invention may include: an adding module 601 , a determining module 602 , a generating module 603 , and a sending module 604 .

加入模块601,用于将获取的多个待发布数据的数据标识加入第一线程池中;A joining module 601 is used to add the acquired data identifiers of the data to be published into the first thread pool;

确定模块602,用于根据每个待发布数据的数据标识,确定每个待发布数据的分布式缓存锁;A determination module 602, configured to determine the distributed cache lock of each to-be-released data according to the data identifier of each to-be-released data;

生成模块603,用于根据数据标识,生成第一消息队列MQ;a generating module 603, configured to generate a first message queue MQ according to the data identifier;

发送模块604,用于将第一MQ发送给数据发布端,以用于数据发布端根据第一MQ中的多个数据标识获取多个待发布数据;将多个待发布数据加入到第二线程池中,并向数据获取端发送第二MQ,发布待发布数据。The sending module 604 is used to send the first MQ to the data publishing end, so that the data publishing end can obtain a plurality of data to be published according to the plurality of data identifiers in the first MQ; add the plurality of data to be published to the second thread In the pool, the second MQ is sent to the data acquisition end to publish the data to be published.

可选的,在本发明的一个实施例中,该装置还包括:Optionally, in an embodiment of the present invention, the device further includes:

确定模块602,用于确定待发布数据的数量;A determination module 602, configured to determine the quantity of data to be published;

获取模块,用于当待发布数据的数量大于预设数量时,获取预设数量的待发布数据;或者,an acquisition module, configured to acquire a preset amount of data to be published when the amount of data to be published is greater than a preset amount; or,

获取模块,用于当待发布数据的数量不大于预设数量时,获取待发布数据。The obtaining module is used for obtaining the data to be published when the quantity of the data to be published is not greater than the preset quantity.

可选的,在本发明的一个实施例中,该装置还包括:Optionally, in an embodiment of the present invention, the device further includes:

确定模块602,用于确定分布式缓存锁的时间阈值;A determination module 602, configured to determine the time threshold of the distributed cache lock;

释放模块,用于当分布式缓存锁的使用时间超过时间阈值时,释放分布式缓存锁。The release module is used to release the distributed cache lock when the usage time of the distributed cache lock exceeds the time threshold.

本发明实施例提供的数据发布装置执行图3所示的方法中的各个步骤,并能够达到保证多个客户端的高可用,节省资源的技术效果,为简洁描述,再此不在详细赘述。The data publishing apparatus provided by the embodiment of the present invention executes each step in the method shown in FIG. 3 , and can achieve the technical effects of ensuring high availability of multiple clients and saving resources.

本发明实施例提供的数据发布装置,通过加入模块601,用于将获取的多个待发布数据的数据标识加入第一线程池中;确定模块602,用于根据每个待发布数据的数据标识,确定每个待发布数据的分布式缓存锁;生成模块603,用于根据数据标识,生成第一消息队列MQ;发送模块604,用于将第一MQ发送给数据发布端,以用于数据发布端根据第一MQ中的多个数据标识获取多个待发布数据;将多个待发布数据加入到第二线程池中,并向数据获取端发送第二MQ,发布待发布数据,能够保证多个客户端的高可用,节省资源。In the data publishing device provided by the embodiment of the present invention, the adding module 601 is used for adding the acquired data identifiers of the data to be published into the first thread pool; the determining module 602 is used for adding the data identifiers of each data to be published according to the data identifiers of each data to be published. , determine the distributed cache lock of each data to be published; the generating module 603 is used to generate the first message queue MQ according to the data identifier; the sending module 604 is used to send the first MQ to the data publisher for data The publishing end obtains multiple data to be published according to the multiple data identifiers in the first MQ; adds the multiple data to be published to the second thread pool, and sends the second MQ to the data obtaining end to publish the data to be published, which can ensure High availability of multiple clients, saving resources.

图7是本发明实施例提供的另一种数据发布装置的结构示意图。FIG. 7 is a schematic structural diagram of another data distribution apparatus provided by an embodiment of the present invention.

如图7所示,本发明实施例提供的一种数据发布装置应用于数据发布端,该装置可以包括:接收模块701,获取模块702,加入模块703,发送模块704,发布模块705。As shown in FIG. 7 , a data publishing apparatus provided by an embodiment of the present invention is applied to a data publishing end. The apparatus may include: a receiving module 701 , an obtaining module 702 , an adding module 703 , a sending module 704 , and a publishing module 705 .

接收模块701,用于接收数据获取端发送的第一消息队列MQ;第一MQ中携带有每个待发布数据的数据标识;The receiving module 701 is used for receiving the first message queue MQ sent by the data acquisition terminal; the first MQ carries the data identifier of each data to be published;

获取模块702,用于根据多个数据标识获取数据标识对应的待发布数据;an obtaining module 702, configured to obtain data to be published corresponding to the data identifiers according to multiple data identifiers;

加入模块703,用于将待发布数据加入到第二线程池中;Joining module 703, for adding the data to be published into the second thread pool;

发送模块704,用于根据多个数据标识生成第二MQ,并将第二MQ发送给数据获取端,以用于数据获取端确定多个待发布数据发布;A sending module 704, configured to generate a second MQ according to multiple data identifiers, and send the second MQ to the data acquisition terminal, so that the data acquisition terminal can determine a plurality of to-be-published data releases;

发布模块705,用于根据每个数据标识,发布每个数据标识对应的待发布数据。The publishing module 705 is configured to publish the data to be published corresponding to each data identification according to each data identification.

可选的,在本发明的一个实施例中,发布模块705具体用于:Optionally, in an embodiment of the present invention, the publishing module 705 is specifically configured to:

根据每个数据标识,确定每个数据标识对应的待发布数据的发布页面;According to each data identifier, determine the release page of the to-be-released data corresponding to each data identifier;

当待发布数据的数据所占页面区域与发布页面对应时,发布待发布数据。When the page area occupied by the data of the to-be-published data corresponds to the publishing page, the to-be-published data is published.

可选的,在本发明的一个实施例中,发送模块704,用于根据多个数据标识生成第二MQ,并将第二MQ发送给数据获取端,以用于数据获取端确定多个待发布数据发布。Optionally, in an embodiment of the present invention, the sending module 704 is configured to generate a second MQ according to multiple data identifiers, and send the second MQ to the data acquisition end, so that the data acquisition end determines a plurality of pending MQs. Publish data release.

可选的,在本发明的一个实施例中,该装置还包括删除模块;Optionally, in an embodiment of the present invention, the device further includes a deletion module;

删除模块,用于删除数据发布端与数据标识对应的历史数据。The deletion module is used to delete the historical data corresponding to the data identifier on the data publishing side.

可选的,在本发明的一个实施例中,该装置还包括:Optionally, in an embodiment of the present invention, the device further includes:

生成模块,用于根据数据标识生成第三MQ,第三MQ包括数据标识;a generating module for generating a third MQ according to the data identification, and the third MQ includes the data identification;

发送模块704,用于向终端发送第三MQ,以用于终端根据第三MQ中的数据标识,从数据库中获取待发布数据,并展示待发布数据。The sending module 704 is configured to send the third MQ to the terminal, so that the terminal obtains the data to be published from the database according to the data identifier in the third MQ, and displays the data to be published.

可选的,在本发明的一个实施例中,删除模块,还用于:Optionally, in an embodiment of the present invention, deleting a module is also used to:

当待发布数据发布异常时,删除数据发布端与数据标识对应的历史数据;When the release of the data to be released is abnormal, delete the historical data corresponding to the data identifier at the data release end;

根据多个数据标识生成第四MQ;Generate a fourth MQ according to multiple data identifiers;

向终端发送第四MQ,以用于终端确定待发布数据发布异常。A fourth MQ is sent to the terminal for the terminal to determine that the data to be published is abnormally published.

可选的,在本发明的一个实施例中,生成模块,还用于当待发布数据发布异常时,根据多个数据标识生成第四MQ;Optionally, in an embodiment of the present invention, the generating module is further configured to generate a fourth MQ according to multiple data identifiers when the to-be-published data is published abnormally;

根据第四MQ重新发布待发布数据。The to-be-published data is republished according to the fourth MQ.

可选的,在本发明的一个实施例中,该装置还包括更新模块;Optionally, in an embodiment of the present invention, the device further includes an update module;

更新模块,用于当重新发布待发布数据的次数超过预设次数,更新待发布数据在数据库的状态为发布异常的待发布数据。The updating module is configured to update the to-be-published data whose status in the database is abnormally published when the number of times of re-publishing the to-be-published data exceeds a preset number of times.

本发明实施例提供的数据发布装置执行图4所示的方法中的各个步骤,并能够达到保证多个客户端的高可用,节省资源的技术效果,为简洁描述,再此不在详细赘述。The data publishing apparatus provided by the embodiment of the present invention executes each step in the method shown in FIG. 4, and can achieve the technical effect of ensuring high availability of multiple clients and saving resources.

本发明实施例提供的一种数据发布装置,通过接收模块701,用于接收数据获取端发送的第一消息队列MQ;第一MQ中携带有每个待发布数据的数据标识;获取模块702,用于根据多个数据标识获取数据标识对应的待发布数据;加入模块703,用于将待发布数据加入到第二线程池中;发送模块704,用于根据多个数据标识生成第二MQ,并将第二MQ发送给数据获取端,以用于数据获取端确定多个待发布数据发布;发布模块705,用于根据每个数据标识,发布每个数据标识对应的待发布数据,能够保证多个客户端的高可用,节省资源。A data publishing apparatus provided by an embodiment of the present invention is configured to receive, through a receiving module 701, a first message queue MQ sent by a data acquiring end; the first MQ carries a data identifier of each data to be published; the acquiring module 702, for obtaining the data to be published corresponding to the data identifications according to the multiple data identifications; the adding module 703 for adding the data to be published into the second thread pool; the sending module 704 for generating the second MQ according to the multiple data identifications, and send the second MQ to the data acquisition end, so that the data acquisition end determines a plurality of data to be published; the publishing module 705 is used to publish the data to be published corresponding to each data identification according to each data identification, which can ensure that High availability of multiple clients, saving resources.

图8示出了本发明实施例提供的一种电子设备的硬件结构示意图。FIG. 8 shows a schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present invention.

在电子设备可以包括处理器801以及存储有计算机程序指令的存储器802。The electronic device may include a processor 801 and a memory 802 storing computer program instructions.

具体地,上述处理器801可以包括中央处理器(CPU),或者特定集成电路(Application Specific Integrated Circuit,ASIC),或者可以被配置成实施本发明实施例的一个或多个集成电路。Specifically, the above-mentioned processor 801 may include a central processing unit (CPU), or a specific integrated circuit (Application Specific Integrated Circuit, ASIC), or may be configured as one or more integrated circuits implementing the embodiments of the present invention.

存储器802可以包括用于数据或指令的大容量存储器。举例来说而非限制,存储器802可包括硬盘驱动器(Hard Disk Drive,HDD)、软盘驱动器、闪存、光盘、磁光盘、磁带或通用串行总线(Universal Serial Bus,USB)驱动器或者两个或更多个以上这些的组合。在合适的情况下,存储器802可包括可移除或不可移除(或固定)的介质。在合适的情况下,存储器802可在综合网关容灾设备的内部或外部。在特定实施例中,存储器802是非易失性固态存储器。在特定实施例中,存储器802包括只读存储器(ROM)。在合适的情况下,该ROM可以是掩模编程的ROM、可编程ROM(PROM)、可擦除PROM(EPROM)、电可擦除PROM(EEPROM)、电可改写ROM(EAROM)或闪存或者两个或更多个以上这些的组合。Memory 802 may include mass storage for data or instructions. By way of example and not limitation, memory 802 may include a Hard Disk Drive (HDD), a floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive or two or more A combination of more than one of the above. Memory 802 may include removable or non-removable (or fixed) media, where appropriate. Storage 802 may be internal or external to the integrated gateway disaster recovery device, where appropriate. In certain embodiments, memory 802 is non-volatile solid state memory. In certain embodiments, memory 802 includes read only memory (ROM). Where appropriate, the ROM may be a mask programmed ROM, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), electrically rewritable ROM (EAROM) or flash memory or A combination of two or more of the above.

处理器801通过读取并执行存储器802中存储的计算机程序指令,以实现上述实施例中的任意一种数据发布方法。The processor 801 reads and executes the computer program instructions stored in the memory 802 to implement any one of the data publishing methods in the foregoing embodiments.

在一个示例中,电子设备还可包括通信接口803和总线810。其中,如图8所示,处理器801、存储器802、通信接口803通过总线810连接并完成相互间的通信。In one example, the electronic device may also include a communication interface 803 and a bus 810 . Among them, as shown in FIG. 8 , the processor 801 , the memory 802 , and the communication interface 803 are connected through the bus 810 and complete the mutual communication.

通信接口803,主要用于实现本发明实施例中各模块、装置、单元和/或设备之间的通信。The communication interface 803 is mainly used to implement communication between modules, apparatuses, units and/or devices in the embodiments of the present invention.

总线810包括硬件、软件或两者,将电子设备的部件彼此耦接在一起。举例来说而非限制,总线可包括加速图形端口(AGP)或其他图形总线、增强工业标准架构(EISA)总线、前端总线(FSB)、超传输(HT)互连、工业标准架构(ISA)总线、无限带宽互连、低引脚数(LPC)总线、存储器总线、微信道架构(MCA)总线、外围组件互连(PCI)总线、PCI-Express(PCI-X)总线、串行高级技术附件(SATA)总线、视频电子标准协会局部(VLB)总线或其他合适的总线或者两个或更多个以上这些的组合。在合适的情况下,总线810可包括一个或多个总线。尽管本发明实施例描述和示出了特定的总线,但本发明考虑任何合适的总线或互连。The bus 810 includes hardware, software, or both, coupling the components of the electronic device to each other. By way of example and not limitation, the bus may include Accelerated Graphics Port (AGP) or other graphics bus, Enhanced Industry Standard Architecture (EISA) bus, Front Side Bus (FSB), HyperTransport (HT) Interconnect, Industry Standard Architecture (ISA) Bus, Infiniband Interconnect, Low Pin Count (LPC) Bus, Memory Bus, Microchannel Architecture (MCA) Bus, Peripheral Component Interconnect (PCI) Bus, PCI-Express (PCI-X) Bus, Serial Advanced Technology Attachment (SATA) bus, Video Electronics Standards Association Local (VLB) bus or other suitable bus or a combination of two or more of the above. Bus 810 may include one or more buses, where appropriate. Although embodiments of the present invention describe and illustrate a particular bus, the present invention contemplates any suitable bus or interconnect.

该电子设备可以执行本发明实施例中的数据发布方法,从而实现结合图3和图4描述的数据发布方法。The electronic device may execute the data publishing method in the embodiment of the present invention, thereby implementing the data publishing method described in conjunction with FIG. 3 and FIG. 4 .

另外,结合上述实施例中的数据发布方法,本发明实施例可提供一种计算机存储介质来实现。该计算机存储介质上存储有计算机程序指令;该计算机程序指令被处理器执行时实现上述实施例中的任意一种数据发布方法。In addition, in combination with the data publishing method in the foregoing embodiments, the embodiments of the present invention may provide a computer storage medium for implementation. Computer program instructions are stored on the computer storage medium; when the computer program instructions are executed by the processor, any one of the data publishing methods in the foregoing embodiments is implemented.

需要明确的是,本发明并不局限于上文所描述并在图中示出的特定配置和处理。为了简明起见,这里省略了对已知方法的详细描述。在上述实施例中,描述和示出了若干具体的步骤作为示例。但是,本发明的方法过程并不限于所描述和示出的具体步骤,本领域的技术人员可以在领会本发明的精神后,作出各种改变、修改和添加,或者改变步骤之间的顺序。It is to be understood that the present invention is not limited to the specific arrangements and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above-described embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the sequence of steps after comprehending the spirit of the present invention.

以上所述的结构框图中所示的功能块可以实现为硬件、软件、固件或者它们的组合。当以硬件方式实现时,其可以例如是电子电路、专用集成电路(ASIC)、适当的固件、插件、功能卡等等。当以软件方式实现时,本发明的元素是被用于执行所需数据的程序或者代码段。程序或者代码段可以存储在机器可读介质中,或者通过载波中携带的数据信号在传输介质或者通信链路上传送。“机器可读介质”可以包括能够存储或传输信息的任何介质。机器可读介质的例子包括电子电路、半导体存储器设备、ROM、闪存、可擦除ROM(EROM)、软盘、CD-ROM、光盘、硬盘、光纤介质、射频(RF)链路,等等。代码段可以经由诸如因特网、内联网等的计算机网络被下载。The functional blocks shown in the above-described structural block diagrams may be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, it may be, for example, an electronic circuit, an application specific integrated circuit (ASIC), suitable firmware, a plug-in, a function card, or the like. When implemented in software, the elements of the invention are programs or code segments used to execute the required data. The program or code segments may be stored in a machine-readable medium or transmitted over a transmission medium or communication link by a data signal carried in a carrier wave. A "machine-readable medium" may include any medium that can store or transmit information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, and the like. The code segments may be downloaded via a computer network such as the Internet, an intranet, or the like.

还需要说明的是,本发明中提及的示例性实施例,基于一系列的步骤或者装置描述一些方法或系统。但是,本发明不局限于上述步骤的顺序,也就是说,可以按照实施例中提及的顺序执行步骤,也可以不同于实施例中的顺序,或者若干步骤同时执行。It should also be noted that the exemplary embodiments mentioned in the present invention describe some methods or systems based on a series of steps or devices. However, the present invention is not limited to the order of the above steps, that is, the steps may be performed in the order mentioned in the embodiments, or may be different from the order in the embodiments, or several steps may be performed simultaneously.

以上所述,仅为本发明的具体实施方式,所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的系统、模块和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。应理解,本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本发明的保护范围之内。The above are only specific implementations of the present invention. Those skilled in the art can clearly understand that, for the convenience and simplicity of the description, the specific working process of the above-described systems, modules and units may refer to the foregoing method embodiments. The corresponding process in , will not be repeated here. It should be understood that the protection scope of the present invention is not limited to this. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should all cover within the protection scope of the present invention.

Claims (13)

1.一种数据发布方法,其特征在于,所述方法应用于数据获取端,所述方法包括:1. A data publishing method, wherein the method is applied to a data acquisition terminal, and the method comprises: 将获取的多个待发布数据的数据标识加入第一线程池中,以用于所述数据获取端发送或接收消息队列MQ;adding the acquired data identifiers of the data to be published into the first thread pool for the data acquisition end to send or receive the message queue MQ; 根据每个所述待发布数据的所述数据标识,确定每个所述待发布数据的分布式缓存锁;According to the data identifier of each of the data to be published, determine the distributed cache lock of each of the data to be published; 根据所述数据标识,生成第一消息队列MQ,所述第一MQ包括所述数据标识;generating a first message queue MQ according to the data identifier, where the first MQ includes the data identifier; 将所述第一MQ发送给数据发布端,以用于所述数据发布端根据所述第一MQ中的多个数据标识获取多个待发布数据;将多个所述待发布数据加入到第二线程池中,并向所述数据获取端发送第二MQ,发布所述待发布数据;所述第二MQ包括所述数据标识。The first MQ is sent to the data publishing end, so that the data publishing end can obtain a plurality of data to be published according to the plurality of data identifiers in the first MQ; add a plurality of the data to be published to the first MQ. In the second thread pool, a second MQ is sent to the data acquisition end to publish the data to be published; the second MQ includes the data identifier. 2.根据权利要求1所述的方法,其特征在于,所述方法还包括:2. The method according to claim 1, wherein the method further comprises: 确定所述待发布数据的数量;determining the quantity of the data to be published; 当所述待发布数据的数量大于预设数量时,获取所述预设数量的所述待发布数据;或者,When the quantity of the data to be published is greater than a preset quantity, acquire the preset quantity of the data to be published; or, 当所述待发布数据的数量不大于所述预设数量时,获取所述待发布数据。When the quantity of the data to be published is not greater than the preset quantity, the data to be published is acquired. 3.根据权利要求1所述的方法,其特征在于,所述方法还包括:3. The method according to claim 1, wherein the method further comprises: 确定所述分布式缓存锁的时间阈值;determining the time threshold of the distributed cache lock; 当所述分布式缓存锁的使用时间超过所述时间阈值时,释放所述分布式缓存锁。When the usage time of the distributed cache lock exceeds the time threshold, the distributed cache lock is released. 4.一种数据发布方法,其特征在于,所述方法应用于数据发布端,所述方法包括:4. A data publishing method, wherein the method is applied to a data publishing terminal, and the method comprises: 接收数据获取端发送的第一消息队列MQ;所述第一MQ中携带有每个待发布数据的数据标识;Receive the first message queue MQ sent by the data acquisition end; the first MQ carries the data identifier of each data to be published; 根据多个所述数据标识获取所述数据标识对应的待发布数据;Acquiring data to be published corresponding to the data identifiers according to a plurality of the data identifiers; 将所述待发布数据加入到第二线程池中,以用于所述数据发布端发送或接收MQ;adding the to-be-published data to the second thread pool for the data publishing end to send or receive MQ; 根据每个所述数据标识,发布所述每个所述数据标识对应的待发布数据。According to each of the data identifiers, the to-be-published data corresponding to each of the data identifiers is published. 5.根据权利要求4所述的方法,其特征在于,所述根据每个所述数据标识,发布所述每个所述数据标识对应的待发布数据,包括:5. The method according to claim 4, wherein, according to each of the data identifiers, publishing the data to be released corresponding to each of the data identifiers, comprising: 根据每个所述数据标识,确定每个所述数据标识对应的待发布数据的发布页面;According to each of the data identifiers, determine the release page of the data to be released corresponding to each of the data identifiers; 当所述待发布数据的数据所占页面区域与所述发布页面对应时,发布所述待发布数据。When the page area occupied by the data of the data to be published corresponds to the published page, the data to be published is published. 6.根据权利要求4所述的方法,其特征在于,所述方法还包括:根据多个所述数据标识生成第二MQ,并将所述第二MQ发送给所述数据获取端,以用于所述数据获取端确定多个所述待发布数据发布。6. The method according to claim 4, characterized in that, the method further comprises: generating a second MQ according to a plurality of the data identifiers, and sending the second MQ to the data acquisition end to use A plurality of the to-be-published data to be published are determined at the data acquisition end. 7.根据权利要求4所述的方法,其特征在于,所述方法还包括:7. The method according to claim 4, wherein the method further comprises: 根据所述数据标识生成第三MQ,所述第三MQ包括数据标识;Generate a third MQ according to the data identification, and the third MQ includes the data identification; 向终端发送所述第三MQ,以用于所述终端根据所述第三MQ中的数据标识,从数据库中获取待发布数据,并展示所述待发布数据。The third MQ is sent to the terminal, so that the terminal obtains the data to be published from the database according to the data identifier in the third MQ, and displays the data to be published. 8.根据权利要求4-7任一项所述的方法,其特征在于,所述方法还包括:8. The method according to any one of claims 4-7, wherein the method further comprises: 当所述待发布数据发布异常时,删除所述数据发布端与所述数据标识对应的历史数据;When the release of the data to be released is abnormal, delete the historical data corresponding to the data identifier of the data release terminal; 根据多个所述数据标识生成第四MQ;generating a fourth MQ according to a plurality of the data identifiers; 向终端发送所述第四MQ,以用于所述终端确定所述待发布数据发布异常。The fourth MQ is sent to the terminal for the terminal to determine that the to-be-published data is published abnormally. 9.根据权利要求8所述的方法,其特征在于,所述方法还包括:9. The method according to claim 8, wherein the method further comprises: 当所述待发布数据发布异常时,根据多个所述数据标识生成第四MQ;When the to-be-published data is published abnormally, generating a fourth MQ according to a plurality of the data identifiers; 根据所述第四MQ重新发布所述待发布数据。The to-be-published data is republished according to the fourth MQ. 10.一种数据发布装置,其特征在于,所述装置应用于数据获取端,所述装置包括:10. A data publishing device, wherein the device is applied to a data acquisition end, and the device comprises: 加入模块,用于将获取的多个待发布数据的数据标识加入第一线程池中;A joining module is used to add the acquired data identifiers of the plurality of data to be published into the first thread pool; 确定模块,用于根据每个所述待发布数据的所述数据标识,确定每个所述待发布数据的分布式缓存锁;A determination module, configured to determine the distributed cache lock of each of the to-be-released data according to the data identifier of each of the to-be-released data; 生成模块,用于根据所述数据标识,生成第一消息队列MQ;a generating module, configured to generate a first message queue MQ according to the data identifier; 发送模块,用于将所述第一MQ发送给数据发布端,以用于所述数据发布端根据所述第一MQ中的多个数据标识获取多个待发布数据;将多个所述待发布数据加入到第二线程池中,并向所述数据获取端发送所述第二MQ,发布所述待发布数据。A sending module, configured to send the first MQ to a data publishing end, so that the data publishing end can obtain a plurality of data to be published according to a plurality of data identifiers in the first MQ; The published data is added to the second thread pool, and the second MQ is sent to the data acquisition end to publish the to-be-published data. 11.一种数据发布装置,其特征在于,所述装置应用于数据发布端,所述装置包括:11. A data publishing device, wherein the device is applied to a data publishing terminal, and the device comprises: 接收模块,用于接收数据获取端发送的第一消息队列MQ;所述第一MQ中携带有每个待发布数据的数据标识;a receiving module, configured to receive the first message queue MQ sent by the data acquisition end; the first MQ carries the data identifier of each data to be published; 获取模块,用于根据多个所述数据标识获取所述数据标识对应的待发布数据;an acquisition module, configured to acquire data to be published corresponding to the data identifiers according to a plurality of the data identifiers; 加入模块,用于将所述待发布数据加入到第二线程池中;a joining module for adding the to-be-published data to the second thread pool; 发送模块,用于根据多个所述数据标识生成第二MQ,并将所述第二MQ发送给所述数据获取端,以用于所述数据获取端确定多个所述待发布数据发布;a sending module, configured to generate a second MQ according to a plurality of the data identifiers, and send the second MQ to the data acquisition end, so that the data acquisition end determines a plurality of the to-be-published data releases; 发布模块,用于根据每个所述数据标识,发布所述每个所述数据标识对应的待发布数据。A publishing module, configured to publish the data to be published corresponding to each of the data identifications according to each of the data identifications. 12.一种电子设备,其特征在于,包括:至少一个处理器、至少一个存储器以及存储在所述存储器中的计算机程序指令,当所述计算机程序指令被所述处理器执行时实现如权利要求1-3中任一项所述的方法或实现如权利要求4-9中任一项所述的方法。12. An electronic device, characterized in that it comprises: at least one processor, at least one memory and computer program instructions stored in the memory, when the computer program instructions are executed by the processor, the implementation as claimed in the claims The method of any one of 1-3 or implementing the method of any one of claims 4-9. 13.一种计算机可读存储介质,其上存储有计算机程序指令,其特征在于,当所述计算机程序指令被处理器执行时实现如权利要求1-3中任一项所述的方法或实现如权利要求4-9中任一项所述的方法。13. A computer-readable storage medium having computer program instructions stored thereon, wherein the method or implementation of any one of claims 1-3 is implemented when the computer program instructions are executed by a processor The method of any of claims 4-9.
CN201911404064.7A 2019-12-30 2019-12-30 Data distribution method, device, equipment and storage medium Pending CN113127217A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911404064.7A CN113127217A (en) 2019-12-30 2019-12-30 Data distribution method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911404064.7A CN113127217A (en) 2019-12-30 2019-12-30 Data distribution method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113127217A true CN113127217A (en) 2021-07-16

Family

ID=76768438

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911404064.7A Pending CN113127217A (en) 2019-12-30 2019-12-30 Data distribution method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113127217A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115396498A (en) * 2022-07-12 2022-11-25 青岛云天励飞科技有限公司 Information distribution method, device, system, electronic device and storage medium
US11922026B2 (en) 2022-02-16 2024-03-05 T-Mobile Usa, Inc. Preventing data loss in a filesystem by creating duplicates of data in parallel, such as charging data in a wireless telecommunications network

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102779132A (en) * 2011-05-12 2012-11-14 阿里巴巴集团控股有限公司 Data updating method, system and database server
CN103199968A (en) * 2012-01-09 2013-07-10 卓望数码技术(深圳)有限公司 Sending method of messages and system
CN103503388A (en) * 2011-09-01 2014-01-08 华为技术有限公司 Distributed queue message reading method, device and system
CN103810072A (en) * 2012-11-09 2014-05-21 上海飞田通信技术有限公司 Device and method for guaranteeing order execution of multithread tasks
CN104092767A (en) * 2014-07-21 2014-10-08 北京邮电大学 A publish/subscribe system with added message queue model and its working method
CN108134830A (en) * 2017-12-20 2018-06-08 马上消费金融股份有限公司 Load balancing method, system, device and storage medium based on message queue
CN108717426A (en) * 2018-05-04 2018-10-30 苏州朗动网络科技有限公司 Update method, device, computer equipment and the storage medium of business data
WO2019029320A1 (en) * 2017-08-11 2019-02-14 华为技术有限公司 Configuration management method, apparatus and device
CN110619098A (en) * 2018-12-26 2019-12-27 北京时光荏苒科技有限公司 Information display method and device, electronic equipment and storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102779132A (en) * 2011-05-12 2012-11-14 阿里巴巴集团控股有限公司 Data updating method, system and database server
CN103503388A (en) * 2011-09-01 2014-01-08 华为技术有限公司 Distributed queue message reading method, device and system
CN103199968A (en) * 2012-01-09 2013-07-10 卓望数码技术(深圳)有限公司 Sending method of messages and system
CN103810072A (en) * 2012-11-09 2014-05-21 上海飞田通信技术有限公司 Device and method for guaranteeing order execution of multithread tasks
CN104092767A (en) * 2014-07-21 2014-10-08 北京邮电大学 A publish/subscribe system with added message queue model and its working method
WO2019029320A1 (en) * 2017-08-11 2019-02-14 华为技术有限公司 Configuration management method, apparatus and device
CN108134830A (en) * 2017-12-20 2018-06-08 马上消费金融股份有限公司 Load balancing method, system, device and storage medium based on message queue
CN108717426A (en) * 2018-05-04 2018-10-30 苏州朗动网络科技有限公司 Update method, device, computer equipment and the storage medium of business data
CN110619098A (en) * 2018-12-26 2019-12-27 北京时光荏苒科技有限公司 Information display method and device, electronic equipment and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
刘利强 等: "《嵌入式软件技术》", 31 August 2009, 哈尔滨工程大学出版社, pages: 116 *
朱里奇 等: "《现代通信网概论》", 30 September 2013, 天津大学出版社, pages: 163 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11922026B2 (en) 2022-02-16 2024-03-05 T-Mobile Usa, Inc. Preventing data loss in a filesystem by creating duplicates of data in parallel, such as charging data in a wireless telecommunications network
US12248687B2 (en) 2022-02-16 2025-03-11 T-Mobile Usa, Inc. Preventing data loss in a filesystem by creating duplicates of data in parallel, such as charging data in a wireless telecommunications network
CN115396498A (en) * 2022-07-12 2022-11-25 青岛云天励飞科技有限公司 Information distribution method, device, system, electronic device and storage medium
CN115396498B (en) * 2022-07-12 2024-09-27 青岛云天励飞科技有限公司 Information publishing method, device, system, electronic device and storage medium

Similar Documents

Publication Publication Date Title
CN111835467B (en) Message sending method, device, computer equipment and storage medium
CN110706069B (en) Exception handling method, device, server and system for order payment request
CN108536532B (en) Batch task processing method and system
CN108874558B (en) Message subscription method of distributed transaction, electronic device and readable storage medium
JP6749926B2 (en) Method, device and system for synchronizing data
CN107766080B (en) Transaction message processing method, device, equipment and system
CN104021043B (en) The interruption re-access method and system of batch application program
CN109815291B (en) Data synchronization method and device, electronic equipment and storage medium
CN110706071B (en) Exception handling method, device, server and system for order payment request
CN114116262B (en) Processing method, device, medium and equipment for distributed asynchronous data communication
CN111274052A (en) Data distribution method, server, and computer-readable storage medium
CN108228363A (en) A kind of message method and device
CN113127217A (en) Data distribution method, device, equipment and storage medium
CN111008206A (en) Method and device for storing state data of cross-chain transaction and storage medium
CN111367694A (en) Event processing method, server and computer storage medium
CN107562555A (en) The cleaning method and server of duplicate data
CN111127088B (en) Method, device, computer equipment and storage medium for realizing final consistency
CN114205322A (en) Message sending method and device, electronic equipment and storage medium
CN114579593A (en) Data transmission method and system and electronic equipment
WO2019019701A1 (en) Processing method for blank invoices recycling, storage medium and server
WO2024179138A1 (en) Message processing method and apparatus, and communication device and storage medium
CN114650287B (en) Breakpoint continuous method, device and system for data file
CN116233154A (en) Configuration data synchronization method and device for multiple systems
CN113783666B (en) Method and device for processing business
CN114238359A (en) Report data management method, device, equipment, medium and computer program product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210716