CN113206872B - Message sending method, terminal and computer storage medium - Google Patents
Message sending method, terminal and computer storage medium Download PDFInfo
- Publication number
- CN113206872B CN113206872B CN202110434691.6A CN202110434691A CN113206872B CN 113206872 B CN113206872 B CN 113206872B CN 202110434691 A CN202110434691 A CN 202110434691A CN 113206872 B CN113206872 B CN 113206872B
- Authority
- CN
- China
- Prior art keywords
- task
- message
- list
- identifier
- request
- 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.)
- Active
Links
Images
Classifications
-
- 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/12—Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/08—Network architectures or network communication protocols for network security for authentication of entities
- H04L63/0807—Network architectures or network communication protocols for network security for authentication of entities using tickets, e.g. Kerberos
-
- 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/02—Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
-
- 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
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/08—Protocols for interworking; Protocol conversion
Abstract
The invention provides a message sending method, a terminal and a computer storage medium, which are applied to a system comprising a gateway, a processing terminal and an mqtt module; the processing end is respectively connected with the gateway and the mqtt module; the method comprises the following steps: acquiring a message requested to be sent through a gateway by a processing terminal; a task for sending a message is online through a processing terminal, and an identifier of the task is stored in a task list; dividing the message into a plurality of batches through a processing end; judging whether the identifier exists in a preset task canceling list or not for each batch; if the judgment result is negative, the message is sent to the mqtt module; judging whether the message exists in the cache through an mqtt module; if the judgment result is yes, sending the message to the client; and obtaining feedback information fed back by the client through an mqtt module, and carrying out message persistence on the feedback information. The effect of sending messages in batch without subscription messages is achieved.
Description
Technical Field
The present invention relates to the field of message transmission technologies, and in particular, to a message transmission method, a terminal, and a computer storage medium.
Background
The application prospect of the Internet of things is vivid and infinite in future daily activities. Therefore, higher requirements are put on the demand of the internet of things protocol.
MQTT is a messaging protocol for publish/subscribe mode of client-server architecture. The design idea of the device is light, open, simple, standard and easy to realize. These features make it a good choice for many scenarios, especially for limited environments such as machine-to-machine communication (M2M) and internet of things (IoT). (ii) a
The existing mqtt browser function is not perfect, the batch sending of messages can not be realized under the condition of no subscription message, and once the message is executed, the message can not be effectively terminated.
Thus, there is a need for a better method to solve the problems of the prior art.
Disclosure of Invention
In view of this, the invention provides a message sending method, a terminal and a computer storage medium.
Specifically, the present invention proposes the following specific examples:
the embodiment of the invention provides a message sending method, which is applied to a system comprising a gateway, a processing terminal and an mqtt module; the processing end is respectively connected with the gateway and the mqtt module; the method comprises the following steps:
acquiring a message requested to be sent through the gateway by the processing terminal;
a task for sending a message is online through the processing terminal, and an identifier of the task is stored in a task list;
dividing the message into a plurality of batches through the processing end;
judging whether the identifier exists in a preset task canceling list or not for each batch;
if the judgment result is negative, the message is sent to the mqtt module;
judging whether the message exists in the cache or not through the mqtt module;
if the judgment result is yes, the message is sent to the client;
and obtaining feedback information fed back by the client through the mqtt module, and carrying out message persistence on the feedback information.
In a specific embodiment, the method further comprises:
and if the identifier exists in a preset task canceling list, canceling operation is executed.
In a specific embodiment, the cancelling operation includes: and canceling the task, clearing all caches, and deleting the identifier in a task canceling list.
In a specific embodiment, the cancelling operation further includes: and generating a return result, wherein the return result is used for prompting that the task is cancelled.
In a specific embodiment, the method further comprises:
when the mqtt module acquires a request for canceling a task, judging whether an identifier of the task corresponding to the request is in the task list;
if so, judging whether the identifier of the task corresponding to the request is in the task canceling list;
and if so, stopping the task corresponding to the request.
In a specific embodiment, after the task corresponding to the request is terminated, the method further includes:
an indication that the task is being cancelled is generated.
In a specific embodiment, if the identifier of the task corresponding to the request is not in the task list, a prompt that the task does not exist is returned.
In a specific embodiment, if the identifier of the task corresponding to the request is not in the task cancel list, the identifier of the task corresponding to the request is deleted from the task list, and the identifier of the task corresponding to the request is added to the task cancel list.
An embodiment of the present invention further provides a terminal, including: a processor for performing the above method.
An embodiment of the present invention also provides a computer storage medium, in which a program for executing the above method is stored.
Therefore, the embodiment of the invention provides a message sending method, a terminal and a computer storage medium, which are applied to a system comprising a gateway, a processing terminal and an mqtt module; the processing end is respectively connected with the gateway and the mqtt module; the method comprises the following steps: acquiring a message requested to be sent through the gateway by the processing terminal; a task for sending a message is online through the processing terminal, and an identifier of the task is stored in a task list; dividing the message into a plurality of batches through the processing end; judging whether the identifier exists in a preset task canceling list or not for each batch; if the judgment result is negative, the message is sent to the mqtt module; judging whether the message exists in the cache or not through the mqtt module; if the judgment result is yes, the message is sent to the client; and obtaining feedback information fed back by the client through the mqtt module, and carrying out message persistence on the feedback information. The effect of sending messages in batch without subscription messages is achieved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a schematic flowchart of a message sending method according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a system for sending a message according to an embodiment of the present invention;
fig. 3 is a schematic partial flow chart of a message sending method according to an embodiment of the present invention.
Detailed Description
Various embodiments of the present disclosure will be described more fully hereinafter. The present disclosure is capable of various embodiments and of modifications and variations therein. However, it should be understood that: there is no intention to limit the various embodiments of the disclosure to the specific embodiments disclosed herein, but rather, the disclosure is to cover all modifications, equivalents, and/or alternatives falling within the spirit and scope of the various embodiments of the disclosure.
The terminology used in the various embodiments of the present disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the various embodiments of the present disclosure. As used herein, the singular forms are intended to include the plural forms as well, unless the context clearly indicates otherwise. Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the various embodiments of the present disclosure belong. The terms (such as those defined in commonly used dictionaries) should be interpreted as having a meaning that is consistent with their contextual meaning in the relevant art and will not be interpreted in an idealized or overly formal sense unless expressly so defined in various embodiments of the present disclosure.
Example 1
specifically, as shown in fig. 2, the present solution is applied to a system including a gateway, a processing end, and an mqtt module; the processing end is respectively connected with the gateway and the mqtt module; the Gateway, namely the Gateway module, mainly realizes the address routing and fusing functions of the http request; the processing terminal, namely the device module, mainly realizes the functions of receiving commands, generating the mqtt messages and caching the messages for transmission, and the mqtt module realizes the functions of authenticating, connecting, sending the messages, receiving the message subscription, rejecting the connection and the like of the mqtt client.
As shown in fig. 3, in the cluster environment, the device module receives an http request to send a message.
102, a task for sending a message is online through the processing terminal, and an identifier of the task is stored in a task list;
specifically, in order to avoid conflict with other nodes, firstly, a token is acquired through vertx shared data, and a task can be executed only after the token is taken; and then the task is on-line, and the task id (taskId) is put into a public resource and is stored by the name of a taskList.
103, dividing the message into a plurality of batches through the processing end; specifically, the batch messages are divided into a plurality of batches, and the batches can be customized.
104, judging whether the identifier exists in a preset task canceling list or not for each batch; regarding batch sending: after receiving the push request, sending the push request in batches immediately; the batch strategy is 1000 batches, the interval of each batch is 200ms, and the interval of each batch is 1 s;
specifically, the method further comprises: and if the identifier exists in a preset task canceling list, canceling operation is executed. In a specific embodiment, the cancelling operation includes: and canceling the task, clearing all caches, and deleting the identifier in a task canceling list. In a specific embodiment, the cancelling operation further includes: and generating a return result, wherein the return result is used for prompting that the task is cancelled.
In a specific application scenario, in each batch execution, firstly, performing first verification in a cancellation task list, if a taskId exists in the task list, performing cancellation operation, and otherwise, continuing to send a program;
wherein the cancellation operation comprises: a. terminating the task; b. eliminating all the previous caches; c. the taskId is deleted in the task cancel list and the result "task canceled" is returned.
The transmission program includes: a. storing the message into a cache; b. the message is sent asynchronously to the mqtt module.
further, when the mqtt module obtains a request for canceling a task, whether the identifier of the task corresponding to the request is in the task list is judged; if yes, judging whether the task identifier corresponding to the request is in the task canceling list; and if so, stopping the task corresponding to the request.
Further, after suspending the task corresponding to the request, the method further includes: an indication that the task is being cancelled is generated.
And if the identification of the task corresponding to the request is not in the task list, returning a prompt that the task does not exist.
And if the identification of the task corresponding to the request is not in the task canceling list, deleting the identification of the task corresponding to the request in the task list, and adding the identification of the task corresponding to the request in the task canceling list.
And step 108, obtaining feedback information fed back by the client through the mqtt module, and carrying out message persistence on the feedback information.
Specifically, the mqtt browser receives a specific message; firstly, comparing the message with the message in the cache, if the message does not exist, not sending the message to the client; if the request exists, the request is sent to the client, the client feeds back information to the mqtt, the mqtt carries out result persistence, and the task process and the result can be queried in real time according to the result;
canceling a task currently being executed includes:
1. obtaining a task canceling request, taskId;
2. detecting whether the task taklist on the task has the taskId, if not, terminating and returning a result that the task does not exist, and if so, continuing to execute the step 3;
3. detecting whether the task canceling list has the taskId or not, if so, terminating and returning a result that the task is being canceled, and if not, executing the step 4;
4. and deleting the taskId on the task online taklist, and adding the taskId in the task cancel list.
Further, regarding protocol conversion and protocol identification: the http message is converted to an mqtt message. Webserver sends uri request to mqtt browser, mqtt browser identifies http request and converts mqtt message and sends to device, device receives mqtt message, and device information is sent to web server by way of sending http request and implemented by Hazelcast: hazelcast does not need to specially designate a central node, so that the problem of data centralization can be solved, data are dispersed in each node, single-point failure can be resisted, all the Hazelcast functions only need to quote a jar package to provide a series of distributed functions, no framework needs to be bound for use, and the Hazelcast is suitable for any scene
Example 2
The embodiment 2 of the present invention further discloses a terminal, including: a processor for performing the method described in embodiment 1.
Specifically, embodiment 2 of the present invention also discloses other related features, and for specific related features, reference is made to the description in embodiment 1.
Example 3
Specifically, the embodiment 3 of the present invention also discloses other related features, and for specific related features, reference is made to the description in the embodiment 1.
Therefore, the embodiment of the invention provides a message sending method, a terminal and a computer storage medium, which are applied to a system comprising a gateway, a processing terminal and an mqtt module; the processing end is respectively connected with the gateway and the mqtt module; the method comprises the following steps: acquiring a message requested to be sent through the gateway by the processing terminal; a task for sending a message is online through the processing terminal, and an identifier of the task is stored in a task list; dividing the message into a plurality of batches through the processing end; judging whether the identifier exists in a preset task canceling list or not for each batch; if the judgment result is negative, the message is sent to the mqtt module; judging whether the message exists in the cache or not through the mqtt module; if the judgment result is yes, the message is sent to the client; and obtaining feedback information fed back by the client through the mqtt module, and carrying out message persistence on the feedback information. The effect of sending messages in batch without subscription messages is achieved.
Those skilled in the art will appreciate that the figures are merely schematic representations of one preferred implementation scenario and that the blocks or flow diagrams in the figures are not necessarily required to practice the present invention.
Those skilled in the art will appreciate that the modules in the devices in the implementation scenario may be distributed in the devices in the implementation scenario according to the description of the implementation scenario, or may be located in one or more devices different from the present implementation scenario with corresponding changes. The modules of the implementation scenario may be combined into one module, or may be further split into a plurality of sub-modules.
The above-mentioned invention numbers are merely for description and do not represent the merits of the implementation scenarios.
The above disclosure is only a few specific implementation scenarios of the present invention, however, the present invention is not limited thereto, and any variations that can be made by those skilled in the art are intended to fall within the scope of the present invention.
Claims (10)
1. A message sending method is characterized by being applied to a system comprising a gateway, a processing end and an mqtt module; the processing end is respectively connected with the gateway and the mqtt module; the method comprises the following steps:
acquiring a message requested to be sent through the gateway by the processing terminal;
a task for sending a message is online through the processing terminal, and an identifier of the task is stored in a task list;
dividing the message into a plurality of batches through the processing end;
judging whether the identifier exists in a preset task canceling list or not for each batch;
if the judgment result is negative, the message is sent to the mqtt module;
judging whether the message exists in the cache or not through the mqtt module;
if the judgment result is yes, the message is sent to the client;
and obtaining feedback information fed back by the client through the mqtt module, and carrying out message persistence on the feedback information.
2. The method of claim 1, further comprising:
and if the identifier exists in a preset task canceling list, canceling operation is executed.
3. The method of claim 2, wherein the cancelling operation comprises: and canceling the task, clearing all caches, and deleting the identifier in a task canceling list.
4. The method of claim 3, wherein the cancelling operation further comprises: and generating a return result, wherein the return result is used for prompting that the task is cancelled.
5. The method of claim 1, further comprising:
when the mqtt module acquires a request for canceling a task, judging whether an identifier of the task corresponding to the request is in the task list;
if so, judging whether the identifier of the task corresponding to the request is in the task canceling list;
and if so, stopping the task corresponding to the request.
6. The method of claim 5, after suspending the task to which the request corresponds, further comprising:
an indication that the task is being cancelled is generated.
7. The method of claim 5, wherein if the identification of the task corresponding to the request is not in the task list, returning a prompt that the task does not exist.
8. The method according to claim 5, wherein if the identifier of the task corresponding to the request is not in the task cancel list, the identifier of the task corresponding to the request is deleted from the task list, and the identifier of the task corresponding to the request is added to the task cancel list.
9. A terminal, comprising: a processor for performing the method of any one of claims 1-8.
10. A computer-readable storage medium, characterized in that a program for executing the method of any one of claims 1-8 is stored in the computer-readable storage medium.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110434691.6A CN113206872B (en) | 2021-04-22 | 2021-04-22 | Message sending method, terminal and computer storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110434691.6A CN113206872B (en) | 2021-04-22 | 2021-04-22 | Message sending method, terminal and computer storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113206872A CN113206872A (en) | 2021-08-03 |
CN113206872B true CN113206872B (en) | 2022-06-03 |
Family
ID=77027902
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110434691.6A Active CN113206872B (en) | 2021-04-22 | 2021-04-22 | Message sending method, terminal and computer storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113206872B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105519041A (en) * | 2013-09-28 | 2016-04-20 | 迈克菲股份有限公司 | Security-connected framework |
CN108768826A (en) * | 2018-05-16 | 2018-11-06 | 华南理工大学 | Based on the message route method under MQTT and Kafka high concurrent scenes |
CN110086636A (en) * | 2019-04-17 | 2019-08-02 | 平安科技(深圳)有限公司 | A kind of message distributing method based on mqtt, server and storage medium |
CN112104720A (en) * | 2020-09-03 | 2020-12-18 | 国电南瑞科技股份有限公司 | MQTT double-Broker data interaction method and system suitable for edge Internet of things terminal |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10645181B2 (en) * | 2016-12-12 | 2020-05-05 | Sap Se | Meta broker for publish-subscribe-based messaging |
CN110365587B (en) * | 2018-03-26 | 2022-04-19 | 阿里巴巴集团控股有限公司 | Inter-device communication method, device and storage medium |
-
2021
- 2021-04-22 CN CN202110434691.6A patent/CN113206872B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105519041A (en) * | 2013-09-28 | 2016-04-20 | 迈克菲股份有限公司 | Security-connected framework |
CN108768826A (en) * | 2018-05-16 | 2018-11-06 | 华南理工大学 | Based on the message route method under MQTT and Kafka high concurrent scenes |
CN110086636A (en) * | 2019-04-17 | 2019-08-02 | 平安科技(深圳)有限公司 | A kind of message distributing method based on mqtt, server and storage medium |
CN112104720A (en) * | 2020-09-03 | 2020-12-18 | 国电南瑞科技股份有限公司 | MQTT double-Broker data interaction method and system suitable for edge Internet of things terminal |
Also Published As
Publication number | Publication date |
---|---|
CN113206872A (en) | 2021-08-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109889551B (en) | Method for accessing intelligent hardware to Internet of things cloud platform | |
US20140115046A1 (en) | Stream processing using a client-server architecture | |
CN110958281B (en) | Data transmission method and communication device based on Internet of things | |
KR102407334B1 (en) | Gateway apparatus and operating method thereof | |
CN101895520B (en) | Widget system data sharing method, server and data sharing system | |
CN111818158B (en) | Gateway control method, device, electronic equipment and storage medium | |
CN114398176A (en) | Service access method, device, electronic equipment and storage medium | |
CN111200606A (en) | Deep learning model task processing method, system, server and storage medium | |
CN104539510A (en) | Multi-protocol-based information pushing system and method | |
CN113612686A (en) | Traffic scheduling method and device and electronic equipment | |
CN112261111A (en) | Method and system for realizing cross-domain access of browser in application program | |
CN104168294A (en) | Instant communication method, system and device across users on open platforms | |
US9026582B2 (en) | Device management methods and related apparatus for enhancing applicability of status messages in response to commands | |
US9106596B2 (en) | Method and apparatus of configuring a data broadcast service | |
CN113342503B (en) | Real-time progress feedback method, device, equipment and storage medium | |
CN111124717A (en) | Message delivery method, system and computer storage medium | |
CN114338063B (en) | Message queue system, service processing method and computer readable storage medium | |
CN113206872B (en) | Message sending method, terminal and computer storage medium | |
JP5517255B2 (en) | Service connection control method, control node server and program in a plurality of service node servers | |
WO2019201111A1 (en) | Information processing method, apparatus and device, and computer-readable storage medium | |
CN111262779A (en) | Method, device, server and system for acquiring data in instant messaging | |
CN113553206B (en) | Data event execution method and device, electronic equipment and computer readable medium | |
CN113596105B (en) | Content acquisition method, edge node and computer readable storage medium | |
CN110661895A (en) | Network address mapping method and network address mapping equipment of server | |
CN111128184B (en) | Voice interaction method and device between devices |
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 | ||
CB02 | Change of applicant information | ||
CB02 | Change of applicant information |
Address after: 518000 D401, productivity building, No. 5, Gaoxin middle 2nd Road, Science Park community, Yuehai street, Nanshan District, Shenzhen, Guangdong Applicant after: Shenzhen ganzhen intelligent Co.,Ltd. Address before: 518000 Room 501, building a, productivity building, No.5, Gaoxin middle 2nd Road, science and Technology Park, Yuehai street, Nanshan District, Shenzhen City, Guangdong Province Applicant before: 8D TECHNOLOGY Ltd. |
|
GR01 | Patent grant | ||
GR01 | Patent grant |