CN110868449A - Method and system for realizing timing task based on asynchronous message - Google Patents
Method and system for realizing timing task based on asynchronous message Download PDFInfo
- Publication number
- CN110868449A CN110868449A CN201910972402.0A CN201910972402A CN110868449A CN 110868449 A CN110868449 A CN 110868449A CN 201910972402 A CN201910972402 A CN 201910972402A CN 110868449 A CN110868449 A CN 110868449A
- Authority
- CN
- China
- Prior art keywords
- message
- service
- asynchronous
- task
- timed task
- 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
-
- 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/50—Network services
- H04L67/51—Discovery or management thereof, e.g. service location protocol [SLP] or web services
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Transfer Between Computers (AREA)
Abstract
The invention discloses a method and a system for realizing a timing task based on asynchronous messages, and relates to the technical field of communication. The method comprises the following steps: the timed task message distribution service receives the timed task to the timed task management service; after receiving the timing task, the timing task message distribution service suspends an http/https request and converts the timing task into an asynchronous message; the timed task message distribution service sends the asynchronous message to an asynchronous message service; the asynchronous message service forwards the asynchronous message to a microservice; and after receiving the asynchronous message, the micro service executes corresponding business according to the content of the asynchronous message. The invention receives the timing task through the timing task message distribution service, converts the timing task into asynchronous message, and sends the asynchronous message to the micro-service through the asynchronous message service, and the micro-service executes corresponding service according to the content of the asynchronous message, thereby providing a method and a system for realizing the timing task based on the asynchronous message.
Description
Technical Field
The invention relates to the technical field of communication, in particular to a method and a system for realizing a timing task based on asynchronous messages.
Background
In the design and implementation of a distributed technology platform, a timing task is basically an indispensable service for managing the task distribution and execution of the whole platform. At present, http or https is used as a communication protocol to trigger and execute a timing task on an internet technology platform, and the scheme is relatively simple to implement.
However, most of the existing distributed systems are implemented by micro service architectures, and most of the platforms under the micro service architectures implement data transmission between the micro service architectures by using an RPC protocol and asynchronous messages. At this time, the timed task service must support RPC protocol or asynchronous message, or the micro-service architecture supports http/https protocol. Under the condition that the number of micro service architectures is large and the timing task is large, huge workload and maintenance complexity are brought when any party supports the protocol of the other party. Therefore, for a distributed platform with a large number of microservice architectures and timing tasks, how to implement the timing task based on the asynchronous message becomes a problem to be solved by those skilled in the art without changing the timing task and the microservice implementation.
Disclosure of Invention
The present invention is directed to solving, at least to some extent, one of the technical problems in the related art. Therefore, the invention aims to provide a method and a system for realizing a timing task based on asynchronous messages.
The technical scheme adopted by the invention is as follows:
in a first aspect, the present invention provides a method for implementing a timing task based on an asynchronous message, where the method includes:
the timed task message distribution service receives the timed task to the timed task management service;
after receiving the timing task, the timing task message distribution service suspends an http/https request and converts the timing task into an asynchronous message;
the timed task message distribution service sends the asynchronous message to an asynchronous message service;
the asynchronous message service forwards the asynchronous message to a microservice;
and after receiving the asynchronous message, the micro service executes corresponding business according to the content of the asynchronous message.
Further, the timed task message distribution service and the timed task management service are in butt joint through an http/https protocol.
Further, the method further comprises:
and after the micro service executes the corresponding service, returning an execution result to the asynchronous message service, wherein the execution result is in an asynchronous message format.
Further, the method further comprises:
the asynchronous message service forwards the received execution result to the timed task message distribution service.
Further, the method further comprises:
and after receiving the execution result, the timed task message distribution service returns a suspended http/https request to the timed task management service according to the execution result.
Further, the method further comprises:
if the asynchronous message service does not receive the execution result within the preset time, returning an execution task overtime message to the timed task message distribution service;
and the timed task message distribution service sends the executed task overtime message to the timed task management service, and the timed task management service processes the executed task overtime message.
Further, the method further comprises:
if the asynchronous message service receives a task execution error message, forwarding the message to the timed task message distribution service;
and the timed task message distribution service sends the executed task error message to the timed task management service, and the timed task management service processes the executed task error message.
In a second aspect, the present invention provides a system for implementing a timing task based on asynchronous messages, the system comprising: a timed task message distribution service, a timed task management service, an asynchronous message service and a microservice;
the timed task message distribution service is used for receiving a timed task to the timed task management service, converting the timed task into an asynchronous message after receiving the timed task, and sending the asynchronous message to the asynchronous message service;
the asynchronous message service is used for forwarding the asynchronous message to the microservice;
and the micro service is used for executing corresponding business according to the content of the asynchronous message after receiving the asynchronous message.
The invention has the beneficial effects that:
the invention receives the timing task through the timing task message distribution service, converts the timing task into asynchronous message, and sends the asynchronous message to the micro-service through the asynchronous message service, and the micro-service executes corresponding service according to the content of the asynchronous message, thereby providing a method and a system for realizing the timing task based on the asynchronous message.
Drawings
FIG. 1 is a flow chart illustrating an embodiment of a method for implementing a timed task based on asynchronous messages according to the present invention;
FIG. 2 is another flow chart illustrating an embodiment of a method for performing a timed task based on asynchronous messages in accordance with the present invention;
fig. 3 is a schematic structural diagram of an embodiment of a system for implementing a timing task based on an asynchronous message in the present invention.
Detailed Description
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict.
Example one
The embodiment provides a method for implementing a timing task based on an asynchronous message, as shown in fig. 1, the method includes the following steps:
s100, receiving a timing task by a timing task message distribution service to a timing task management service;
s200, after receiving the timing task, the timing task message distribution service suspends the http/https request and converts the timing task into an asynchronous message;
s300, the timed task message distribution service sends asynchronous messages to an asynchronous message service;
s400, the asynchronous message service forwards the asynchronous message to the microservice;
s500, after receiving the asynchronous message, the micro service executes corresponding business according to the content of the asynchronous message.
In this embodiment, the timed task message distribution service and the timed task management service are interfaced via an http/https protocol.
Specifically, the timed task message distribution service and the timed task management service are in butt joint through an http/https protocol, and the timed task sent by the timed task management service is received. After receiving the timing task, the timing task message distribution service firstly suspends the http/https request, does not return immediately, and returns the http/https request after waiting for receiving a corresponding execution result or waiting for overtime. The timed task message distribution service translates (the format of) the timed task into asynchronous messages (the format) of the microservice owned service. The timed task message distribution service sends the asynchronous message to an asynchronous message service. The asynchronous message service forwards the asynchronous message to the microservice, and simultaneously the asynchronous message service monitors the execution result return message after the message processing in real time. After receiving the asynchronous message, the micro-service executes corresponding service according to the content of the asynchronous message.
As shown in fig. 2, the method further comprises the steps of:
s600, after the micro service executes the corresponding service, returning an execution result to the asynchronous message service, wherein the execution result is in an asynchronous message format;
s700, the asynchronous message service forwards the received execution result to a timing task message distribution service;
s800, after receiving the execution result, the timed task message distribution service returns a suspended http/https request to the timed task management service according to the execution result;
s900, if the asynchronous message service does not receive the execution result within the preset time, returning an execution task overtime message to the timed task message distribution service;
s1000, the timed task message distribution service sends an executed task overtime message to the timed task management service, and the timed task management service processes the executed task overtime message;
s1100, if the asynchronous message service receives a task execution error message, forwarding the message to a timed task message distribution service;
s1200, the timed task message distribution service sends the executed task error message to the timed task management service, and the timed task management service processes the executed task error message.
Specifically, after the micro service executes the corresponding service, an execution result is returned to the asynchronous message service, and the execution result (format) is also in the asynchronous message format. The asynchronous message service forwards the execution result to the timed task message distribution service. And after receiving the execution result, the timed task message distribution service returns a suspended http/https request to the timed task management service according to the content of the execution result. At this point, a complete timed task process is completed.
Further, if the asynchronous message service does not receive the execution result returned by the micro service within the preset time, returning an execution task overtime message to the timed task message distribution service. The timed task message distribution service sends the executed task overtime message to the timed task management service, the timed task management service processes the executed task overtime message, and the executed task overtime message is displayed at a timed task manager end or the timed task is automatically retransmitted, which is specifically determined by the timed task requirement.
Further, if the asynchronous message service receives an executive task error message, the executive task error message is forwarded to the timed task message distribution service. The timed task message distribution service sends the executed task error message to the timed task management service, the timed task management service processes the executed task error message, and the executed task error message is displayed at a timed task manager end or the timed task is automatically retransmitted, which is specifically determined by the timed task requirement.
It should be noted here that, for the case where the asynchronous message of the same timing task is sent by the asynchronous message service for multiple times, the process is still handled in a manner of solving idempotency in the distributed system, and no new logic or concept is added.
Example two
The embodiment provides a system for implementing a timing task based on an asynchronous message, as shown in fig. 3, the system includes: the system comprises a timing task management service, a timing task message distribution service, an asynchronous message service and a micro service which are connected in sequence.
The timed task message distribution service is used for receiving a timed task to the timed task management service, converting the timed task into an asynchronous message after receiving the timed task, and sending the asynchronous message to the asynchronous message service;
an asynchronous message service for forwarding asynchronous messages to the microservice;
and the micro service is used for executing corresponding services according to the content of the asynchronous message after receiving the asynchronous message.
Referring to FIG. 3, it is worth explaining here that the asynchronous message service may connect a plurality of microservices, which communicate with each other via the RPC protocol. Under the condition of more timing tasks, a plurality of micro services ensure that a plurality of corresponding services can be executed simultaneously.
In this embodiment, please refer to the description of the method for implementing a timing task based on an asynchronous message in the first embodiment in the working process of the system for implementing a timing task based on an asynchronous message, which is not described herein again.
While the preferred embodiments of the present invention have been illustrated and described, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.
Claims (8)
1. A method for implementing a timed task based on asynchronous messages, the method comprising:
the timed task message distribution service receives the timed task to the timed task management service;
after receiving the timing task, the timing task message distribution service suspends an http/https request and converts the timing task into an asynchronous message;
the timed task message distribution service sends the asynchronous message to an asynchronous message service;
the asynchronous message service forwards the asynchronous message to a microservice;
and after receiving the asynchronous message, the micro service executes corresponding business according to the content of the asynchronous message.
2. The method for realizing timed tasks based on asynchronous messages as claimed in claim 1, wherein said timed task message distribution service interfaces with said timed task management service via http/https protocol.
3. The method of claim 2, wherein the method further comprises:
and after the micro service executes the corresponding service, returning an execution result to the asynchronous message service, wherein the execution result is in an asynchronous message format.
4. The method of claim 3, wherein the method further comprises:
the asynchronous message service forwards the received execution result to the timed task message distribution service.
5. The method of claim 4, wherein the method further comprises:
and after receiving the execution result, the timed task message distribution service returns a suspended http/https request to the timed task management service according to the execution result.
6. The method of claim 5, wherein the method further comprises:
if the asynchronous message service does not receive the execution result within the preset time, returning an execution task overtime message to the timed task message distribution service;
and the timed task message distribution service sends the executed task overtime message to the timed task management service, and the timed task management service processes the executed task overtime message.
7. The method of claim 6, wherein the method further comprises:
if the asynchronous message service receives a task execution error message, forwarding the message to the timed task message distribution service;
and the timed task message distribution service sends the executed task error message to the timed task management service, and the timed task management service processes the executed task error message.
8. A system for performing timed tasks based on asynchronous messages, the system comprising: a timed task message distribution service, a timed task management service, an asynchronous message service and a microservice;
the timed task message distribution service is used for receiving a timed task to the timed task management service, converting the timed task into an asynchronous message after receiving the timed task, and sending the asynchronous message to the asynchronous message service;
the asynchronous message service is used for forwarding the asynchronous message to the microservice;
and the micro service is used for executing corresponding business according to the content of the asynchronous message after receiving the asynchronous message.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910972402.0A CN110868449B (en) | 2019-10-14 | 2019-10-14 | Method and system for realizing timing task based on asynchronous message |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910972402.0A CN110868449B (en) | 2019-10-14 | 2019-10-14 | Method and system for realizing timing task based on asynchronous message |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110868449A true CN110868449A (en) | 2020-03-06 |
CN110868449B CN110868449B (en) | 2022-03-22 |
Family
ID=69652703
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910972402.0A Active CN110868449B (en) | 2019-10-14 | 2019-10-14 | Method and system for realizing timing task based on asynchronous message |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110868449B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111475306A (en) * | 2020-03-31 | 2020-07-31 | 招商局金融科技有限公司 | Micro service node, asynchronous task processing method, system and storage medium |
CN112769712A (en) * | 2020-12-23 | 2021-05-07 | 中移(杭州)信息技术有限公司 | Compensation method and device, electronic equipment and storage medium |
CN112929431A (en) * | 2021-02-01 | 2021-06-08 | 深圳市科漫达智能管理科技有限公司 | Message synchronous and asynchronous response conversion method and device based on micro-service framework |
Citations (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050234928A1 (en) * | 2004-03-23 | 2005-10-20 | Grand Central Communications, Inc. | Synchronous interface to asynchronous processes |
CN104917833A (en) * | 2015-06-08 | 2015-09-16 | 北京集奥聚合网络技术有限公司 | Asynchronous information processing method based on NIO request |
US20160112475A1 (en) * | 2014-10-21 | 2016-04-21 | Twilio, Inc. | System and method for providing a micro-services communication platform |
CN106126354A (en) * | 2016-06-21 | 2016-11-16 | 中国建设银行股份有限公司 | A kind of asynchronous batch processing method and system |
CN106126309A (en) * | 2016-07-15 | 2016-11-16 | 浪潮软件集团有限公司 | ONS-based timed task scheduling method |
CN106598705A (en) * | 2015-10-15 | 2017-04-26 | 阿里巴巴集团控股有限公司 | Asynchronous task scheduling method, device and system and electronic equipment |
CN106993023A (en) * | 2017-03-01 | 2017-07-28 | 北京交通大学 | Distributed transaction solution under micro services framework |
CN109067597A (en) * | 2018-09-21 | 2018-12-21 | 杭州安恒信息技术股份有限公司 | A kind of distributed system dynamic and intelligent service administering method |
CN109542639A (en) * | 2018-11-06 | 2019-03-29 | 用友网络科技股份有限公司 | A kind of processing method, processing unit for ensureing micro services and calling data consistency |
CN109766201A (en) * | 2019-01-04 | 2019-05-17 | 中国联合网络通信集团有限公司 | Task distribution method, server, client and system |
-
2019
- 2019-10-14 CN CN201910972402.0A patent/CN110868449B/en active Active
Patent Citations (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050234928A1 (en) * | 2004-03-23 | 2005-10-20 | Grand Central Communications, Inc. | Synchronous interface to asynchronous processes |
US20160112475A1 (en) * | 2014-10-21 | 2016-04-21 | Twilio, Inc. | System and method for providing a micro-services communication platform |
CN104917833A (en) * | 2015-06-08 | 2015-09-16 | 北京集奥聚合网络技术有限公司 | Asynchronous information processing method based on NIO request |
CN106598705A (en) * | 2015-10-15 | 2017-04-26 | 阿里巴巴集团控股有限公司 | Asynchronous task scheduling method, device and system and electronic equipment |
CN106126354A (en) * | 2016-06-21 | 2016-11-16 | 中国建设银行股份有限公司 | A kind of asynchronous batch processing method and system |
CN106126309A (en) * | 2016-07-15 | 2016-11-16 | 浪潮软件集团有限公司 | ONS-based timed task scheduling method |
CN106993023A (en) * | 2017-03-01 | 2017-07-28 | 北京交通大学 | Distributed transaction solution under micro services framework |
CN109067597A (en) * | 2018-09-21 | 2018-12-21 | 杭州安恒信息技术股份有限公司 | A kind of distributed system dynamic and intelligent service administering method |
CN109542639A (en) * | 2018-11-06 | 2019-03-29 | 用友网络科技股份有限公司 | A kind of processing method, processing unit for ensureing micro services and calling data consistency |
CN109766201A (en) * | 2019-01-04 | 2019-05-17 | 中国联合网络通信集团有限公司 | Task distribution method, server, client and system |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111475306A (en) * | 2020-03-31 | 2020-07-31 | 招商局金融科技有限公司 | Micro service node, asynchronous task processing method, system and storage medium |
CN111475306B (en) * | 2020-03-31 | 2023-04-07 | 招商局金融科技有限公司 | Micro service node, asynchronous task processing method, system and storage medium |
CN112769712A (en) * | 2020-12-23 | 2021-05-07 | 中移(杭州)信息技术有限公司 | Compensation method and device, electronic equipment and storage medium |
CN112929431A (en) * | 2021-02-01 | 2021-06-08 | 深圳市科漫达智能管理科技有限公司 | Message synchronous and asynchronous response conversion method and device based on micro-service framework |
CN112929431B (en) * | 2021-02-01 | 2022-12-20 | 深圳市科漫达智能管理科技有限公司 | Message synchronous and asynchronous response conversion method and device based on micro-service framework |
Also Published As
Publication number | Publication date |
---|---|
CN110868449B (en) | 2022-03-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110868449B (en) | Method and system for realizing timing task based on asynchronous message | |
CN101969469B (en) | Callback processing method and device in telecom capability opening | |
KR20120019474A (en) | System and methods for integrating short message service messaging with contact center applications | |
US10834033B2 (en) | Method and system for transferring messages between messaging systems | |
CN102307212A (en) | Method for realizing page-turning synchronization | |
CN110636127B (en) | Communication processing method and system between information data | |
CN104850491A (en) | Software test method, equipment and system | |
CN104539510A (en) | Multi-protocol-based information pushing system and method | |
CN101969461A (en) | Method for implementing white board clear screen synchronization on webpage | |
CN101888404A (en) | Data updating method and device for mobile equipment | |
CN107018045A (en) | Distributed memory system method of testing and system based on RPC | |
CN102209049B (en) | Instant messaging system and method for user information processing | |
CN111200653B (en) | Multi-platform communication method, multi-platform communication device and intermediate server | |
CN111901308A (en) | Information interaction method | |
CN101931715B (en) | Customer service system and cross-platform monitoring method therein | |
CN101072172A (en) | Method and device for realizing network data high-efficiency transfer | |
CN111930830B (en) | Distributed transaction data processing method and system based on shared database | |
CN109639568A (en) | A kind of real-time Communication for Power Network simulation system based on OpenDDS | |
CN113792093A (en) | Signal system interface service creating and executing method, device and electronic equipment | |
CN111459825A (en) | Block chain application system, method and device for payment service | |
CN108735278B (en) | Instruction transmission method and application suitable for rehabilitation equipment | |
CN103731337A (en) | Transfer method, system and device for text chat and conversation and agent client terminal | |
CN113852990A (en) | Network element control system and method | |
CN110740110A (en) | video pushing method in broadband cluster, dispatching desk and cluster media function body | |
CN106503149B (en) | Data synchronization method and system |
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 |