CN113760572A - Message processing method and device - Google Patents
Message processing method and device Download PDFInfo
- Publication number
- CN113760572A CN113760572A CN202110153651.4A CN202110153651A CN113760572A CN 113760572 A CN113760572 A CN 113760572A CN 202110153651 A CN202110153651 A CN 202110153651A CN 113760572 A CN113760572 A CN 113760572A
- Authority
- CN
- China
- Prior art keywords
- message
- attribute change
- item
- item attribute
- change message
- 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.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0655—Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
- G06F3/0656—Data buffering arrangements
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/544—Buffers; Shared memory; Pipes
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q30/00—Commerce
- G06Q30/06—Buying, selling or leasing transactions
- G06Q30/0601—Electronic shopping [e-shopping]
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Business, Economics & Management (AREA)
- Accounting & Taxation (AREA)
- Finance (AREA)
- Economics (AREA)
- General Business, Economics & Management (AREA)
- Strategic Management (AREA)
- Marketing (AREA)
- Development Economics (AREA)
- Human Computer Interaction (AREA)
- Information Transfer Between Computers (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明公开了一种消息处理方法和装置,涉及计算机技术领域。该方法的一具体实施方式包括:获取第一物品属性变更消息;根据所述物品标识,判断消息缓存数据中是否存在所述物品标识对应的第二物品属性变更消息:若不存在,则根据所述第一物品属性变更消息,在所述消息缓存数据中创建所述物品标识对应的第二物品属性变更消息,并将所述第一物品属性变更消息推送至消息队列;若存在,则根据所述第一物品属性变更消息更新所述第二物品属性变更消息,并增加所述第二物品属性变更消息对应的消息变更次数,以根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列。该实施方式降低了短时间内发送变更消息的频率。
The invention discloses a message processing method and device, and relates to the technical field of computers. A specific implementation of the method includes: obtaining a first item attribute change message; according to the item identifier, judging whether there is a second item attribute change message corresponding to the item identifier in the message cache data; if not, according to the the first item attribute change message, create a second item attribute change message corresponding to the item identifier in the message cache data, and push the first item attribute change message to the message queue; The first item attribute change message updates the second item attribute change message, and increases the number of message changes corresponding to the second item attribute change message, so as to determine whether to change the second item attribute according to the number of message changes. Messages are pushed to the message queue. This embodiment reduces the frequency of sending change messages within a short period of time.
Description
技术领域technical field
本发明涉及计算机技术领域,尤其涉及一种消息处理方法和装置。The present invention relates to the field of computer technology, and in particular, to a message processing method and device.
背景技术Background technique
随着电子商务业务的发展以及物品应用场景的扩展和丰富,物品属性在快速的增长,对应形成了成千上百个属性或者属性组,比如包含了名称、价格、库存的基本属性,包含了颜色、尺寸的销售属性及规格参数等等。基于此,为适应物品属性的快速增长以更好地进行支持业务搜索和展示,很多业务系统使用消息队列传递物品属性的变更消息,以提升用户体验。With the development of e-commerce business and the expansion and enrichment of item application scenarios, item attributes are growing rapidly, corresponding to the formation of thousands of attributes or attribute groups, such as basic attributes including name, price, and inventory, including Sales attributes and specifications of colors, sizes, etc. Based on this, in order to adapt to the rapid growth of item attributes to better support business search and display, many business systems use message queues to transmit item attribute change messages to improve user experience.
在实现本发明过程中,发明人发现现有技术中至少存在如下问题:每一次物品属性的变更消息都会推送至消息队列,如此在短时间内物品属性存在频繁变更的情况下,上游消息发送方会频繁地使用消息队列传递消息,造成大量服务器资源及带宽的占用;而对于下游的消息消费者而言,则需要根据变更消息频繁、高负载地更新对应的物品属性,且其中可能存在大量的无效更新,造成了资源浪费、降低了处理效率。In the process of implementing the present invention, the inventor found that there are at least the following problems in the prior art: every change message of item attributes will be pushed to the message queue. The message queue will be frequently used to transmit messages, which will occupy a large amount of server resources and bandwidth; for downstream message consumers, the corresponding item attributes need to be updated frequently and under high load according to the change message, and there may be a large number of them. Invalid update results in wasting resources and reducing processing efficiency.
发明内容SUMMARY OF THE INVENTION
有鉴于此,本发明实施例提供了一种消息处理方法和装置,能够在保证消息即时性的同时,通过在消息缓存数据中合并接收到的一个或多个物品属性变更消息,避免了短时间内频繁发送变更消息,进而避免了下游消息消费者短时间内频繁地更新物品属性,减少了服务器等资源的浪费。In view of this, the embodiments of the present invention provide a message processing method and device, which can ensure the immediacy of the message, and avoid a short time by merging one or more received item attribute change messages in the message cache data. Change messages are frequently sent within the system, thereby avoiding downstream message consumers from frequently updating item attributes in a short period of time, and reducing the waste of resources such as servers.
为实现上述目的,根据本发明实施例的一个方面,提供了一种消息处理方法,包括:To achieve the above purpose, according to an aspect of the embodiments of the present invention, a message processing method is provided, including:
获取第一物品属性变更消息,所述第一物品属性变更消息指示了物品标识及所述物品标识对应的一个或多个更新后的物品属性值;acquiring a first item attribute change message, where the first item attribute change message indicates an item identifier and one or more updated item attribute values corresponding to the item identifier;
根据所述物品标识,判断消息缓存数据中是否存在所述物品标识对应的第二物品属性变更消息:According to the item identifier, determine whether there is a second item attribute change message corresponding to the item identifier in the message cache data:
若不存在,则根据所述第一物品属性变更消息,在所述消息缓存数据中创建所述物品标识对应的第二物品属性变更消息,并将所述第一物品属性变更消息推送至消息队列;If it does not exist, create a second item attribute change message corresponding to the item identifier in the message cache data according to the first item attribute change message, and push the first item attribute change message to the message queue ;
若存在,则根据所述第一物品属性变更消息更新所述第二物品属性变更消息,并增加所述第二物品属性变更消息对应的消息变更次数,以根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列。If it exists, update the second item attribute change message according to the first item attribute change message, and increase the number of message changes corresponding to the second item attribute change message, so as to determine whether to change the information according to the number of message changes. The second item attribute change message is pushed to the message queue.
可选地,还包括:Optionally, also include:
在所述消息缓存数据中创建所述物品标识对应的第二物品属性变更消息的情况下,针对所述第二物品属性变更消息启动第一定时任务,以在经过第一阈值时间后,根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列。In the case where a second item attribute change message corresponding to the item identifier is created in the message cache data, a first timing task is started for the second item attribute change message, so that after the first threshold time elapses, according to the The number of changes of the message is used to determine whether to push the second item attribute change message to the message queue.
可选地,所述根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列,包括:Optionally, the judging whether to push the second item attribute change message to the message queue according to the number of changes of the message includes:
判断所述第二物品属性变更消息对应的当前消息变更次数是否大于创建所述第二物品属性变更消息时对应的消息变更次数:Determine whether the current message change times corresponding to the second item attribute change message is greater than the corresponding message change times when the second item attribute change message was created:
若大于,则将所述第二物品属性变更消息推送至所述消息队列,并从所述消息缓存数据中删除所述第二物品属性变更消息;If it is greater than that, push the second item attribute change message to the message queue, and delete the second item attribute change message from the message cache data;
若不大于,则直接从所述消息缓存数据中删除所述第二物品属性变更消息。If it is not greater than the value, the second item attribute change message is directly deleted from the message cache data.
可选地,还包括:Optionally, also include:
为所述消息缓存数据启动第二定时任务,以周期性地遍历所述消息缓存数据中的第二物品属性变更消息;starting a second timing task for the message cache data to periodically traverse the second item attribute change messages in the message cache data;
并在所述第二物品属性变更消息对应的发送时间小于当前时间的情况下,根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列,所述发送时间指示了所述第二物品属性变更消息的创建时间与第二阈值时间之和。And when the sending time corresponding to the second item attribute change message is less than the current time, it is judged whether to push the second item attribute change message to the message queue according to the number of message changes, and the sending time indicates is the sum of the creation time of the second item attribute change message and the second threshold time.
可选地,通过解析数据库日志文件的方式获取所述第一物品属性变更消息,所述数据库用于存储所述物品标识及对应的物品属性值。Optionally, the first item attribute change message is acquired by parsing a database log file, and the database is used to store the item identifier and the corresponding item attribute value.
可选地,还包括:Optionally, also include:
在将所述第二物品属性变更消息推送至所述消息队列的情况下,通知所述第二物品属性变更消息的消费者通过远程过程调用的方式,从所述数据库中获取所述物品标识对应的变更后的物品属性值。In the case of pushing the second item attribute change message to the message queue, notify the consumer of the second item attribute change message to obtain the corresponding item identifier from the database by means of a remote procedure call The changed item attribute value of .
可选地,还包括:Optionally, also include:
为所述第二物品属性变更消息设置缓存期限,以在经过所述缓存期限后,从所述消息缓存数据中删除所述第二物品属性变更消息。A cache period is set for the second item attribute change message, so that after the cache period elapses, the second item attribute change message is deleted from the message cache data.
可选地,还包括:Optionally, also include:
在根据所述物品标识,判断消息缓存数据中是否存在所述物品标识对应的第二物品属性变更消息之前,判断所述第一物品属性变更消息对应的消息类型是否可用于创建对应的第二物品属性变更消息。Before determining whether there is a second item attribute change message corresponding to the item identifier in the message cache data according to the item identifier, determine whether the message type corresponding to the first item attribute change message can be used to create a corresponding second item Property change message.
可选地,还包括:Optionally, also include:
在根据所述物品标识,判断消息缓存数据中是否存在所述物品标识对应的第二物品属性变更消息之前,判断当前时间段内是否可创建第二物品属性变更消息。Before determining whether there is a second item attribute change message corresponding to the item identifier in the message cache data according to the item identifier, it is determined whether a second item attribute change message can be created within the current time period.
可选地,在所述消息缓存数据中以键值对的方式存储所述第二物品属性变更消息。Optionally, the second item attribute change message is stored in the message cache data in the form of a key-value pair.
为实现上述目的,根据本发明实施例的另一个方面,提供了一种消息处理装置,包括:物品属性变更消息获取模块、物品属性变更消息处理模块;其中,In order to achieve the above object, according to another aspect of the embodiments of the present invention, a message processing device is provided, including: an item attribute change message acquisition module and an item attribute change message processing module; wherein,
所述物品属性变更消息获取模块,用于获取第一物品属性变更消息,所述第一物品属性变更消息指示了物品标识及所述物品标识对应的一个或多个更新后的物品属性值;The item attribute change message acquisition module is configured to acquire a first item attribute change message, where the first item attribute change message indicates an item identifier and one or more updated item attribute values corresponding to the item identifier;
所述物品属性变更消息处理模块,用于根据所述物品标识,判断消息缓存数据中是否存在所述物品标识对应的第二物品属性变更消息:The item attribute change message processing module is configured to determine, according to the item identifier, whether there is a second item attribute change message corresponding to the item identifier in the message cache data:
若不存在,则根据所述第一物品属性变更消息,在所述消息缓存数据中创建所述物品标识对应的第二物品属性变更消息,并将所述第一物品属性变更消息推送至消息队列;If it does not exist, create a second item attribute change message corresponding to the item identifier in the message cache data according to the first item attribute change message, and push the first item attribute change message to the message queue ;
若存在,则根据所述第一物品属性变更消息更新所述第二物品属性变更消息,并增加所述第二物品属性变更消息对应的消息变更次数,以根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列。If it exists, update the second item attribute change message according to the first item attribute change message, and increase the number of message changes corresponding to the second item attribute change message, so as to determine whether to change the information according to the number of message changes. The second item attribute change message is pushed to the message queue.
可选地,还包括:定时任务启动模块;其中,Optionally, it also includes: a timing task starting module; wherein,
所述定时任务启动模块,用于在所述消息缓存数据中创建所述物品标识对应的第二物品属性变更消息的情况下,针对所述第二物品属性变更消息启动第一定时任务,以在经过第一阈值时间后,根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列。The timing task starting module is configured to start a first timing task for the second item attribute change message in the case of creating a second item attribute change message corresponding to the item identifier in the message cache data, to After the first threshold time has elapsed, whether to push the second item attribute change message to the message queue is determined according to the number of times of message change.
可选地,所述根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列,包括:Optionally, the judging whether to push the second item attribute change message to the message queue according to the number of changes of the message includes:
判断所述第二物品属性变更消息对应的当前消息变更次数是否大于创建所述第二物品属性变更次数时对应的消息变更次数:Determine whether the current message change times corresponding to the second item attribute change message is greater than the message change times corresponding to the creation of the second item attribute change times:
若大于,则将所述第二物品属性变更消息推送至所述消息队列,并从所述消息缓存数据中删除所述第二物品属性变更消息;If it is greater than that, push the second item attribute change message to the message queue, and delete the second item attribute change message from the message cache data;
若不大于,则直接从所述消息缓存数据中删除所述第二物品属性变更消息。If it is not greater than the value, the second item attribute change message is directly deleted from the message cache data.
可选地,所述定时任务启动模块,还用于,Optionally, the timing task startup module is also used to:
为所述消息缓存数据启动第二定时任务,以周期性地遍历所述消息缓存数据中的第二物品属性变更消息;starting a second timing task for the message cache data to periodically traverse the second item attribute change messages in the message cache data;
并在所述第二物品属性变更消息对应的发送时间小于当前时间的情况下,根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列;其中,所述发送时间指示了所述第二物品属性变更消息的创建时间与第二阈值时间之和。And in the case that the sending time corresponding to the second item attribute change message is less than the current time, determine whether to push the second item attribute change message to the message queue according to the number of changes of the message; wherein, the sending The time indicates the sum of the creation time of the second item attribute change message and the second threshold time.
可选地,所述物品属性变更消息获取模块,用于通过解析数据库日志文件的方式获取所述第一物品属性变更消息,所述数据库用于存储所述物品标识及对应的物品属性值。Optionally, the item attribute change message acquisition module is configured to acquire the first item attribute change message by parsing a database log file, and the database is used to store the item identifier and the corresponding item attribute value.
可选地,所述物品属性变更消息处理模块,还用于,Optionally, the item attribute change message processing module is further configured to:
在将所述第二物品属性变更消息推送至所述消息队列的情况下,通知所述第二物品属性变更消息的消费者通过远程过程调用的方式,从所述数据库中获取所述物品标识对应的变更后的物品属性值。In the case of pushing the second item attribute change message to the message queue, notify the consumer of the second item attribute change message to obtain the corresponding item identifier from the database by means of a remote procedure call The changed item attribute value of .
可选地,所述物品属性变更消息处理模块,还用于,Optionally, the item attribute change message processing module is further configured to:
为所述第二物品属性变更消息设置缓存期限,以在经过所述缓存期限后,从所述消息缓存数据中删除所述第二物品属性变更消息。A cache period is set for the second item attribute change message, so that after the cache period elapses, the second item attribute change message is deleted from the message cache data.
可选地,述物品属性变更消息处理模块,还用于,Optionally, the item attribute change message processing module is further configured to:
在根据所述物品标识,判断消息缓存数据中是否存在所述物品标识对应的第二物品属性变更消息之前,判断所述第一物品属性变更消息对应的消息类型是否可用于创建对应的第二物品属性变更消息。Before determining whether there is a second item attribute change message corresponding to the item identifier in the message cache data according to the item identifier, determine whether the message type corresponding to the first item attribute change message can be used to create a corresponding second item Property change message.
可选地,所述物品属性变更消息处理模块,还用于,Optionally, the item attribute change message processing module is further configured to:
在根据所述物品标识,判断消息缓存数据中是否存在所述物品标识对应的第二物品属性变更消息之前,判断当前时间段内是否可创建第二物品属性变更消息。Before determining whether there is a second item attribute change message corresponding to the item identifier in the message cache data according to the item identifier, it is determined whether a second item attribute change message can be created within the current time period.
可选地,在所述消息缓存数据中以键值对的方式存储所述第二物品属性变更消息。Optionally, the second item attribute change message is stored in the message cache data in the form of a key-value pair.
为实现上述目的,根据本发明实施例的再一个方面,提供了一种用于消息处理的电子设备,包括:一个或多个处理器;存储装置,用于存储一个或多个程序,To achieve the above object, according to yet another aspect of the embodiments of the present invention, an electronic device for message processing is provided, comprising: one or more processors; a storage device for storing one or more programs,
当所述一个或多个程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现如上所述的消息处理方法中任一所述的方法。When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of the above message processing methods.
为实现上述目的,根据本发明实施例的又一个方面,提供了一种计算机可读介质,其上存储有计算机程序,所述程序被处理器执行时实现如上所述的消息处理方法中任一所述的方法。In order to achieve the above object, according to another aspect of the embodiments of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, any one of the above message processing methods is implemented. the method described.
上述发明中的一个实施例具有如下优点或有益效果:通过在接收到第一物品属性变更消息时,在消息缓存数据中创建或不断更新第二物品属性变更消息的方式,实现了对所获取的一个或多个第一物品属性变更消息的合并,避免了短时间内频繁发送变更消息,进而避免了下游消息消费者短时间内频繁地更新物品属性,减少了对服务器及带宽的占用,也减少了因频繁无效更新物品属性造成的资源浪费。同时,通过在创建第二物品属性变更消息时,直接通过消息队列发送第一物品属性变更消息的方式,保证了下游消息消费者接收物品属性变更消息的即时性。An embodiment of the above invention has the following advantages or beneficial effects: by creating or continuously updating the second item attribute change message in the message cache data when the first item attribute change message is received, the obtained item attribute change message is realized. The combination of one or more first item attribute change messages avoids frequent sending of change messages in a short period of time, thereby preventing downstream message consumers from frequently updating item attributes in a short period of time, reducing the occupation of servers and bandwidth, and reducing It eliminates the waste of resources caused by frequent and invalid updating of item attributes. At the same time, by directly sending the first item attribute change message through the message queue when creating the second item attribute change message, the immediacy of the downstream message consumer receiving the item attribute change message is ensured.
上述的非惯用的可选方式所具有的进一步效果将在下文中结合具体实施方式加以说明。Further effects of the above non-conventional alternatives will be described below in conjunction with specific embodiments.
附图说明Description of drawings
附图用于更好地理解本发明,不构成对本发明的不当限定。其中:The accompanying drawings are used for better understanding of the present invention and do not constitute an improper limitation of the present invention. in:
图1是根据本发明实施例的消息处理方法的主要流程的示意图;1 is a schematic diagram of a main flow of a message processing method according to an embodiment of the present invention;
图2是根据本发明实施例的另一消息处理方法的主要流程的示意图;2 is a schematic diagram of a main flow of another message processing method according to an embodiment of the present invention;
图3是根据本发明实施例的再一消息处理方法的主要流程的示意图;3 is a schematic diagram of a main flow of a further message processing method according to an embodiment of the present invention;
图4是根据本发明实施例的消息处理装置的主要模块的示意图;4 is a schematic diagram of main modules of a message processing apparatus according to an embodiment of the present invention;
图5是本发明实施例可以应用于其中的示例性系统架构图;5 is an exemplary system architecture diagram to which an embodiment of the present invention may be applied;
图6是适于用来实现本发明实施例的终端设备或服务器的计算机系统的结构示意图。FIG. 6 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present invention.
具体实施方式Detailed ways
以下结合附图对本发明的示范性实施例做出说明,其中包括本发明实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。因此,本领域普通技术人员应当认识到,可以对这里描述的实施例做出各种改变和修改,而不会背离本发明的范围和精神。同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, which include various details of the embodiments of the present invention to facilitate understanding and should be considered as exemplary only. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted from the following description for clarity and conciseness.
图1是根据本发明实施例的消息处理方法的主要流程的示意图,如图1所示,该消息处理方法具体可以包括的步骤如下:FIG. 1 is a schematic diagram of a main flow of a message processing method according to an embodiment of the present invention. As shown in FIG. 1 , the message processing method may specifically include the following steps:
步骤S101,获取第一物品属性变更消息,所述第一物品属性变更消息指示了物品标识及所述物品标识对应的一个或多个物品属性值。Step S101: Obtain a first item attribute change message, where the first item attribute change message indicates an item identifier and one or more item attribute values corresponding to the item identifier.
其中,物品标识是指能够用于区别不同物品的信息,如商品SKU编码等。物品属性是指实际中用于描述物品或者与物品相关的任何属性信息,包括但不限于物品名称、物品价格、物品库存、物品颜色、物品尺寸、规格参数、是否自营、POP、物品图片、物品视频、物品评价等等。以物品标识为0001的手机为例进行说明,随着促销活动、售卖活动等进行,该手机的实际售卖价格、实际库存等属性信息的取值都在不断变化,尤其是双十一、双十二等经典大促活动期间,其属性信息取值会在短时间内出现频繁变更。相应地,为保证展示或者记录的物品属性信息的可靠性,则需要根据实际情况不断更新物品属性值。Among them, the item identifier refers to information that can be used to distinguish different items, such as the product SKU code. Item attributes refer to any attribute information actually used to describe an item or related to an item, including but not limited to item name, item price, item inventory, item color, item size, specification parameters, whether it is self-operated, POP, item pictures, Item videos, item reviews, and more. Take the mobile phone with the item ID 0001 as an example. With the promotion and sales activities, the value of the mobile phone's actual selling price, actual inventory and other attribute information are constantly changing, especially for Double Eleven and Double Ten. During the second-class classic promotion, the value of its attribute information will change frequently in a short period of time. Accordingly, in order to ensure the reliability of the displayed or recorded item attribute information, it is necessary to continuously update the item attribute value according to the actual situation.
一般而言,物品管理系统可以采用数据库记录不同物品对应的属性信息,且可以根据实际情况通过增加、删除、改动数据的方式,不断更新数据库记录的物品标识对应的物品属性值,以向下游需要获取物品属性信息的消费者不断发送物品属性变更消息。Generally speaking, the item management system can use the database to record the attribute information corresponding to different items, and can continuously update the item attribute value corresponding to the item identifier recorded in the database by adding, deleting and changing data according to the actual situation, so as to meet the downstream needs. Consumers who obtain item attribute information continuously send item attribute change messages.
基于此,可以通过解析数据库日志文件的方式获取所述第一物品属性变更消息,所述数据库用于存储所述物品标识及对应的物品属性值。可以理解的是,本实施例仅以采用数据库存储物品对应的属性信息为例进行说明,实际实施过程中还可以采用分布式缓存或者其他存储方式进行替换。具体地,以采用MySQL数据库为例进行说明,则可以通过canal对MySQL数据库的增量日志即Binlog日志文件进行解析,以获取第一物品属性变更消息。更具体地,第一物品属性变更消息指示了物品标识(如0001),以及该物品标识对应的变更后一个或多个物品属性值,如颜色为黄色;价格为100;库存为23等。Based on this, the first item attribute change message can be acquired by parsing a database log file, and the database is used to store the item identifier and the corresponding item attribute value. It can be understood that, this embodiment only uses a database to store attribute information corresponding to an item for description, and in the actual implementation process, a distributed cache or other storage methods may be used for replacement. Specifically, taking the MySQL database as an example for illustration, the incremental log of the MySQL database, that is, the Binlog log file, can be parsed through canal, so as to obtain the property change message of the first item. More specifically, the first item attribute change message indicates the item ID (eg, 0001), and one or more item attribute values after the modification corresponding to the item ID, such as the color is yellow; the price is 100; the stock is 23, etc.
步骤S102,根据所述物品标识,判断消息缓存数据中是否存在所述物品标识对应的第二物品属性变更消息。具体地,若不存在,则继续执行下述步骤S103;若存在,则继续执行下述步骤S104。Step S102, according to the item identifier, determine whether there is a second item attribute change message corresponding to the item identifier in the message cache data. Specifically, if it does not exist, continue to execute the following step S103; if it exists, continue to execute the following step S104.
也即是说,在通过解析数据库日志文件获取到第一物品属性变更消息之后,不直接通过消息队列向下游消息消费者发送该第一物品属性变更消息,而是先在消息缓存数据中合并针对同一物品标识的一个或多个第一物品属性变更消息,即根据第一物品属性变更消息创建或者不断更新第二物品属性变更消息。如此,避免了因短时间内物品属性频繁变更而向下游频繁发送变更消息导致占用大量服务器资源及带宽的问题。That is to say, after the first item attribute change message is obtained by parsing the database log file, the first item attribute change message is not directly sent to the downstream message consumer through the message queue, but is first merged in the message cache data for One or more first item attribute change messages identified by the same item, that is, creating or continuously updating second item attribute change messages according to the first item attribute change messages. In this way, the problem of occupying a large amount of server resources and bandwidth due to frequent changes of item attributes in a short period of time and frequent sending of change messages to the downstream is avoided.
其中,第二物品属性变更消息指示了物品标识对应的一个或多个最新更新后的物品属性值。具体地,第二物品属性变更消息既可以仅指示了第一物品属性变更消息所指示的最新更新的一个或多个物品属性值,也可以指示了根据第一物品属性变更消息最新更新后的物品标识对应的所有物品属性值。如以,物品标识0001对应的所有物品属性仅包括颜色、尺寸、价格、库存为例进行说明,若最新获取的第一物品属性变更消息指示了价格为100、库存为23,则根据该第一物品属性变更消息更新后的第二物品属性变更消息可以仅指示了物品标识0001对应的价格为100、库存为23,也可以指示了物品标识0001对应的价格为100、库存为23、颜色为黄色、尺寸为5.5英寸等。The second item attribute change message indicates one or more newly updated item attribute values corresponding to the item identifier. Specifically, the second item attribute change message may only indicate the latest updated one or more item attribute values indicated by the first item attribute change message, or may indicate the latest updated item according to the first item attribute change message Identifies all corresponding item attribute values. For example, all the item attributes corresponding to the item identifier 0001 only include color, size, price, and inventory as an example for illustration. The updated second item attribute change message may only indicate that the price corresponding to the item ID 0001 is 100 and the stock is 23, or it may indicate that the price corresponding to the item ID 0001 is 100, the stock is 23, and the color is yellow , the size is 5.5 inches, etc.
更进一步地,在存储消息缓存数据中可以键值(key-value)对的方式存储所述第二物品属性变更消息,即采用Hash数据结构存储第二物品属性变更消息。如以在Redis中存储消息缓存数据为例进行说明,则可采用第二物品标识为key值,对应的更新后的一个或多个物品属性值为value值进行存储,如此,可以通过查询物品标识这一key值得方式,迅速确定Redis是否已存在该物品标识对应的value值,即第二物品属性变更消息。此外,在实际的执行过程中,还可以在value值中对应地存储物品标识的发送时间、消息变更次数等信息。Furthermore, the second item attribute change message may be stored in the form of a key-value pair in the stored message cache data, that is, a Hash data structure is used to store the second item attribute change message. For example, taking the storage of message cache data in Redis as an example, the second item identifier can be used as the key value, and the corresponding updated attribute value of one or more items is stored as the value value. In this way, the item identifier can be queried by querying the item identifier. This key value method can quickly determine whether the value corresponding to the item identifier already exists in Redis, that is, the second item attribute change message. In addition, in the actual execution process, information such as the sending time of the item identifier, the number of times of message changes, and the like can also be correspondingly stored in the value value.
其中,发送时间由第二物品属性变更消息的创建时间与第二阈值时间之和确定,而第二阈值时间则指示了使用消息缓存数据合并同一物品标识对应的一个或多个第一物品属性消息的时间长短,具体可以根据实际情况预先设定,如30s、50s等。消息变更次数则指示了从创建第二物品属性变更消息起的第二阈值时间内,该物品标识对应的属性信息发生变更的次数,即接收到的第一物品属性变更消息的总次数。默认地,创建第二物品属性变更消息时对应的消息变更次数为1。可以理解的是,也可以根据实际情况将创建第二物品属性变更消息时对应的消息变更次数为设置为除1以外的其他值。The sending time is determined by the sum of the creation time of the second item attribute change message and the second threshold time, and the second threshold time indicates the use of message cache data to merge one or more first item attribute messages corresponding to the same item identifier The length of time can be preset according to the actual situation, such as 30s, 50s, etc. The number of message changes indicates the number of times the attribute information corresponding to the item identifier is changed within the second threshold time since the creation of the second item attribute change message, that is, the total number of received first item attribute change messages. By default, the corresponding message change times when the second item attribute change message is created is 1. It can be understood that the number of times of message change corresponding to the creation of the second item attribute change message can also be set to a value other than 1 according to the actual situation.
在一种可选的实施方式中,还包括:在根据所述物品标识,判断消息缓存数据中是否存在所述物品标识对应的第二物品属性变更消息之前,判断当前时间段内是否可创建第二物品属性变更消息。In an optional embodiment, the method further includes: before judging whether there is a second item attribute change message corresponding to the item ID in the message cache data according to the item ID, judging whether a first item attribute change message can be created within the current time period 2. Item attribute change message.
也即是说,在实际的执行过程中,可以根据物品属性短时内存在频繁变更的时间规律,合理地设定采用消息缓存数据合并第一物品属性变更消息,即创建第二物品属性变更消息的时间段。如在双十一、双十二等大促期间采用创建第二物品属性变更消息的策略,而在其他时间不采用此策略。如此,既可以可减少短时内频繁发向下游直接发送第一物品属性变更消息,导致下游消息消费者频繁而无效地更新物品属性值,又可以兼顾向下游发送物品属性变更消息的即时性,保证下游消费者接收到的物品属性值得高可用性。That is to say, in the actual execution process, it can be reasonably set to use the message cache data to merge the first item attribute change message, that is, create the second item attribute change message, according to the time rule of frequent change of item attributes in a short period of time. time period. For example, during the Double Eleven, Double Twelve and other big promotions, the strategy of creating a second item attribute change message is adopted, and this strategy is not adopted at other times. In this way, it can not only reduce the frequent sending of the first item attribute change message directly to the downstream in a short period of time, causing the downstream message consumers to update the item attribute value frequently and ineffectively, but also take into account the immediacy of sending the item attribute change message to the downstream, Ensure that the attributes of items received by downstream consumers are worthy of high availability.
更进一步地,还包括:在根据所述物品标识,判断消息缓存数据中是否存在所述物品标识对应的第二物品属性变更消息之前,判断所述第一物品属性变更消息对应的消息类型是否可用于创建对应的第二物品属性变更消息。Further, it also includes: before judging whether there is a second item attribute change message corresponding to the item ID in the message cache data according to the item ID, judging whether the message type corresponding to the first item attribute change message is available. to create a corresponding second item attribute change message.
也即是说,除却根据物品属性短时内存在频繁变更的时间规律,确定当前时间段内是否采用创建第二物品属性变更消息的策略以外,还可以更细粒度地根据下游消息消费者对不同物品属性变更消息的即时性需求,即消息类型的不同,确定是否采用消息缓存数据合并第一物品属性变更消息,即创建第二物品属性变更消息来减少短时间内发送变更消息的频率。如在双十一、双十二大促期间,对价格、库存等物品属性变更消息的即时性要求较高,则可以不采用创建第二物品属性变更消息,而是直接发送所获取的所有所获取的含有价格、库存的第一物品属性变更消息,以保证下游获取价格、库存的即时性及高可用性;另一方面,对于仅指示了物品图片、物品视频等物品属性的第一物品属性变更消息,即时性要求相对较低,为减少对服务器资源或带宽的占用,则可以考虑创建第二物品属性变更消息,以减少短时间内发送变更消息的频率。That is to say, in addition to determining whether to adopt the strategy of creating a second item attribute change message in the current time period according to the time rule of frequent changes in item attributes in a short period of time, it can also be more fine-grained according to downstream message consumers The immediacy requirements of item attribute change messages, that is, different message types, determine whether to use message cache data to merge the first item attribute change message, that is, create a second item attribute change message to reduce the frequency of sending change messages in a short period of time. For example, during the Double Eleven and Double Twelve promotions, there is a high requirement for the immediacy of item attribute change messages such as price and inventory, so instead of creating a second item attribute change message, all the obtained items can be sent directly. The obtained first item attribute change message containing price and inventory, to ensure the immediacy and high availability of downstream acquisition price and inventory; on the other hand, for the first item attribute change that only indicates item attributes such as item pictures and item videos The immediacy requirements of messages are relatively low. In order to reduce the occupation of server resources or bandwidth, you can consider creating a second item attribute change message to reduce the frequency of sending change messages in a short period of time.
步骤S103,根据所述第一物品属性变更消息,在所述消息缓存数据中创建所述物品标识对应的第二物品属性变更消息,并将所述第一物品属性变更消息推送至消息队列。Step S103, according to the first item attribute change message, create a second item attribute change message corresponding to the item identifier in the message cache data, and push the first item attribute change message to a message queue.
也即是说,在消息缓存数据中尚未存在有物品标识对应的第二物品属性变更消息的情况下,在创建第二物品属性变更消息,以在后续获取到该物品标识对应的一个或多个第一物品属性变更消息的情况下,更新该第二物品属性变更消息,而不直接发送后续获取的第一物品属性变更消息,以减少短时间内发送同一物品标识对应的物品属性变更消息的频率。同时,在根据第一物品属性变更消息创建第二物品属性变更消息时,直接将第一物品属性变更消息推送至消息队列,以使下游消息消费者可根据第一物品属性变更消息更新对应的物品属性值,在一定程度上保证了物品属性变更消息的即时性及高可用性。That is to say, in the case where there is no second item attribute change message corresponding to the item identifier in the message cache data, a second item attribute change message is created to obtain one or more items corresponding to the item identifier later. In the case of the first item attribute change message, update the second item attribute change message instead of directly sending the subsequently acquired first item attribute change message, so as to reduce the frequency of sending item attribute change messages corresponding to the same item identifier in a short period of time . At the same time, when the second item attribute change message is created according to the first item attribute change message, the first item attribute change message is directly pushed to the message queue, so that downstream message consumers can update the corresponding item according to the first item attribute change message Attribute value, to a certain extent, ensures the immediacy and high availability of item attribute change messages.
更具体地,本实施例仅以第二物品属性变更消息指示了物品标识对应的最新更显后的一个或多个物品属性值为例进行说明,若第一物品属性变更消息指示了物品标识0001对应的价格为100、库存为23,则根据该第一物品属性变更消息创建后的第二物品属性变更消息也指示了物品标识0001对应的价格为100、库存为23。可以理解的是,该第二物品属性变更消息还可指示了物品标识0001对应的其他物品属性值,以及对应的消息变更次数(如1)、发送时间T1等,其中发送时间T1指示了当前时间T0与第二阈值时间(如30s)之和,即在接下来的30s内,若获取到物品标识0001对应的第一物品属性变更消息,则不直接发送而是对应地更新第二物品属性变更消息;直至经过了30s以后,即到达对应的发送时间,可以直接将第二物品属性变更消息推送至消息队列,并从消息缓存数据中删除该第二物品属性变更消息,以避免同一第二物品属性变更消息的重复发送,减少资源浪费。More specifically, this embodiment is only described by taking the second item attribute change message indicating the latest updated item attribute value or values corresponding to the item identifier as an example. If the first item attribute change message indicates the item identifier 0001 The corresponding price is 100 and the stock is 23, then the second item attribute change message created according to the first item attribute change message also indicates that the price corresponding to the item identifier 0001 is 100 and the stock is 23. It can be understood that the second item attribute change message can also indicate other item attribute values corresponding to the item identifier 0001, as well as the corresponding message change times (such as 1 ), sending time T1, etc., wherein the sending time T1 indicates The sum of the current time T 0 and the second threshold time (such as 30s), that is, in the next 30s, if the first item attribute change message corresponding to the item ID 0001 is obtained, it will not be sent directly but will be updated accordingly. Item attribute change message; until the corresponding sending time has passed after 30s, the second item attribute change message can be directly pushed to the message queue, and the second item attribute change message can be deleted from the message cache data to avoid the same Repeated sending of the second item attribute change message reduces resource waste.
更进一步地,还包括:在所述消息缓存数据中创建所述物品标识对应的第二物品属性变更消息的情况下,针对所述第二物品属性变更消息启动第一定时任务,以在经过第一阈值时间后,根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列。也即是说,为保证消息缓存数据中第二物品属性变更消息发送的即时性,可以通过Timer设定定时任务,以在经过第一阈值时间(如40s)后,将消息缓存数据中的第二物品属性变更消息推送至消息队列,并并从消息缓存数据中删除该第二物品属性变更消息,以避免该同一第二物品属性变更消息的重复发送,减少资源浪费。Further, it also includes: in the case of creating a second item attribute change message corresponding to the item identifier in the message cache data, starting a first timing task for the second item attribute change message, so as to After a threshold time, it is determined whether to push the second item attribute change message to the message queue according to the number of times of message change. That is to say, in order to ensure the immediacy of sending the second item attribute change message in the message cache data, a timer task can be set through the Timer, so that after the first threshold time (such as 40s), the second item in the message cache data is sent. The second item attribute change message is pushed to the message queue, and the second item attribute change message is deleted from the message cache data, so as to avoid repeated transmission of the same second item attribute change message and reduce resource waste.
更具体地,所述根据所述消息变更次数判断所述消息队列发送所述第二物品属性变更消息,包括:判断所述第二物品属性变更消息对应的当前消息变更次数是否大于创建所述第二物品属性变更消息时对应的消息变更次数:若大于,则将所述第二物品属性变更消息推送至所述消息队列,并从所述消息缓存数据中删除所述第二物品属性变更消息;若不大于,则直接从所述消息缓存数据中删除所述第二物品属性变更消息。More specifically, judging that the message queue sends the second item attribute change message according to the message change times includes: judging whether the current message change times corresponding to the second item attribute change message is greater than creating the first item attribute change message. The number of times of message change corresponding to the second item attribute change message: if it is greater than that, push the second item attribute change message to the message queue, and delete the second item attribute change message from the message cache data; If it is not greater than the value, the second item attribute change message is directly deleted from the message cache data.
步骤S104,根据所述第一物品属性变更消息更新所述第二物品属性变更消息,并增加所述第二物品属性变更消息对应的消息变更次数,以根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列。Step S104: Update the second item attribute change message according to the first item attribute change message, and increase the number of message changes corresponding to the second item attribute change message, so as to determine whether to change the message according to the number of message changes. The second item attribute change message is pushed to the message queue.
具体地,本实施例仅以第二物品属性变更消息指示了物品标识对应的最新更显后的一个或多个物品属性值为例进行说明,若第一物品属性变更消息指示了物品标识0001对应的价格为100、库存为23,且消息缓存数据中存在的第二物品属性变更消息指示了价格为150、库存为50,对应的消息变更次数为3,则根据该第一物品属性变更消息更新后的第二物品属性变更消息指示了物品标识0001对应的价格为100、库存为23,对应的消息变更次数增加为5,即从创建第二物品属性变更消息至今,共先后获取到了5个该物品标识对应的第一物品属性变更消息。Specifically, this embodiment is only described by taking the second item attribute change message indicating the latest updated item attribute value or values corresponding to the item identifier as an example. If the first item attribute change message indicates that the item identifier 0001 corresponds to The price is 100, the inventory is 23, and the second item attribute change message in the message cache data indicates that the price is 150, the inventory is 50, and the corresponding message change times is 3, then update according to the first item attribute change message The following second item attribute change message indicates that the price corresponding to the item ID 0001 is 100, the inventory is 23, and the corresponding message change times is increased to 5, that is, since the creation of the second item attribute change message, a total of 5 such items have been obtained successively. The first item attribute change message corresponding to the item identifier.
更进一步地,为避免Timer出现故障,导致设定的第一定时任务无法正常执行,进而使得第二物品属性变更消息无法正常发送,还通过守护进程的方式,设定了周期性的第二定时任务,如每10s执行一次,以保障下游消息消费者接收第二物品属性变更消息的即时性及高可用性。具体地,还包括:为所述消息缓存数据启动第二定时任务,以周期性地遍历所述消息缓存数据中的第二物品属性变更消息;并在所述第二物品属性变更消息对应的发送时间小于当前时间的情况下,根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列,所述发送时间指示了所述第二物品属性变更消息的创建时间与第二阈值时间之和。Furthermore, in order to avoid the failure of the Timer, causing the set first timing task to fail to be executed normally, and thus making the second item attribute change message fail to be sent normally, a periodic second timing is also set by means of a daemon process. The task, for example, is executed every 10s to ensure the immediacy and high availability of the downstream message consumer receiving the second item attribute change message. Specifically, it also includes: starting a second timing task for the message cache data to periodically traverse the second item attribute change messages in the message cache data; and sending the second item attribute change message corresponding to the message cache data. When the time is less than the current time, it is judged whether to push the second item attribute change message to the message queue according to the number of message changes, and the sending time indicates the difference between the creation time of the second item attribute change message and the Sum of the second threshold time.
更具体地,在周期性地便利消息缓存数据的过程中,如发现第二物品属性变更消息对应的发送时间小于当前时间,即该第二物品属性变更消息应发送而未发送,则进一步判断该第二物品属性变更消息对应的当前消息变更次数是否大于创建所述第二物品属性变更消息时对应的消息变更次数(如1):若大于,则表明该第二物品属性变更消息自创建后有发生变更,故将所述第二物品属性变更消息推送至所述消息队列,并从所述消息缓存数据中删除所述第二物品属性变更消息,以避免重复发送;若不大于,则表明该第二物品属性变更消息自创建后未发生变更,故直接从所述消息缓存数据中删除所述第二物品属性变更消息,以避免重复发送。More specifically, in the process of periodically facilitating message cache data, if it is found that the sending time corresponding to the second item attribute change message is less than the current time, that is, the second item attribute change message should be sent but not sent, then further judge the Whether the current message change times corresponding to the second item attribute change message is greater than the corresponding message change times when the second item attribute change message was created (eg 1): if it is greater, it means that the second item attribute change message has been changed since it was created If the change occurs, the second item attribute change message is pushed to the message queue, and the second item attribute change message is deleted from the message cache data to avoid repeated sending; The second item attribute change message has not changed since it was created, so the second item attribute change message is directly deleted from the message cache data to avoid repeated transmission.
此外,为避免因Timer故障或者守护进程故障等导致的消息缓存数据中已过期的第二物品属性变更消息的残留累积,以保证消息缓存装置存储空间的有效利用率,还包括:为所述第二物品属性变更消息设置缓存期限,以在经过所述缓存期限后,从所述消息缓存数据中删除所述第二物品属性变更消息。如以缓存期限即TTL(Time To Live)为100s为例,则自动清除在消息缓存数据中的已存储有100s的第二物品属性变更消息。In addition, in order to avoid residual accumulation of expired second item attribute change messages in the message cache data due to Timer failure or daemon process failure, etc., to ensure the effective utilization of the storage space of the message cache device, it also includes: for the first item A cache period is set for the second item attribute change message, so that after the cache period elapses, the second item attribute change message is deleted from the message cache data. For example, taking the cache period, that is, TTL (Time To Live) as 100s, as an example, the second item attribute change message that has been stored for 100s in the message cache data is automatically cleared.
值得注意的是,在第二物品属性变更消息仅指示了第一物品属性变更消息所指示的最新更新的一个或多个物品属性值的情况下,若先后获取的第一物品属性变更消息所指示的存在更新的物品属性有所不同,则仅向消息队列推送最新更新的第二物品属性变更消息,存在遗漏更新过的物品属性的情况,在一定程度上降低了下游接收到的第二物品属性变更消息高可用性。而若第二物品属性变更消息指示了根据第一物品属性变更消息最新更新后的物品标识对应的所有物品属性值,虽可以避免更新的物品属性遗漏,但随着物品属性的快速增加,受限于消息容量的大小,第二物品属性变更消息中指示的发生更新的物品属性数量有限。It is worth noting that, in the case where the second item attribute change message only indicates the latest updated one or more item attribute values indicated by the first item attribute change message, if the successively acquired first item attribute change messages indicate If the updated item attributes are different, only the latest updated second item attribute change message will be pushed to the message queue, and there is a situation where the updated item attributes are omitted, which reduces the second item attributes received downstream to a certain extent. Change message high availability. However, if the second item attribute change message indicates all the item attribute values corresponding to the latest updated item identifier according to the first item attribute change message, although the omission of the updated item attribute can be avoided, with the rapid increase of the item attribute, the limitation is limited. Due to the size of the message capacity, the number of updated item attributes indicated in the second item attribute change message is limited.
基于此,在避免短时间内向下游频繁发送变更消息的同时,保证下游接收到的第二物品属性变更消息的高可用性,还包括:在将所述第二物品属性变更消息推送至所述消息队列的情况下,通知所述第二物品属性变更消息的消费者通过远程过程调用的方式,从所述数据库中获取所述物品标识对应的变更后的物品属性值。也即是说,通过创建第二物品属性变更消息减少向下游发送物品属性变更消息的频率,以使下游消息消费者在知晓了物品属性变更的同时,通过RPC远程过程调用的方式,从存储有物品标识对应的属性信息的MySQL数据库中查询物品标识对应的最新更新后的所有物品属性值。Based on this, while avoiding frequent sending of change messages to the downstream in a short period of time, ensuring the high availability of the second item attribute change message received downstream, the method further includes: pushing the second item attribute change message to the message queue In the case of notifying the consumer of the second item attribute change message, the changed item attribute value corresponding to the item identifier is obtained from the database by means of a remote procedure call. That is to say, by creating a second item attribute change message, the frequency of sending item attribute change messages to the downstream is reduced, so that the downstream message consumers can know the item attribute change and use the RPC remote procedure call from the storage. Query the latest updated attribute values of all items corresponding to the item ID in the MySQL database of the attribute information corresponding to the item ID.
基于上述实施例,通过在接收到第一物品属性变更消息时,在消息缓存数据中创建或不断更新第二物品属性变更消息的方式,实现了对所获取的一个或多个第一物品属性变更消息的合并,避免了短时间内频繁发送变更消息,进而避免了下游消息消费者短时间内频繁地更新物品属性,减少了对服务器及带宽的占用,也减少了因频繁无效更新物品属性造成的资源浪费。同时,通过在创建第二物品属性变更消息时,直接通过消息队列发送第一物品属性变更消息的方式,保证了下游消息消费者接收物品属性变更消息的即时性。Based on the above embodiment, when the first item attribute change message is received, the second item attribute change message is created or continuously updated in the message cache data, so as to realize the change of one or more acquired first item attributes. The merging of messages avoids frequent sending of change messages in a short period of time, thereby preventing downstream message consumers from frequently updating item attributes in a short period of time, reducing the occupation of servers and bandwidth, and reducing the frequent and invalid update of item attributes. Waste of resources. At the same time, by directly sending the first item attribute change message through the message queue when creating the second item attribute change message, the immediacy of the downstream message consumer receiving the item attribute change message is ensured.
参见图2,在上述实施例的基础上,本发明实施例提供了另一种消息处理方法,该方法具体可以包括的步骤如下:Referring to FIG. 2 , on the basis of the foregoing embodiment, the embodiment of the present invention provides another message processing method, which may specifically include the following steps:
步骤S201,获取第一物品属性变更消息,所述第一物品属性变更消息指示了物品标识及所述物品标识对应的一个或多个更新后的物品属性值。Step S201: Obtain a first item attribute change message, where the first item attribute change message indicates an item identifier and one or more updated item attribute values corresponding to the item identifier.
步骤S202,判断当前时间段内是否可创建第二物品属性变更消息。若可创建,则继续执行下述步骤S203;若不可创建,则继续执行下述步骤S204。Step S202, determining whether a second item attribute change message can be created within the current time period. If it can be created, continue to execute the following step S203; if it cannot be created, continue to execute the following step S204.
步骤S203,在当前时间段内可创建第二物品属性变更消息的基础上,判断所述第一物品属性变更消息对应的消息类型是否可用于创建对应的第二物品属性变更消息。若可创建,则继续执行下述步骤S205;若不可创建,则继续执行下述步骤S204。Step S203, on the basis that the second item attribute change message can be created in the current time period, determine whether the message type corresponding to the first item attribute change message can be used to create the corresponding second item attribute change message. If it can be created, continue to execute the following step S205; if it cannot be created, continue to execute the following step S204.
步骤S204,在不可创建第二物品属性变更消息的基础上,将第一物品属性变更消息推送至所述消息队列。Step S204, on the basis that the second item attribute change message cannot be created, push the first item attribute change message to the message queue.
步骤S205,根据所述物品标识,判断消息缓存数据中是否存在所述物品标识对应的第二物品属性变更消息。若存在,则继续执行下述步骤S207;若不存在,则继续执行下述步骤S206。Step S205, according to the item identifier, determine whether there is a second item attribute change message corresponding to the item identifier in the message cache data. If it exists, continue to execute the following step S207; if not, continue to execute the following step S206.
步骤S206,根据所述第一物品属性变更消息,在所述消息缓存数据中创建所述物品标识对应的第二物品属性变更消息,并将所述第一物品属性变更消息推送至消息队列。本实施例仅此时第二物品属性变更消息对应的消息变更次数为1进行说明。Step S206, according to the first item attribute change message, create a second item attribute change message corresponding to the item identifier in the message cache data, and push the first item attribute change message to a message queue. This embodiment is described only when the number of message changes corresponding to the second item attribute change message is 1 at this time.
步骤S207,根据所述第一物品属性变更消息更新所述第二物品属性变更消息,并增加所述第二物品属性变更消息对应的消息变更次数。Step S207: Update the second item attribute change message according to the first item attribute change message, and increase the number of message changes corresponding to the second item attribute change message.
步骤S208,针对所述第二物品属性变更消息启动第一定时任务。如此,可以在经过第一阈值时间(如30s)后,根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列。Step S208, starting a first timed task for the second item attribute change message. In this way, after a first threshold time (eg 30s) has elapsed, it may be determined whether to push the second item attribute change message to the message queue according to the number of times of message change.
步骤S209,在经过第一阈值时间后,判断第二物品属性变更消息对应的当前消息变更次数是否大于1,即判断第二物品属性变更消息自创建后是否发生更新。若大于,则继续执行下述步骤S210;若不大于,则继续执行下述步骤S211。Step S209, after the first threshold time has elapsed, determine whether the current message change times corresponding to the second item attribute change message is greater than 1, that is, determine whether the second item attribute change message has been updated since it was created. If it is greater than, continue to execute the following step S210; if not, continue to execute the following step S211.
步骤S210,将所述第二物品属性变更消息推送至所述消息队列,并删除从所述消息缓存数据中删除的所述第二物品属性变更消息。Step S210, push the second item attribute change message to the message queue, and delete the second item attribute change message deleted from the message cache data.
步骤S211,直接从所述消息缓存数据中删除所述第二物品属性变更消息。可以理解的是,由于在创建第二物品属性变更消息的时候,已经发送过对应的第一物品属性变更消息,因此在第二物品属性变更消息未发生更新的情况下,为避免重复发送可直接删除第二物品属性变更消息,同时节省缓存空间。Step S211, directly delete the second item attribute change message from the message cache data. It can be understood that, since the corresponding first item attribute change message has been sent when the second item attribute change message is created, if the second item attribute change message has not been updated, in order to avoid repeated transmission, you can directly Delete the second item attribute change message, while saving cache space.
在此基础上,为避免Timer出现故障,导致设定的第一定时任务无法正常执行,进而使得第二物品属性变更消息无法正常发送,还通过守护进程的方式,设定了周期性的第二定时任务,如每10s执行一次,以保障下游消息消费者接收第二物品属性变更消息的即时性及高可用性。具体涉及的消息处理方法如图3所示,对应的步骤如下:On this basis, in order to avoid the failure of the Timer, the set first timed task cannot be executed normally, and thus the second item attribute change message cannot be sent normally, and a periodic second timer is also set by means of a daemon process. Timed tasks, such as executing once every 10s, ensure the immediacy and high availability of downstream message consumers receiving the second item attribute change message. The specific message processing method involved is shown in Figure 3, and the corresponding steps are as follows:
步骤S301,为所述消息缓存数据启动第二定时任务,以周期性地遍历所述消息缓存数据中的第二物品属性变更消息。Step S301 , start a second timing task for the message cache data, so as to periodically traverse the second item attribute change messages in the message cache data.
步骤S302,判断第二物品属性变更消息对应的发送时间是否小于当前时间;其中,发送时间指示了所述第二物品属性变更消息的创建时间与第二阈值时间(如30s)之和。若小于,则表明该第二物品属性变更消息应发送而未发送,继续执行下述步骤S303;若不小于,则表明该第二物品属性变更消息尚未到Timer执行发送的时间,结束对该第二物品属性变更消息的操作,继续遍历其他第二物品属性变更消息。Step S302, judging whether the sending time corresponding to the second item attribute change message is less than the current time; wherein, the sending time indicates the sum of the creation time of the second item attribute change message and a second threshold time (eg 30s). If it is less than that, it means that the second item attribute change message should be sent but not sent, and the following step S303 is continued; The operation of the second item attribute change message continues to traverse other second item attribute change messages.
步骤S303,判断第二物品属性变更消息对应的当前消息变更次数是否大于创建所述第二物品属性变更消息时对应的消息变更次数(即1)。若大于,则表明该第二物品属性变更消息自创建后有发生变更,继续执行下述步骤S304;若不大于,则表明该第二物品属性变更消息自创建后未发生变更,继续执行下述步骤S305。Step S303, judging whether the current message change times corresponding to the second item attribute change message is greater than the corresponding message change times (ie, 1) when the second item attribute change message was created. If it is greater than that, it means that the second item attribute change message has changed since it was created, and the following step S304 is continued; Step S305.
步骤S304,将所述第二物品属性变更消息推送至所述消息队列,并从所述消息缓存数据中删除所述第二物品属性变更消息,以避免重复发送。Step S304, push the second item attribute change message to the message queue, and delete the second item attribute change message from the message cache data to avoid repeated sending.
步骤S305,直接从所述消息缓存数据中删除所述第二物品属性变更消息,以避免重复发送。Step S305, directly delete the second item attribute change message from the message cache data to avoid repeated sending.
参见图4,在上述实施例的基础上,本发明实施例提供了一种消息处理装置400,包括:物品属性变更消息获取模块401、物品属性变更消息处理模块402;其中,Referring to FIG. 4 , on the basis of the above-mentioned embodiments, an embodiment of the present invention provides a
所述物品属性变更消息获取模块401,用于获取第一物品属性变更消息,所述第一物品属性变更消息指示了物品标识及所述物品标识对应的一个或多个更新后的物品属性值;The item attribute change
所述物品属性变更消息处理模块402,用于根据所述物品标识,判断消息缓存数据中是否存在所述物品标识对应的第二物品属性变更消息:The item attribute change
若不存在,则根据所述第一物品属性变更消息,在所述消息缓存数据中创建所述物品标识对应的第二物品属性变更消息,并将所述第一物品属性变更消息推送至消息队列;If it does not exist, create a second item attribute change message corresponding to the item identifier in the message cache data according to the first item attribute change message, and push the first item attribute change message to the message queue ;
若存在,则根据所述第一物品属性变更消息更新所述第二物品属性变更消息,并增加所述第二物品属性变更消息对应的消息变更次数,以根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列。If it exists, update the second item attribute change message according to the first item attribute change message, and increase the number of message changes corresponding to the second item attribute change message, so as to determine whether to change the information according to the number of message changes. The second item attribute change message is pushed to the message queue.
在一种可选的实施方式中,还包括:定时任务启动模块403;其中,In an optional implementation manner, it further includes: a timing
所述定时任务启动模块,用于在所述消息缓存数据中创建所述物品标识对应的第二物品属性变更消息的情况下,针对所述第二物品属性变更消息启动第一定时任务,以在经过第一阈值时间后,根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列。The timing task starting module is configured to start a first timing task for the second item attribute change message in the case of creating a second item attribute change message corresponding to the item identifier in the message cache data, to After the first threshold time has elapsed, whether to push the second item attribute change message to the message queue is determined according to the number of times of message change.
在一种可选的实施方式中,所述根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列,包括:In an optional implementation manner, the judging whether to push the second item attribute change message to the message queue according to the number of changes of the message includes:
判断所述第二物品属性变更消息对应的当前消息变更次数是否大于创建所述第二物品属性变更次数时对应的消息变更次数:Determine whether the current message change times corresponding to the second item attribute change message is greater than the message change times corresponding to the creation of the second item attribute change times:
若大于,则将所述第二物品属性变更消息推送至所述消息队列,并从所述消息缓存数据中删除所述第二物品属性变更消息;If it is greater than that, push the second item attribute change message to the message queue, and delete the second item attribute change message from the message cache data;
若不大于,则直接从所述消息缓存数据中删除所述第二物品属性变更消息。If it is not greater than the value, the second item attribute change message is directly deleted from the message cache data.
在一种可选的实施方式中,所述定时任务启动模块403,还用于,In an optional implementation manner, the timing
为所述消息缓存数据启动第二定时任务,以周期性地遍历所述消息缓存数据中的第二物品属性变更消息;starting a second timing task for the message cache data to periodically traverse the second item attribute change messages in the message cache data;
并在所述第二物品属性变更消息对应的发送时间小于当前时间的情况下,根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列;其中,所述发送时间指示了所述第二物品属性变更消息的创建时间与第二阈值时间之和。And in the case that the sending time corresponding to the second item attribute change message is less than the current time, determine whether to push the second item attribute change message to the message queue according to the number of changes of the message; wherein, the sending The time indicates the sum of the creation time of the second item attribute change message and the second threshold time.
在一种可选的实施方式中,所述物品属性变更消息获取模块401,用于通过解析数据库日志文件的方式获取所述第一物品属性变更消息,所述数据库用于存储所述物品标识及对应的物品属性值。In an optional implementation manner, the item attribute change
在一种可选的实施方式中,所述物品属性变更消息处理模块402,还用于,In an optional implementation manner, the item attribute change
在将所述第二物品属性变更消息推送至所述消息队列的情况下,通知所述第二物品属性变更消息的消费者通过远程过程调用的方式,从所述数据库中获取所述物品标识对应的变更后的物品属性值。In the case of pushing the second item attribute change message to the message queue, notify the consumer of the second item attribute change message to obtain the corresponding item identifier from the database by means of a remote procedure call The changed item attribute value of .
在一种可选的实施方式中,所述物品属性变更消息处理模块402,还用于,In an optional implementation manner, the item attribute change
为所述第二物品属性变更消息设置缓存期限,以在经过所述缓存期限后,从所述消息缓存数据中删除所述第二物品属性变更消息。A cache period is set for the second item attribute change message, so that after the cache period elapses, the second item attribute change message is deleted from the message cache data.
在一种可选的实施方式中,述物品属性变更消息处理模块402,还用于,In an optional implementation manner, the item attribute change
在根据所述物品标识,判断消息缓存数据中是否存在所述物品标识对应的第二物品属性变更消息之前,判断所述第一物品属性变更消息对应的消息类型是否可用于创建对应的第二物品属性变更消息。Before determining whether there is a second item attribute change message corresponding to the item identifier in the message cache data according to the item identifier, determine whether the message type corresponding to the first item attribute change message can be used to create a corresponding second item Property change message.
在一种可选的实施方式中,所述物品属性变更消息处理模块402,还用于,In an optional implementation manner, the item attribute change
在根据所述物品标识,判断消息缓存数据中是否存在所述物品标识对应的第二物品属性变更消息之前,判断当前时间段内是否可创建第二物品属性变更消息。Before determining whether there is a second item attribute change message corresponding to the item identifier in the message cache data according to the item identifier, it is determined whether a second item attribute change message can be created within the current time period.
在一种可选的实施方式中,在所述消息缓存数据中以键值对的方式存储所述第二物品属性变更消息。具体地,可采用的消息数据缓存装置包括但不限于Redis等。In an optional implementation manner, the second item attribute change message is stored in the message cache data in the form of a key-value pair. Specifically, the available message data caching device includes, but is not limited to, Redis and the like.
图5示出了可以应用本发明实施例的消息处理方法或消息处理装置的示例性系统架构500。FIG. 5 shows an
如图5所示,系统架构500可以包括终端设备501、502、503,网络504和服务器505。网络504用以在终端设备501、502、503和服务器505之间提供通信链路的介质。网络504可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。As shown in FIG. 5 , the
用户可以使用终端设备501、502、503通过网络504与服务器505交互,以接收或发送消息等。终端设备501、502、503上可以安装有客户端应用。The user can use the
终端设备501、502、503可以是具有显示屏并且支持网页浏览的各种电子设备,包括但不限于智能手机、平板电脑、膝上型便携计算机和台式计算机等等。The
服务器505可以是提供各种服务的服务器,例如对用户利用终端设备501、502、503所浏览的物品属性进行管理的服务器。后台管理服务器可以对接收到的物品属性变更消息等进行分析处理,并将处理结果第二物品属性变更消息反馈给终端设备。The
需要说明的是,本发明实施例所提供的消息处理方法一般由服务器505执行,相应地,消息处理装置一般设置于服务器505中。It should be noted that the message processing method provided in the embodiment of the present invention is generally executed by the
应该理解,图5中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。It should be understood that the numbers of terminal devices, networks and servers in FIG. 5 are only illustrative. There can be any number of terminal devices, networks and servers according to implementation needs.
下面参考图6,其示出了适于用来实现本发明实施例的终端设备的计算机系统600的结构示意图。图6示出的终端设备仅仅是一个示例,不应对本发明实施例的功能和使用范围带来任何限制。Referring to FIG. 6 below, it shows a schematic structural diagram of a
如图6所示,计算机系统600包括中央处理单元(CPU)601,其可以根据存储在只读存储器(ROM)602中的程序或者从存储部分608加载到随机访问存储器(RAM)603中的程序而执行各种适当的动作和处理。在RAM 603中,还存储有系统600操作所需的各种程序和数据。CPU 601、ROM 602以及RAM 603通过总线604彼此相连。输入/输出(I/O)接口605也连接至总线604。As shown in FIG. 6, a
以下部件连接至I/O接口605:包括键盘、鼠标等的输入部分606;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分607;包括硬盘等的存储部分608;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分609。通信部分609经由诸如因特网的网络执行通信处理。驱动器610也根据需要连接至I/O接口605。可拆卸介质611,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器610上,以便于从其上读出的计算机程序根据需要被安装入存储部分608。The following components are connected to the I/O interface 605: an
特别地,根据本发明公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本发明公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分609从网络上被下载和安装,和/或从可拆卸介质611被安装。在该计算机程序被中央处理单元(CPU)601执行时,执行本发明的系统中限定的上述功能。In particular, the processes described above with reference to the flowcharts may be implemented as computer software programs in accordance with the disclosed embodiments of the present invention. For example, embodiments disclosed herein include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the method illustrated in the flowchart. In such an embodiment, the computer program may be downloaded and installed from the network via the
需要说明的是,本发明所示的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本发明中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本发明中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the above two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or a combination of any of the above. More specific examples of computer readable storage media may include, but are not limited to, electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read only memory (ROM), erasable Programmable read only memory (EPROM or flash memory), fiber optics, portable compact disk read only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing. In the present invention, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, however, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code therein. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device . Program code embodied on a computer readable medium may be transmitted using any suitable medium including, but not limited to, wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
附图中的流程图和框图,图示了按照本发明各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code that contains one or more logical functions for implementing the specified functions executable instructions. It should also be noted that, in some alternative implementations, the functions noted in the blocks may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It is also noted that each block of the block diagrams or flowchart illustrations, and combinations of blocks in the block diagrams or flowchart illustrations, can be implemented in special purpose hardware-based systems that perform the specified functions or operations, or can be implemented using A combination of dedicated hardware and computer instructions is implemented.
描述于本发明实施例中所涉及到的模块可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的单元(or“模块”)也可以设置在处理器中,例如,可以描述为:一种处理器包括物品属性变更消息获取模块、物品属性变更消息处理模块。其中,这些模块的名称在某种情况下并不构成对该单元本身的限定,例如,定时任务启动模块还可以被描述为“定时任务启动模块模块”。The modules involved in the embodiments of the present invention may be implemented in a software manner, and may also be implemented in a hardware manner. The described unit (or "module") can also be set in the processor, for example, it can be described as: a processor includes an item attribute change message acquisition module and an item attribute change message processing module. Wherein, the names of these modules do not constitute a limitation on the unit itself under certain circumstances. For example, the timing task starting module may also be described as a "timing task starting module module".
作为另一方面,本发明还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的设备中所包含的;也可以是单独存在,而未装配入该设备中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被一个该设备执行时,使得该设备包括:获取第一物品属性变更消息,所述第一物品属性变更消息指示了物品标识及所述物品标识对应的一个或多个更新后的物品属性值;根据所述物品标识,判断消息缓存数据中是否存在所述物品标识对应的第二物品属性变更消息:若不存在,则根据所述第一物品属性变更消息,在所述消息缓存数据中创建所述物品标识对应的第二物品属性变更消息,并将所述第一物品属性变更消息推送至消息队列;若存在,则根据所述第一物品属性变更消息更新所述第二物品属性变更消息,并增加所述第二物品属性变更消息对应的消息变更次数,以根据所述消息变更次数判断是否将所述第二物品属性变更消息推送至所述消息队列。As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or may exist alone without being assembled into the device. The above-mentioned computer-readable medium carries one or more programs, and when the above-mentioned one or more programs are executed by a device, the device includes: acquiring a first item attribute change message, the first item attribute change message indicating The item ID and one or more updated item attribute values corresponding to the item ID; according to the item ID, determine whether there is a second item attribute change message corresponding to the item ID in the message cache data: if not, Then, according to the first item attribute change message, create a second item attribute change message corresponding to the item identifier in the message cache data, and push the first item attribute change message to the message queue; if it exists, Then update the second item attribute change message according to the first item attribute change message, and increase the number of message changes corresponding to the second item attribute change message, so as to determine whether to change the second item according to the number of message changes. The item attribute change message is pushed to the message queue.
根据本发明实施例的技术方案,通过在接收到第一物品属性变更消息时,在消息缓存数据中创建或不断更新第二物品属性变更消息的方式,实现了对所获取的一个或多个第一物品属性变更消息的合并,避免了短时间内频繁发送变更消息,进而避免了下游消息消费者短时间内频繁地更新物品属性,减少了对服务器及带宽的占用,也减少了因频繁无效更新物品属性造成的资源浪费。同时,通过在创建第二物品属性变更消息时,直接通过消息队列发送第一物品属性变更消息的方式,保证了下游消息消费者接收物品属性变更消息的即时性。According to the technical solution of the embodiment of the present invention, when the first item attribute change message is received, the second item attribute change message is created or continuously updated in the message cache data, so that the obtained one or more items The merging of item attribute change messages avoids frequent sending of change messages in a short period of time, thereby preventing downstream message consumers from frequently updating item attributes in a short period of time, reducing the occupation of servers and bandwidth, and reducing frequent invalid updates. Waste of resources caused by item attributes. At the same time, by directly sending the first item attribute change message through the message queue when creating the second item attribute change message, the immediacy of the downstream message consumer receiving the item attribute change message is ensured.
上述具体实施方式,并不构成对本发明保护范围的限制。本领域技术人员应该明白的是,取决于设计要求和其他因素,可以发生各种各样的修改、组合、子组合和替代。任何在本发明的精神和原则之内所作的修改、等同替换和改进等,均应包含在本发明保护范围之内。The above-mentioned specific embodiments do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims (13)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202110153651.4A CN113760572B (en) | 2021-02-04 | 2021-02-04 | Message processing method and device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202110153651.4A CN113760572B (en) | 2021-02-04 | 2021-02-04 | Message processing method and device |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN113760572A true CN113760572A (en) | 2021-12-07 |
| CN113760572B CN113760572B (en) | 2025-07-18 |
Family
ID=78786542
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202110153651.4A Active CN113760572B (en) | 2021-02-04 | 2021-02-04 | Message processing method and device |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN113760572B (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114780564A (en) * | 2022-04-21 | 2022-07-22 | 京东科技控股股份有限公司 | Data processing method, data processing apparatus, electronic device and storage medium |
Citations (10)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105740060A (en) * | 2016-01-18 | 2016-07-06 | 中国人民解放军国防科学技术大学 | Message filtering method in distributed virtual environment |
| US20170134330A1 (en) * | 2015-11-11 | 2017-05-11 | International Business Machines Corporation | Intelligent message queue management |
| CN107291779A (en) * | 2016-04-12 | 2017-10-24 | 百度在线网络技术(北京)有限公司 | Data cached management method and device |
| US20180054400A1 (en) * | 2016-08-18 | 2018-02-22 | Board Of Regents, The University Of Texas System | Interactive Mobile Service For Deploying Automated Protocols |
| US9971987B1 (en) * | 2014-03-25 | 2018-05-15 | Amazon Technologies, Inc. | Out of order data management |
| WO2020015186A1 (en) * | 2018-07-19 | 2020-01-23 | 平安科技(深圳)有限公司 | Method and apparatus for real-time update of page data and electronic device |
| WO2020033553A1 (en) * | 2018-08-07 | 2020-02-13 | Walmart Apollo, Llc | System and method for anomaly detection and deduplication of electronic data feeds |
| CN111026773A (en) * | 2019-11-26 | 2020-04-17 | 泰康保险集团股份有限公司 | Information processing method, information processing device, electronic equipment and storage medium |
| CN111078430A (en) * | 2019-12-09 | 2020-04-28 | 苏州浪潮智能科技有限公司 | A message notification processing method, device and storage medium |
| CN112118352A (en) * | 2020-08-31 | 2020-12-22 | 京东数字科技控股股份有限公司 | Method and device for processing notification trigger message |
-
2021
- 2021-02-04 CN CN202110153651.4A patent/CN113760572B/en active Active
Patent Citations (10)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US9971987B1 (en) * | 2014-03-25 | 2018-05-15 | Amazon Technologies, Inc. | Out of order data management |
| US20170134330A1 (en) * | 2015-11-11 | 2017-05-11 | International Business Machines Corporation | Intelligent message queue management |
| CN105740060A (en) * | 2016-01-18 | 2016-07-06 | 中国人民解放军国防科学技术大学 | Message filtering method in distributed virtual environment |
| CN107291779A (en) * | 2016-04-12 | 2017-10-24 | 百度在线网络技术(北京)有限公司 | Data cached management method and device |
| US20180054400A1 (en) * | 2016-08-18 | 2018-02-22 | Board Of Regents, The University Of Texas System | Interactive Mobile Service For Deploying Automated Protocols |
| WO2020015186A1 (en) * | 2018-07-19 | 2020-01-23 | 平安科技(深圳)有限公司 | Method and apparatus for real-time update of page data and electronic device |
| WO2020033553A1 (en) * | 2018-08-07 | 2020-02-13 | Walmart Apollo, Llc | System and method for anomaly detection and deduplication of electronic data feeds |
| CN111026773A (en) * | 2019-11-26 | 2020-04-17 | 泰康保险集团股份有限公司 | Information processing method, information processing device, electronic equipment and storage medium |
| CN111078430A (en) * | 2019-12-09 | 2020-04-28 | 苏州浪潮智能科技有限公司 | A message notification processing method, device and storage medium |
| CN112118352A (en) * | 2020-08-31 | 2020-12-22 | 京东数字科技控股股份有限公司 | Method and device for processing notification trigger message |
Non-Patent Citations (4)
| Title |
|---|
| WANG, BZ等: "The Design and Implementation of a Website Internal Search System Based on Sphinx", 《2ND INTERNATIONAL CONFERENCE ON ADVANCED DESIGN AND MANUFACTURING ENGINEERING (ADME 2012)》, 15 May 2013 (2013-05-15) * |
| 李峰博;杨文华;: "基于ARCGIS的城乡一体化地籍变更管理系统的设计与实现", 陕西农业科学, no. 12, 25 December 2016 (2016-12-25) * |
| 袁震;: "基于消息中间件的数据同步更新方法", 兵工自动化, no. 07, 15 July 2013 (2013-07-15) * |
| 邹鑫;符敏;陈晓丹;: "基于消息参数的机会网络缓存队列管理策略", 山东工业技术, no. 02, 30 January 2015 (2015-01-30) * |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114780564A (en) * | 2022-04-21 | 2022-07-22 | 京东科技控股股份有限公司 | Data processing method, data processing apparatus, electronic device and storage medium |
Also Published As
| Publication number | Publication date |
|---|---|
| CN113760572B (en) | 2025-07-18 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN112948498A (en) | Method and device for generating global identification of distributed system | |
| CN110162410B (en) | A message processing method and device | |
| CN113312553B (en) | User tag determining method and device | |
| CN113742389A (en) | Service processing method and device | |
| CN113761001A (en) | A cross-system data synchronization method and device | |
| CN113127225A (en) | Method, device and system for scheduling data processing tasks | |
| CN113742617A (en) | Method and device for updating cache | |
| CN113742376B (en) | A method for synchronizing data, a first server, and a system for synchronizing data | |
| CN113760572A (en) | Message processing method and device | |
| CN113360348A (en) | Exception request processing method and device, electronic equipment and storage medium | |
| CN110727694B (en) | Data processing method, device, electronic equipment and storage medium | |
| CN113783913A (en) | A message push management method and device | |
| CN113535768A (en) | Production monitoring method and device | |
| CN112732728A (en) | Data synchronization method and system | |
| CN112130986A (en) | Method for cleaning application memory, server and terminal | |
| CN112068853A (en) | Cross-project synchronous updating method and device | |
| CN113722548B (en) | Method and device for processing quotation relation in service system | |
| CN113132480B (en) | Data transmission method, device and system | |
| CN113760965B (en) | Data query method and device | |
| CN113821519B (en) | Data processing method and domain drive design architecture | |
| CN113760487B (en) | Service processing method and device | |
| CN112688982B (en) | User request processing method and device | |
| CN110851192B (en) | Method and device for responding to degraded switch configuration | |
| CN114756173A (en) | Method, system, device and computer readable medium for file merging | |
| CN113064669A (en) | Loading control method and device |
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 | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |