CN111930530A - Equipment message processing method, device and medium based on Internet of things - Google Patents
Equipment message processing method, device and medium based on Internet of things Download PDFInfo
- Publication number
- CN111930530A CN111930530A CN202010587969.9A CN202010587969A CN111930530A CN 111930530 A CN111930530 A CN 111930530A CN 202010587969 A CN202010587969 A CN 202010587969A CN 111930530 A CN111930530 A CN 111930530A
- Authority
- CN
- China
- Prior art keywords
- message
- messages
- queue
- partitions
- internet
- 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
- 238000003672 processing method Methods 0.000 title claims description 12
- 238000005192 partition Methods 0.000 claims abstract description 149
- 238000012545 processing Methods 0.000 claims abstract description 137
- 238000000034 method Methods 0.000 claims abstract description 46
- 230000008569 process Effects 0.000 claims abstract description 14
- 238000012544 monitoring process Methods 0.000 claims description 10
- 230000007246 mechanism Effects 0.000 claims description 9
- 230000003139 buffering effect Effects 0.000 claims description 5
- 238000004364 calculation method Methods 0.000 claims description 3
- 238000010586 diagram Methods 0.000 description 12
- 230000006870 function Effects 0.000 description 9
- 230000006872 improvement Effects 0.000 description 9
- 238000003860 storage Methods 0.000 description 9
- 238000004590 computer program Methods 0.000 description 7
- 238000005516 engineering process Methods 0.000 description 5
- 238000005520 cutting process Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 230000015556 catabolic process Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 230000003247 decreasing effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000005055 memory storage Effects 0.000 description 1
- 229920001296 polysiloxane Polymers 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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; CALCULATING OR 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
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer And Data Communications (AREA)
- Information Transfer Between Computers (AREA)
Abstract
The application discloses a method, a device and a medium for processing equipment messages based on the Internet of things, wherein the method comprises the following steps: sending the message generated by each Internet of things device to a corresponding partition, wherein the partition is designated for a message queue; a message listener is established in a message processing node, the message listener is configured to monitor messages of all partitions, and the message queues are used for ensuring the message order of all the partitions; creating a message buffer in the message processing node and initializing a plurality of queues in the message buffer; when the message buffer receives the messages of all the partitions sent by the message listener, caching the messages of all the partitions to a preset queue so as to ensure that the messages generated by the same equipment of the internet of things are cached in the same queue in order; and creating a thread pool corresponding to each queue in the message processing node so that each queue can process the cached messages in a single thread mode.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, and a medium for processing an equipment message based on the internet of things.
Background
A large number of internet of things devices need to be accessed in the scene of internet of things, and each internet of things device uploads information related to the internet of things device. With the increase of the access internet of things devices, the requirement on the processing efficiency of the message is higher.
In the prior art, the equipment message processing method still needs to be improved, and if the number of the equipment of the internet of things is too large, the existing equipment message processing method cannot well meet the requirements of users.
Disclosure of Invention
In view of this, embodiments of the present application provide an apparatus message processing method, device and medium based on the internet of things, so as to solve the problem that an apparatus message processing method in the prior art is yet to be improved.
The embodiment of the application adopts the following technical scheme:
the embodiment of the application provides an equipment message processing method based on the Internet of things, which comprises the following steps:
sending the message generated by each Internet of things device to a corresponding partition, wherein the partition is designated for a message queue;
a message listener is established in a message processing node, the message listener is configured to monitor messages of all partitions, and the message queues are used for ensuring the message order of all the partitions;
creating a message buffer in a message processing node, and initializing a plurality of queues in the message buffer;
when the message buffer receives the messages of all the partitions sent by the message listener, caching the messages of all the partitions to a preset queue so as to ensure that the messages generated by the same equipment of the internet of things are cached in the same queue in order;
and creating a thread pool corresponding to each queue in the message processing node so that each queue can process the cached messages in a single thread mode.
It should be noted that, in this embodiment of the present application, a message of each internet of things device is distributed to a fixed message processing node, and a message listener, a message buffer, and a corresponding thread pool of the message processing node perform single-thread processing, so that message ordered processing is implemented.
Further, the configuring the message listener to listen to the messages of all the partitions specifically includes:
and setting the message monitor to monitor by using a single thread, and configuring the message monitor to monitor the messages of all the partitions according to the number of the message monitors.
It should be noted that the message listener uses a single thread to perform the listening, which enables the message listener to have a better listening effect and a higher accuracy. And the message of all the partitions of the message monitor is configured according to the number of the message monitors, so that the monitoring effect of the message monitor is better.
Further, configuring, according to the number of the message listeners, the message listeners to monitor the messages of all the partitions specifically includes:
when the number of the message listeners is single, configuring a single message listener to listen to the messages of all the partitions;
when the number of the message listeners is multiple and is less than the number of the partitions, configuring a single message listener to listen to the messages of one partition or a plurality of partitions;
when the number of the message listeners is multiple and the number of the message listeners is equal to the number of the partitions, configuring a single message listener to listen to the messages of one partition;
and when the number of the message listeners is more than the number of the partitions, configuring the message listeners with the partition number to listen to the messages of each partition.
It should be noted that, when the number of the message listeners is different from the number of the partitions, the message listeners can better listen to the partition messages according to different configuration schemes.
Further, when the number of message listeners is adjusted, the method further includes:
and adjusting the monitoring relation between the current message monitoring node and the partition according to the number of the current message monitors and the monitoring mechanism of the message queue.
It should be noted that, when the number of message listeners is adjusted, the number of message listeners is increased or decreased, and the listening relationship between the current message listening node and the partition is adjusted according to the number of current message listeners and the listening mechanism of the message queue, so that the message listeners can better implement the listening task.
Further, the initializing a plurality of queues specifically includes:
when the message processing node is started, acquiring the number of CPU cores and the concurrency multiple of a server, and taking the number of the CPU cores and the concurrency multiple as parallel processing numbers;
initializing the parallel processing queues.
In the above-described method of initializing a plurality of queues, a plurality of queues to be processed in parallel are initialized.
Further, the caching the messages of all the partitions to a preset queue specifically includes:
performing hash calculation on the ID of the Internet of things equipment to obtain a hash value of the ID of the Internet of things equipment;
and carrying out remainder operation on the hash value of the ID of the Internet of things equipment and the parallel processing number, and caching the partitioned information to a first remainder queue.
It should be noted that, the above-mentioned specific above formula for buffering partitioned messages into a queue can make the buffering effect to the queue better.
Further, after creating a thread pool corresponding to each queue in the message processing node so that each queue performs single-thread processing on the cached message, the method further includes:
and when the message to be processed exists in the queue, establishing a single thread by the corresponding thread pool, and processing the message to be processed.
Further, the messages of the partition comprise subject messages and consumption group messages in the preset partition.
It should be noted that the subject message and the consuming group message in all the partitions can be listened to as required.
The embodiment of the present application further provides an equipment message processing apparatus based on the internet of things, the apparatus includes:
the sending unit is used for sending the message generated by each Internet of things device to a corresponding partition, wherein the partition is designated for a message queue;
a first creating unit, configured to create a message listener in a message processing node, configure the message listener to monitor messages of all partitions, and ensure message ordering of all partitions through the message queue;
a second creating unit, configured to create a message buffer in a message processing node, and initialize a plurality of queues in the message buffer;
the buffer unit is used for buffering the messages of all the partitions to a preset queue when the message buffer receives the messages of all the partitions sent by the message listener so as to ensure that the messages generated by the same equipment of the internet of things are sequentially buffered in the same queue;
and the third creating unit is used for creating a thread pool corresponding to each queue in the message processing node so that each queue can perform single-thread processing on the cached messages.
An embodiment of the present application further provides an apparatus message processing medium based on the internet of things, in which computer-executable instructions are stored, and the computer-executable instructions are configured to:
sending the message generated by each Internet of things device to a corresponding partition, wherein the partition is designated for a message queue;
a message listener is established in a message processing node, the message listener is configured to monitor messages of all partitions, and the message queues are used for ensuring the message order of all the partitions;
creating a message buffer in a message processing node, and initializing a plurality of queues in the message buffer;
when the message buffer receives the messages of all the partitions sent by the message listener, caching the messages of all the partitions to a preset queue so as to ensure that the messages generated by the same equipment of the internet of things are cached in the same queue in order;
and creating a thread pool corresponding to each queue in the message processing node so that each queue can process the cached messages in a single thread mode.
The embodiment of the application adopts at least one technical scheme which can achieve the following beneficial effects: in the embodiment of the application, the message of each equipment of the internet of things is distributed to a fixed message processing node, and the message listener, the message buffer and the corresponding thread pool of the message processing node perform single-thread processing, so that the message is processed in order.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
fig. 1 is a schematic flowchart of a method for processing a device message based on the internet of things according to a first embodiment of the present disclosure;
fig. 2 is a schematic flow chart of a device message processing method based on the internet of things according to a second embodiment of the present specification.
Fig. 3 is a schematic structural diagram of a Kafka message queue cluster provided in the second embodiment of the present specification.
Fig. 4 is a schematic structural diagram of an apparatus message processing device based on the internet of things according to a third embodiment of the present specification.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
Fig. 1 is a schematic flowchart of a method for processing an equipment message based on the internet of things according to an embodiment of the present specification, where the embodiment of the present specification may be implemented by a processor, and the method specifically includes:
step S101, sending the message generated by each Internet of things device to a corresponding partition, wherein the partition is designated for a message queue.
In step S101 in the embodiment of this specification, the processor may allocate a globally unique UUID as an equipment ID to each equipment in the internet of things, and when uploading a message of the equipment in the internet of things, the processor may send the message to an assigned partition of the message queue according to a hash value of the equipment ID, so that the message of the equipment in the internet of things is always in the same partition, and the message queue may ensure the order of the message. The message queue is mq (message queue), which is a data structure of "first-in first-out" in the basic data structure. The method is generally used for solving the problems of application decoupling, asynchronous messages, traffic cutting and the like, and realizes a high-performance, high-availability, scalable and final consistency framework. Embodiments of the present description may employ Kafka, which belongs to one of a variety of MQs.
Step S102, a message monitor is established in the message processing node, the message monitor is configured to monitor the messages of all the partitions, and the message queues are used for ensuring the message order of all the partitions.
In step S102 of this embodiment of the present specification, the message of the partition includes a Topic (Topic) message and a consumption group message within the preset partition. The message listener (MessageReceiver) may be a KafkaMessageReceiver associated with a message queue. The purpose of the message listener may be to receive messages for all partitions.
Step S103, a message buffer is created in the message processing node, and a plurality of queues are initialized in the message buffer.
Step S104, when the message buffer receives the messages of all the partitions sent by the message listener, caching the messages of all the partitions to a preset queue so as to ensure that the messages generated by the same equipment of the internet of things are cached in the same queue in order.
Step S105, a thread pool corresponding to each queue is created in the message processing node, so that each queue performs single-thread processing on the cached message.
In the embodiment of the application, the message of each equipment of the internet of things is distributed to a fixed message processing node, and the message listener, the message buffer and the corresponding thread pool of the message processing node perform single-thread processing, so that the message is processed in order.
Corresponding to the first embodiment of the present specification, fig. 2 is a schematic flowchart of a device message processing method based on the internet of things provided by the second embodiment of the present specification, where the processor in the embodiment of the present specification may perform the following steps, which specifically include:
step S201, sending the message generated by each Internet of things device to a corresponding partition, wherein the partition is designated for a message queue.
In step S201 in the embodiment of this specification, the processor may allocate a globally unique UUID as an equipment ID to each equipment in the internet of things, and when uploading a message of the equipment in the internet of things, the processor may send the message to an assigned partition of the message queue according to a hash value of the equipment ID, so that the message of the equipment in the internet of things is always in the same partition, and the message queue may ensure the order of the message. The message queue is mq (message queue), which is a data structure of "first-in first-out" in the basic data structure. The method is generally used for solving the problems of application decoupling, asynchronous messages, traffic cutting and the like, and realizes a high-performance, high-availability, scalable and final consistency framework. Embodiments of the present description may employ Kafka, which belongs to one of a variety of MQs.
Step S202, a message listener is created in the message processing node, the message listener is configured to monitor the messages of all the partitions, and the message queues are used for ensuring the message ordering of all the partitions.
In step S202 of this embodiment of the present specification, the messages of the partition include a Topic (Topic) message and a consumption group message within the preset partition. The message listener (MessageReceiver) may be a KafkaMessageReceiver associated with a message queue. The purpose of the message listener may be to receive messages for all partitions.
It should be noted that each message processing node may create a message listener.
In step S202 in this embodiment of this specification, configuring the message listener to listen to messages of all partitions specifically includes:
and setting the message monitor to monitor by using a single thread, and configuring the message monitor to monitor the messages of all the partitions according to the number of the message monitors.
Configuring, by the message listener, messages of all the partitions to be listened by the message listener according to the number of the message listeners specifically includes:
when the number of the message listeners is single, configuring a single message listener to listen to the messages of all the partitions, for example, the number of the message listeners is 1, and the number of the partitions is 3, at this time, the message listener needs to listen to 3 partitions, and the message listener needs to listen to the partitioned messages by using a single thread;
when the number of the message listeners is multiple and is less than the number of the partitions, configuring a single message listener to listen to the messages of one partition or multiple partitions, for example, the number of the message listeners is 2, and the number of the partitions is 3, where 1 message listener needs to listen to 1 partition, and another 1 message listener needs to listen to another 2 partitions, and each message listener needs to listen to the messages of the partitions by using a single thread;
when the number of the message listeners is multiple and the number of the message listeners is equal to the number of the partitions, configuring a single message listener to listen to the messages of one partition, for example, the number of the message listeners is 3, and the number of the partitions is 3, at this time, each message listener needs to listen to 1 of the partitions, and each message listener needs to listen to the messages of the partition by using a single thread;
when the number of the message listeners is multiple and the number of the message listeners is greater than the number of the partitions, the message listeners with the number of the partitions are configured to listen to the messages of each partition, for example, the number of the message listeners is 3, and the number of the partitions is 2, at this time, 2 of the message listeners need to listen to 2 partitions respectively, and in addition, 1 of the message listeners is in an idle state, and each message listener needs to listen to the partitioned messages by using a single thread.
Further, when the number of message listeners is adjusted, the method further includes:
and adjusting the monitoring relation between the current message monitoring node and the partition according to the number of the current message monitors and the monitoring mechanism of the message queue.
When a certain message processing node is down, the message corresponding to the partition of the down node can be distributed to another message processing node according to the message queue mechanism, and the down caused by too many messages can be avoided through the message back pressure mechanism of the message processing node, so that the safety and the reliability of the cluster structure can be realized.
And after the downed message processing node is recovered, the corresponding partition can be recovered again according to a message queue mechanism, so that the message processing efficiency of the cluster is recovered.
The message of the partition comprises a subject (Topic) message and a consumption group message in the preset partition.
It should be noted that, in implementing the Kafka message queue listener, the listening designated port may be a flink _ data, and the messages of the internet of things devices are sequentially fetched therefrom.
Step S203, a message buffer is created in the message processing node, and a plurality of queues are initialized in the message buffer.
In step S203 of the embodiment of the present specification, the message buffer may be eventmessagequeue associated with the message queue.
The initializing a plurality of queues specifically includes:
when the message processing node is started, acquiring the number of CPU cores and the concurrency multiple of a server, and taking the number of the CPU cores and the concurrency multiple as parallel processing numbers;
initializing the parallel processing queues.
For example, the number of CPU cores of the server is 10, the concurrency multiple is 3, 10 × 3 — 30 may be used as the number of parallel processes, and 30 queues may be initialized.
It should be noted that, when the processor creates several queues for parallel processing, the maximum capacity of each queue may be 10 times the number of parallel processing. When the number of messages in the corresponding queue exceeds the parallel processing number multiplied by 10, the messages to be processed are overstocked, according to the message queue mechanism, new messages can not be received, the phenomenon that the message processing nodes are down due to overstocked messages after a large number of message bursts or other nodes are down for drainage is prevented, and therefore the message safety processing at the node level is achieved.
Step S204, when the message buffer receives the messages of all the partitions sent by the message listener, the message buffer caches the messages of all the partitions to a preset queue, so as to ensure that the messages generated by the same internet of things device are cached in the same queue in order.
In step S204 in this embodiment of the present description, the caching the messages of all the partitions to a preset queue specifically includes:
performing hash calculation on the ID of the Internet of things equipment to obtain a hash value of the ID of the Internet of things equipment;
and performing remainder operation on the hash value of the ID of the equipment connected with the Internet of things and the parallel processing number, and caching the partitioned messages to a first remainder queue, so that all messages of certain equipment connected with the Internet of things are ensured to be in the same queue, and meanwhile, the orderliness of the messages can be ensured according to the message queue.
For example, the hash value of the ID of the internet of things device and the parallel processing book are subjected to a remainder operation, and when the remainder is 2, the partitioned message is buffered to the second queue.
It should be noted that before step S204 is executed, the device message is also checked, and if the device message is a legitimate message without a device ID, the warning log is discarded and output.
Step S205, a thread pool corresponding to each queue is created in the message processing node, so that each queue performs single-thread processing on the cached message.
In step S205 of this embodiment, a one-to-one thread pool may be created for each queue in the message buffer, and each queue needs to perform single-threaded processing.
It should be noted that several thread pools can be created for parallel processing, and each thread pool only starts 1 thread. And each thread monitors the corresponding queue and takes out the messages in sequence for processing, thereby realizing the ordered and efficient processing of the messages.
Step S206, when the message to be processed exists in the queue, the corresponding thread pool creates a single thread, and the message to be processed is processed.
It should be noted that, the above steps may finally implement message processing of parallel processing number performed by each message processing node, and the message queue ensures ordered processing of messages of a single internet of things device.
It should be noted that the message of each internet of things device is distributed to a fixed certain message processing node, so that the ordered processing of the messages at the cluster level is realized.
It should be noted that, the messages of each equipment of the internet of things are finally processed in sequence by a single thread on the fixed message processing node, so as to realize the ordered processing of the messages; the message processing nodes can dynamically increase the concurrency number according to the CPU core number, so that the performance is improved, and meanwhile, the cluster processing performance is improved by increasing the number of the message processing nodes by adjusting the number of partitions of the message queue, so that the efficient processing of the message is realized; when the message processing node is down, as long as 1 message processing node in the cluster is normal, the message processing service can still be provided, and the message processing node has a back pressure mechanism, so that chain reaction caused by breakdown of other nodes is avoided, and the safe processing of the message is realized.
Referring to fig. 3, a schematic structural diagram of a Kafka message queue cluster is shown, and the Kafka message queue cluster includes a partition one, a partition two, and a partition three, a message processing node one, a message processing node two, and a message processing node three, where the partition corresponds to the message processing node one, the partition two corresponds to the message processing node two, and the partition three corresponds to the message processing node three. And distributing the message to a plurality of queues in each message processing node, processing each queue through a single processing thread, and storing the message after the processing is finished.
In the embodiment of the application, the message of each equipment of the internet of things is distributed to a fixed message processing node, and the message listener, the message buffer and the corresponding thread pool of the message processing node perform single-thread processing, so that the message is processed in order.
Corresponding to the second embodiment of this specification, fig. 4 is a schematic structural diagram of an apparatus message processing device based on the internet of things provided in the third embodiment of this specification, and includes: a sending unit 1, a first creating unit 2, a second creating unit 3, a buffering unit 4 and a third creating unit 5.
The sending unit 1 is configured to send a message generated by each internet of things device to a corresponding partition, where the partition is designated for a message queue;
the first creating unit 2 is configured to create a message listener in a message processing node, configure the message listener to monitor messages of all partitions, and ensure message ordering of all partitions through the message queue;
the second creating unit 3 is used for creating a message buffer in the message processing node and initializing a plurality of queues in the message buffer;
the buffer unit 4 is configured to, when the message buffer receives messages of all the partitions sent by the message listener, buffer the messages of all the partitions to a preset queue, so as to ensure that messages generated by the same internet of things device are sequentially buffered in the same queue;
the third creating unit 5 is configured to create a thread pool corresponding to each queue in the message processing node, so that each queue performs single-thread processing on the cached message.
In the embodiment of the application, the message of each equipment of the internet of things is distributed to a fixed message processing node, and the message listener, the message buffer and the corresponding thread pool of the message processing node perform single-thread processing, so that the message is processed in order.
An embodiment of the present application further provides an apparatus message processing medium based on the internet of things, in which computer-executable instructions are stored, and the computer-executable instructions are configured to:
sending the message generated by each Internet of things device to a corresponding partition, wherein the partition is designated for a message queue;
a message listener is established in a message processing node, the message listener is configured to monitor messages of all partitions, and the message queues are used for ensuring the message order of all the partitions;
creating a message buffer in a message processing node, and initializing a plurality of queues in the message buffer;
when the message buffer receives the messages of all the partitions sent by the message listener, caching the messages of all the partitions to a preset queue so as to ensure that the messages generated by the same equipment of the internet of things are cached in the same queue in order;
and creating a thread pool corresponding to each queue in the message processing node so that each queue can process the cached messages in a single thread mode.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually making an Integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Hardware Description Language), traffic, pl (core universal Programming Language), HDCal (jhdware Description Language), lang, Lola, HDL, laspam, hardward Description Language (vhr Description Language), vhal (Hardware Description Language), and vhigh-Language, which are currently used in most common. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium which can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims (10)
1. An equipment message processing method based on the Internet of things is characterized by comprising the following steps:
sending the message generated by each Internet of things device to a corresponding partition, wherein the partition is designated for a message queue;
a message listener is established in a message processing node, the message listener is configured to monitor messages of all partitions, and the message queues are used for ensuring the message order of all the partitions;
creating a message buffer in the message processing node and initializing a plurality of queues in the message buffer;
when the message buffer receives the messages of all the partitions sent by the message listener, caching the messages of all the partitions to a preset queue so as to ensure that the messages generated by the same equipment of the internet of things are cached in the same queue in order;
and creating a thread pool corresponding to each queue in the message processing node so that each queue can process the cached messages in a single thread mode.
2. The method for processing the message of the device based on the internet of things according to claim 1, wherein the configuring the message listener to listen to the messages of all the partitions specifically comprises:
and setting the message monitor to monitor by using a single thread, and configuring the message monitor to monitor the messages of all the partitions according to the number of the message monitors.
3. The method for processing the device message based on the internet of things according to claim 2, wherein the configuring, according to the number of the message listeners, the message listeners to listen to the messages of all the partitions specifically comprises:
when the number of the message listeners is single, configuring a single message listener to listen to the messages of all the partitions;
when the number of the message listeners is multiple and is less than the number of the partitions, configuring a single message listener to listen to the messages of one partition or a plurality of partitions;
when the number of the message listeners is multiple and the number of the message listeners is equal to the number of the partitions, configuring a single message listener to listen to the messages of one partition;
and when the number of the message listeners is more than the number of the partitions, configuring the message listeners with the partition number to listen to the messages of each partition.
4. The message processing method for equipment based on the internet of things as claimed in claim 3, wherein when the number of the message listeners is adjusted, the method further comprises:
and adjusting the monitoring relation between the current message monitoring node and the partition according to the number of the current message monitors and the monitoring mechanism of the message queue.
5. The method for processing the message of the device based on the internet of things according to claim 3, wherein initializing the plurality of queues specifically comprises:
when the message processing node is started, acquiring the number of CPU cores and the concurrency multiple of a server, and taking the number of the CPU cores and the concurrency multiple as parallel processing numbers;
initializing the parallel processing queues.
6. The method for processing the device message based on the internet of things according to claim 5, wherein the caching the messages of all the partitions to a preset queue specifically comprises:
performing hash calculation on the ID of the Internet of things equipment to obtain a hash value of the ID of the Internet of things equipment;
and carrying out remainder operation on the hash value of the ID of the Internet of things equipment and the parallel processing number, and caching the partitioned information to a first remainder queue.
7. The method for message processing of internet of things-based devices according to claim 1, wherein after creating a thread pool corresponding to each queue in the message processing node so that each queue performs single-thread processing on the buffered messages, the method further comprises:
and when the message to be processed exists in the queue, establishing a single thread by the corresponding thread pool, and processing the message to be processed.
8. The message processing method for the internet-of-things-based equipment as claimed in claim 1, wherein the messages of the partition comprise subject messages and consumption group messages in the preset partition.
9. An apparatus for processing device messages based on the internet of things, the apparatus comprising:
the sending unit is used for sending the message generated by each Internet of things device to a corresponding partition, wherein the partition is designated for a message queue;
a first creating unit, configured to create a message listener in a message processing node, configure the message listener to monitor messages of all partitions, and ensure message ordering of all partitions through the message queue;
a second creating unit, configured to create a message buffer in a message processing node, and initialize a plurality of queues in the message buffer;
the buffer unit is used for buffering the messages of all the partitions to a preset queue when the message buffer receives the messages of all the partitions sent by the message listener so as to ensure that the messages generated by the same equipment of the internet of things are sequentially buffered in the same queue;
and the third creating unit is used for creating a thread pool corresponding to each queue in the message processing node so that each queue can perform single-thread processing on the cached messages.
10. An internet of things-based device message processing medium storing computer-executable instructions configured to:
sending the message generated by each Internet of things device to a corresponding partition, wherein the partition is designated for a message queue;
a message listener is established in a message processing node, the message listener is configured to monitor messages of all partitions, and the message queues are used for ensuring the message order of all the partitions;
creating a message buffer in a message processing node, and initializing a plurality of queues in the message buffer;
when the message buffer receives the messages of all the partitions sent by the message listener, caching the messages of all the partitions to a preset queue so as to ensure that the messages generated by the same equipment of the internet of things are cached in the same queue in order;
and creating a thread pool corresponding to each queue in the message processing node so that each queue can process the cached messages in a single thread mode.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010587969.9A CN111930530B (en) | 2020-06-24 | 2020-06-24 | Equipment message processing method, device and medium based on Internet of things |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010587969.9A CN111930530B (en) | 2020-06-24 | 2020-06-24 | Equipment message processing method, device and medium based on Internet of things |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111930530A true CN111930530A (en) | 2020-11-13 |
CN111930530B CN111930530B (en) | 2024-04-30 |
Family
ID=73317431
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010587969.9A Active CN111930530B (en) | 2020-06-24 | 2020-06-24 | Equipment message processing method, device and medium based on Internet of things |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111930530B (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112764896A (en) * | 2020-12-31 | 2021-05-07 | 广州技象科技有限公司 | Task scheduling method, device and system based on standby queue and storage medium |
CN113823014A (en) * | 2021-08-24 | 2021-12-21 | 广州市瑞立德信息***有限公司 | Message pushing method based on access control processor and access control system |
CN116055289A (en) * | 2022-12-14 | 2023-05-02 | ***数智科技有限公司 | Efficient transmission method for transmission network alarms |
WO2024125052A1 (en) * | 2022-12-13 | 2024-06-20 | 深圳Tcl新技术有限公司 | Device control method and apparatus, and electronic device and computer storage medium |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20160197849A1 (en) * | 2015-01-07 | 2016-07-07 | Mckesson Corporation | Method and Apparatus for Implementing a Messaging Interface |
CN107896172A (en) * | 2017-11-24 | 2018-04-10 | 泰康保险集团股份有限公司 | Monitor fault handling method and device, storage medium and electronic equipment |
US20190104179A1 (en) * | 2017-10-01 | 2019-04-04 | Oracle International Corporation | System and method for topics implementation in a distributed data computing environment |
-
2020
- 2020-06-24 CN CN202010587969.9A patent/CN111930530B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20160197849A1 (en) * | 2015-01-07 | 2016-07-07 | Mckesson Corporation | Method and Apparatus for Implementing a Messaging Interface |
US20190104179A1 (en) * | 2017-10-01 | 2019-04-04 | Oracle International Corporation | System and method for topics implementation in a distributed data computing environment |
CN107896172A (en) * | 2017-11-24 | 2018-04-10 | 泰康保险集团股份有限公司 | Monitor fault handling method and device, storage medium and electronic equipment |
Non-Patent Citations (1)
Title |
---|
刘峰;鄂海红;: "基于海量数据的消息队列的性能对比与优化方案", 软件, no. 10 * |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112764896A (en) * | 2020-12-31 | 2021-05-07 | 广州技象科技有限公司 | Task scheduling method, device and system based on standby queue and storage medium |
CN113823014A (en) * | 2021-08-24 | 2021-12-21 | 广州市瑞立德信息***有限公司 | Message pushing method based on access control processor and access control system |
WO2024125052A1 (en) * | 2022-12-13 | 2024-06-20 | 深圳Tcl新技术有限公司 | Device control method and apparatus, and electronic device and computer storage medium |
CN116055289A (en) * | 2022-12-14 | 2023-05-02 | ***数智科技有限公司 | Efficient transmission method for transmission network alarms |
Also Published As
Publication number | Publication date |
---|---|
CN111930530B (en) | 2024-04-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111930530B (en) | Equipment message processing method, device and medium based on Internet of things | |
CN107395665B (en) | Block chain service acceptance and service consensus method and device | |
CN111756550B (en) | Block chain consensus method and device | |
CN110875935B (en) | Message publishing, processing and subscribing method, device and system | |
CN107577694B (en) | Data processing method and device based on block chain | |
US10007609B2 (en) | Method, apparatus and computer programs providing cluster-wide page management | |
CN108712454B (en) | File processing method, device and equipment | |
CN108628688B (en) | Message processing method, device and equipment | |
US10324836B2 (en) | Balanced double deques for eliminating memory fences in garbage collection | |
US20200097449A1 (en) | File management in thin provisioning storage environments | |
JP2020514866A (en) | Blockchain-based data processing method and apparatus | |
US20150120854A1 (en) | Subscriber based priority of messages in a publisher-subscriber domain | |
CN113918101B (en) | Method, system, equipment and storage medium for writing data cache | |
US20190187897A1 (en) | Efficient sharing of non-volatile memory | |
CN110716813A (en) | Data stream processing method and device, readable storage medium and processor | |
CN115617799A (en) | Data storage method, device, equipment and storage medium | |
CN116560878B (en) | Memory sharing method and related device | |
CN112181979B (en) | Data updating method and device, storage medium and electronic equipment | |
CN110764690B (en) | Distributed storage system and leader node election method and device thereof | |
US20190220208A1 (en) | Method, device and computer program product for storing data | |
CN111459981A (en) | Query task processing method, device, server and system | |
CN117499492A (en) | Data processing method, device and equipment | |
CN107341084B (en) | Data processing method and device | |
CN116893892A (en) | Method, equipment and medium for dynamically generating message queue based on service model | |
CN117539801A (en) | Method, device and related equipment for remotely accessing memory |
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 | ||
TA01 | Transfer of patent application right | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20240328 Address after: 250000 Langchao Science Park, No. 1036, Langchao Road, high tech Zone, Jinan, Shandong Applicant after: Inspur Genersoft Co.,Ltd. Country or region after: China Address before: 250101 Inspur science and Technology Park, 1036 Inspur Road, hi tech Zone, Jinan City, Shandong Province Applicant before: SHANDONG INSPUR GENESOFT INFORMATION TECHNOLOGY Co.,Ltd. Country or region before: China |
|
GR01 | Patent grant | ||
GR01 | Patent grant |