CN111198773A - Message-based application communication method and device - Google Patents

Message-based application communication method and device Download PDF

Info

Publication number
CN111198773A
CN111198773A CN201911410969.5A CN201911410969A CN111198773A CN 111198773 A CN111198773 A CN 111198773A CN 201911410969 A CN201911410969 A CN 201911410969A CN 111198773 A CN111198773 A CN 111198773A
Authority
CN
China
Prior art keywords
application
rpc
request
message
http
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
Application number
CN201911410969.5A
Other languages
Chinese (zh)
Other versions
CN111198773B (en
Inventor
周晔
穆海洁
张晓犇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Huifu Data Service Co ltd
Original Assignee
Shanghai Huifu Data Service Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Huifu Data Service Co ltd filed Critical Shanghai Huifu Data Service Co ltd
Priority to CN201911410969.5A priority Critical patent/CN111198773B/en
Publication of CN111198773A publication Critical patent/CN111198773A/en
Application granted granted Critical
Publication of CN111198773B publication Critical patent/CN111198773B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/541Client-server
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

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 And Data Communications (AREA)

Abstract

The invention discloses a message-based application communication method and device, wherein the method comprises the following steps: the first application sends an RPC/Http request; after the second application receives the RPC/Http request, the second application sends an MQ request, receives the MQ request and processes corresponding service logic; and the second application sends the processed request result to the first application through the RPC/Http callback interface of the first application. Through the technical scheme, the invention can at least reduce the dependence of the front-end service system on the MQ middleware.

Description

Message-based application communication method and device
Technical Field
The invention relates to the technical field of internet, in particular to an application communication method and device based on messages.
Background
With the continuous development of the business of internet companies, the access amount of the system is continuously increased, and the pressure borne by the system is also increased more and more. How to ensure that the user can access normally at this time without high latency or access timeout exceptions? This requires background system applications to promote concurrency capabilities. For example: in the double eleven days of the cat, 8 million transactions need to be processed within one second, and the high concurrency of the cat system ensures that the shopping experience of a user is not influenced by long-time processing delay; 12306 during holidays such as spring festival, in the face of billions of daily visits, the system can still return the train ticket order purchase status to the user in a short time. How can the concurrency capability of the system be improved? The concurrency capability of the application in the system is improved. The scheme for improving the application concurrency capability in the market at present is to add a layer of MQ message middleware between the application and the application, and change the original synchronous calling mode of rpc into an asynchronous processing mode of communicating through sending messages. As shown in fig. 1A and fig. 1B, the two modes can well implement asynchronization of calls between applications, and improve throughput of front-end applications. And functions of application decoupling, flow peak elimination and the like can be realized.
However, the application asynchronous call processing scheme based on message middleware communication also brings problems while improving concurrency capability:
(1) application a cannot know whether application B receives the request, nor can it make a prejudgment on the request.
(2) If a large number of wrong requests occur, the application A is unknown to the MQ and only backlogs without any reason, so that subsequent correct transactions are influenced.
(3) If the application B has an idempotent request, the application A has a large number of repeated transactions and must return through asynchronous requests, and the asynchronous request decoupling is found to be not applied to correct large-amount data processing at the moment. Resulting in a large number of repeated backlogs.
(4) The application A and the application B strongly depend on MQ and become centralized processing middleware among systems, and in case of MQ problem, the influence is large.
(5) The expansion of the application a and the application B is difficult, and the performance problem of the global MQ needs to be considered.
(6) And the application A and the application B have difficulty in realizing fusing, degrading, routing and load balancing strategies at the MQ level.
Disclosure of Invention
Aiming at the problems in the related art, the invention provides a message-based application communication method and device, which can reduce the dependence of a front-end service system on MQ middleware.
The technical scheme of the invention is realized as follows:
according to an aspect of the present invention, there is provided a message-based application communication method, including:
the first application sends an RPC/Http request;
after the second application receives the RPC/Http request, the second application sends an MQ request, receives the MQ request and processes corresponding business logic;
and the second application sends the processed request result to the first application through the RPC/Http callback interface of the first application.
According to the embodiment of the present invention, after receiving the RPC/Http request, the second application further includes: and the second application carries out logic verification on the RPC/Http request, and directly returns an RPC/Http response to the first application under the condition that the logic verification is passed.
According to the embodiment of the present invention, after receiving the RPC/Http request, the second application further includes: in the event that the logical verification fails, the logging is to a database.
According to the embodiment of the invention, after receiving the RPC/Http callback response of the second application, the first application sends a callback MQ to perform traffic peak-eliminating processing.
According to an embodiment of the invention, the MQ request is sent in an asynchronous sending manner.
According to another aspect of the present invention, there is also provided a message-based application communication device for communicating between a first application and a second application, including:
an application service module for receiving the RPC/Http request sent by the first application,
a transmitting MQ module for transmitting the MQ request;
the processing MQ module is used for receiving the MQ request and processing corresponding service logic;
and the response MQ module is used for sending the processed request result to the first application by the second application through the RPC/Http callback interface of the first application.
According to an embodiment of the invention, the message-based application communication device further comprises a verification module for performing logic verification on the RPC/Http request, and directly returning an RPC/Http response to the first application if the logic verification is passed.
According to an embodiment of the invention, the verification module is further configured to: in the event that the logical verification fails, the logging is to a database.
According to an embodiment of the invention, the first application comprises a callback module for sending a callback MQ for traffic peak-canceling processing after receiving the RPC/Http callback response of the second application.
According to an embodiment of the present invention, the sending MQ module sends the MQ request in an asynchronous sending manner.
According to the technical scheme, the message middleware sinks into the application, the communication between the application and the application completely depends on the synchronous RPC/Http protocol, and the dependence of a front-end service system on the MQ middleware is reduced through the synchronous RPC/Http communication framework. Furthermore, routing, partitioning, current limiting, fusing and other processing can be better realized through the synchronous communication framework. And, concurrency can be improved by the horizontal extension mode quickly. Moreover, the self-sending and self-receiving MQ is completely controlled by the service system, the use amount of the MQ is greatly reduced, and the isolation and the extension of the MQ are greatly increased.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings needed in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
FIGS. 1A and 1B are schematic diagrams of a conventional message-based application communication method, respectively;
FIG. 2 is a schematic diagram of a message-based application communication method according to one embodiment of the present invention;
FIG. 3 is a schematic diagram of a message-based application communication method according to another embodiment of the present invention;
fig. 4 is a schematic diagram of a message-based application communication method according to another embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments that can be derived by one of ordinary skill in the art from the embodiments given herein are intended to be within the scope of the present invention.
Referring to fig. 2, an embodiment of the present invention provides a message-based application communication method. The method specifically comprises the following steps:
s1, application a (first application) requests application B (second application) using RPC (Remote Procedure Call Protocol)/Http (HyperText Transfer Protocol) Request.
Application B verification logic, if the verification is not passed (e.g., verify-in-argument verification, idempotent, security verification, etc.), then S2 is executed to return the error directly to application A via the RPC/Http Response request. According to the embodiment of the invention, the authentication of the application B should avoid remote invocation, because in the asynchronous request mode, the corresponding speed and response speed are required to be reached to improve concurrency, and the whole request operation should be within 10 milliseconds. If the application B passes the verification logic, DB or Redis (database) and the like are directly downloaded, and after the service is ensured to be durable and reliable, the service is directly returned to the application A through an RPC/Http Response request. Wherein, if the drop DB requires fast response, hot-spot tables can be considered, which, because of the large number of Insert operations, consider to index as little as possible to improve concurrency. The entire request operation should be within 20 milliseconds.
S3, application B sends MQ (message queue) request as producer, asynchronously decoupled. And S4, the application B itself serves as a consumer to receive the MQ request sent by itself and then process correct service logic. In one embodiment, sending MQ requests may be done asynchronously, thereby improving concurrency, since DB success has previously been dropped, but consideration needs to be given to DB validation as the receiving end processes the business logic.
And S5, processing the completed request result by the application B, calling back through the RPC/Http callback service interface exposed by the application A, and sending the result to the application A.
According to the embodiment of the invention, the embodiment shown in fig. 1 can be applied to the case that the concurrency of the server-side synchronization request is relatively large.
In the prior communication scheme for solving the problem of high concurrency, message middleware is used as a communication layer between applications, so that the asynchronous decoupling effect is achieved, and the concurrency capability is provided. This, while improving concurrency, presents a number of problems. According to the technical scheme, the message middleware sinks into the application, the communication between the application and the application completely depends on the synchronous RPC/Http protocol, and the dependence of a front-end service system on the MQ middleware is reduced through the synchronous RPC/Http communication framework. Furthermore, routing, partitioning, current limiting, fusing and other processing can be better realized through the synchronous communication framework. And, concurrency can be improved by the horizontal extension mode quickly. Moreover, the self-sending and self-receiving MQ is completely controlled by the service system, the use amount of the MQ is greatly reduced, and the isolation and the extension of the MQ are greatly increased.
In one embodiment, if the business system requires a compensation mechanism for data reliability, the MQ can be directly processed to better improve asynchronous processing performance. In one embodiment, if the RPC/Http communication at step S1 (e.g., fig. 2) is abnormal, application a needs to be able to quickly return by blowing, and application B needs to be able to actually concurrently current limit. In one embodiment, if application B verifies an exception, application B can consider the trade strict idempotent to ensure trade consistency. In one embodiment, if an MQ exception is issued at step S3, a timing compensation scheduling thread is required to perform transaction compensation, and the final state of the data is subject to the database DB. In one embodiment, if the MQ exception is received at step S4, the MQ retry mechanism may be considered, the number of retries is not too many, 3 times is the most, each interval is not too long, otherwise the MQ may squeeze (some service scenarios may require aging of the transaction, such as having to obtain a final state within 1 minute, etc.).
Fig. 3 is a schematic diagram of a message-based application communication method according to another embodiment of the present invention. The embodiment shown in fig. 3 can be applied to the case where the concurrency of synchronous requests of the server side is large and the concurrency of asynchronous responses is large.
In order to deal with the situation of large asynchronous concurrency, the embodiment shown in fig. 2 is added with business logic processing. As shown in fig. 3, application B sends the reply MQ message as a producer, and in turn receives the reply MQ message as a consumer. After receiving the response processing MQ message, the application A is requested to obtain a processing result through a callback service interface (APPClient callback interface) of the application A requested by the RPC/Http. Therefore, the business logic flow of the application B cannot be influenced even if the asynchronous response concurrency is large. Other aspects of the embodiment shown in fig. 3 are similar to the embodiment of fig. 2 and will not be repeated here.
Fig. 4 is a schematic diagram of a message-based application communication method according to another embodiment of the present invention. The embodiment shown in fig. 4 can be applied to the cases of large concurrency of synchronous requests, large concurrency of asynchronous responses, and large concurrency of asynchronous callback requests of a front-end application system. The problem of large concurrency of the application B is solved, if the callback service interface request of the application A is large. After receiving the callback response of the application B, the application A needs to send the callback MQ to perform flow peak eliminating processing, and then slowly perform self-service logic processing.
The embodiments of fig. 3 and fig. 4 fully consider the problem that the concurrency capability of the Client (Client) is poor, so that the overall service is affected, and provide a method for the server to achieve asynchronous decoupling by sending and receiving two sets of messages simultaneously.
In summary, according to the above technical solution of the present invention, the application a knows the correct response given by the application B very definitely (can perform service logic processing in time, such as parameter verification error, repetition of power, system exception, etc.); the application B can clearly give a strong type interface of the synchronous request, realize the single responsibility of the interface and define the interface parameter specification; the application B is used as a server and can use the functions of routing, fusing, current limiting, load balancing strategies and the like brought by an RPC/Http interface; in the release process of the application B, functions such as gray scale, partition, horizontal extension and the like brought by an RPC/Http interface can be used; and the application B self-sending and self-receiving MQ can be easily isolated, and the data belonging boundary is defined.
According to an embodiment of the present invention, there is also provided a message-based application communication device for performing communication between a first application and a second application, the application communication device including:
an application service module for receiving the RPC/Http request sent by the first application,
a transmitting MQ module for transmitting the MQ request;
the processing MQ module is used for receiving the MQ request and processing corresponding service logic;
and the response MQ module sends the processed request result to the first application by the second application through the RPC/Http callback interface of the first application.
According to an embodiment of the invention, the message-based application communication device further comprises a verification module for performing logic verification on the RPC/Http request, and directly returning an RPC/Http response to the first application in case of passing the logic verification.
According to an embodiment of the invention, the verification module is further configured to store the data in the database in case the logical verification fails.
According to an embodiment of the invention, the first application comprises a callback module for sending a callback MQ for traffic peak-canceling processing after receiving an RPC/Http callback response of the second application.
According to an embodiment of the invention, the sending MQ module sends the MQ request in an asynchronous sending manner.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (10)

1. A message-based application communication method, comprising:
the first application sends an RPC/Http request;
after the second application receives the RPC/Http request, the second application sends an MQ request, receives the MQ request and processes corresponding business logic;
and the second application sends the processed request result to the first application through the RPC/Http callback interface of the first application.
2. The message-based application communication method of claim 1, wherein the second application, after receiving the RPC/Http request, further comprises:
and the second application carries out logic verification on the RPC/Http request, and directly returns an RPC/Http response to the first application under the condition that the logic verification is passed.
3. The message-based application communication method of claim 2, wherein the second application, after receiving the RPC/Http request, further comprises:
in the event that the logical verification fails, the logging is to a database.
4. The message-based application communication method according to claim 1, wherein the first application sends a callback MQ for traffic peak-canceling after receiving the RPC/Http callback reply of the second application.
5. The message-based application communication method of claim 1, wherein the MQ request is transmitted in an asynchronous transmission.
6. A message-based application communication device for communicating between a first application and a second application, comprising, provided in the second application:
an application service module for receiving the RPC/Http request sent by the first application,
a transmitting MQ module for transmitting the MQ request;
the processing MQ module is used for receiving the MQ request and processing corresponding service logic;
and the response MQ module is used for sending the processed request result to the first application by the second application through the RPC/Http callback interface of the first application.
7. The message-based application communication device of claim 6, further comprising:
and the verification module is used for carrying out logic verification on the RPC/Http request, and directly returning an RPC/Http response to the first application under the condition that the logic verification is passed.
8. The message-based application communication device of claim 7, wherein the verification module is further configured to:
in the event that the logical verification fails, the logging is to a database.
9. The message-based application communication device of claim 6, wherein the first application comprises a callback module for sending a callback MQ for traffic peak-canceling after receiving an RPC/Http callback reply for the second application.
10. The message-based application communication device of claim 6, wherein the sending MQ module sends the MQ request in an asynchronous sending manner.
CN201911410969.5A 2019-12-31 2019-12-31 Message-based application communication method and device Active CN111198773B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911410969.5A CN111198773B (en) 2019-12-31 2019-12-31 Message-based application communication method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911410969.5A CN111198773B (en) 2019-12-31 2019-12-31 Message-based application communication method and device

Publications (2)

Publication Number Publication Date
CN111198773A true CN111198773A (en) 2020-05-26
CN111198773B CN111198773B (en) 2024-03-29

Family

ID=70746216

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911410969.5A Active CN111198773B (en) 2019-12-31 2019-12-31 Message-based application communication method and device

Country Status (1)

Country Link
CN (1) CN111198773B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112256447A (en) * 2020-09-11 2021-01-22 上海汇付数据服务有限公司 Message notification method and system
CN113342771A (en) * 2021-07-01 2021-09-03 上海通联金融服务有限公司 Distributed call log printing method

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101552801A (en) * 2009-05-20 2009-10-07 中国电信股份有限公司 A method and system for on-line browsing and downloading the address-book of user group
CN103473489A (en) * 2013-06-09 2013-12-25 洛阳鸿卓电子信息技术有限公司 Permission validation system and permission validation method for safety production comprehensive supervision
US20150058405A1 (en) * 2013-08-26 2015-02-26 Samsung Electronics Co., Ltd. Method for processing http message and electronic device implementing the same
CN106130868A (en) * 2016-06-02 2016-11-16 腾讯科技(深圳)有限公司 A kind of processing method adjusting back message and queue management system
CN106888218A (en) * 2017-04-01 2017-06-23 网易(杭州)网络有限公司 Message treatment method, device, client and service end
CN109542639A (en) * 2018-11-06 2019-03-29 用友网络科技股份有限公司 A kind of processing method, processing unit for ensureing micro services and calling data consistency

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101552801A (en) * 2009-05-20 2009-10-07 中国电信股份有限公司 A method and system for on-line browsing and downloading the address-book of user group
CN103473489A (en) * 2013-06-09 2013-12-25 洛阳鸿卓电子信息技术有限公司 Permission validation system and permission validation method for safety production comprehensive supervision
US20150058405A1 (en) * 2013-08-26 2015-02-26 Samsung Electronics Co., Ltd. Method for processing http message and electronic device implementing the same
CN106130868A (en) * 2016-06-02 2016-11-16 腾讯科技(深圳)有限公司 A kind of processing method adjusting back message and queue management system
CN106888218A (en) * 2017-04-01 2017-06-23 网易(杭州)网络有限公司 Message treatment method, device, client and service end
CN109542639A (en) * 2018-11-06 2019-03-29 用友网络科技股份有限公司 A kind of processing method, processing unit for ensureing micro services and calling data consistency

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
NIELS ZEILEMAKER: "Large-scale message synchronization in challenged networks" *
吕德奎;崔艳军;: "开源消息中间件复杂并发连接控制的研究与实现" *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112256447A (en) * 2020-09-11 2021-01-22 上海汇付数据服务有限公司 Message notification method and system
CN113342771A (en) * 2021-07-01 2021-09-03 上海通联金融服务有限公司 Distributed call log printing method

Also Published As

Publication number Publication date
CN111198773B (en) 2024-03-29

Similar Documents

Publication Publication Date Title
US11159411B2 (en) Distributed testing service
US8514750B2 (en) Multiplexed communication for duplex applications
CN110336702B (en) System and implementation method of message middleware
US20040068479A1 (en) Exploiting asynchronous access to database operations
US7694178B2 (en) Method, apparatus and computer program product for transaction recovery
US20070162560A1 (en) System and method for asynchronous request response
CN111212085B (en) Method for synchronously calling Internet of things platform, internet of things system and network equipment
CN110134534B (en) System and method for optimizing message processing for big data distributed system based on NIO
CN111198773A (en) Message-based application communication method and device
US20120311018A1 (en) System and method for callbacks based on web service addressing
CN112019597B (en) Distributed data receiving system and data receiving method
US20160156704A1 (en) Exchange of information between processing servers
CN112866421A (en) Intelligent contract operation method and device based on distributed cache and NSQ
US8756320B2 (en) Web service grid architecture
US20090172122A1 (en) Message Transmission Method, Message Transmission Device, and Storage Medium Recorded with Message Transmission Program
CN110336847B (en) Payment message transmission system and method
CN110995725B (en) Data processing method and device, electronic equipment and computer readable storage medium
CN113190624A (en) Asynchronous-to-synchronous calling method and device based on distributed cross-container
CN111490997A (en) Task processing method, agent system, service system and electronic equipment
CN112994894B (en) Gateway-based single-thread request processing method and information verification AGENT
US20070162539A1 (en) System and method for callbacks based on Web service addressing
US7100171B1 (en) System and method for auto-evolvable remote procedure call structures
JP4959339B2 (en) Port type independent proxy support for web services intermediary
CN115134320B (en) Transaction system for determining time sequence based on message distribution
CN112948430B (en) Date data query method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Country or region after: China

Address after: 5 / F, building C5, 700 Yishan Road, Xuhui District, Shanghai, 200233

Applicant after: Shanghai HuiFu payment Co.,Ltd.

Address before: 5 / F, building C5, 700 Yishan Road, Xuhui District, Shanghai, 200233

Applicant before: SHANGHAI HUIFU DATA SERVICE Co.,Ltd.

Country or region before: China

GR01 Patent grant
GR01 Patent grant