CN114979174B - Method for processing HTTP blocking waiting step-by-step service data - Google Patents

Method for processing HTTP blocking waiting step-by-step service data Download PDF

Info

Publication number
CN114979174B
CN114979174B CN202210399869.2A CN202210399869A CN114979174B CN 114979174 B CN114979174 B CN 114979174B CN 202210399869 A CN202210399869 A CN 202210399869A CN 114979174 B CN114979174 B CN 114979174B
Authority
CN
China
Prior art keywords
http
http request
service
data
party
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
Application number
CN202210399869.2A
Other languages
Chinese (zh)
Other versions
CN114979174A (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.)
Sichuan Hongmei Intelligent Technology Co Ltd
Original Assignee
Sichuan Hongmei Intelligent Technology 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 Sichuan Hongmei Intelligent Technology Co Ltd filed Critical Sichuan Hongmei Intelligent Technology Co Ltd
Priority to CN202210399869.2A priority Critical patent/CN114979174B/en
Publication of CN114979174A publication Critical patent/CN114979174A/en
Application granted granted Critical
Publication of CN114979174B publication Critical patent/CN114979174B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/142Managing session states for stateless protocols; Signalling session states; State transitions; Keeping-state mechanisms
    • 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
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/50Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention discloses a method for processing HTTP blocking waiting step-by-step service data, which is characterized in that a self-circulation mode structural design is utilized, and a blocked HTTP request mode is searched, so that the method can enable a synchronous HTTP request to acquire other asynchronous system data in time, especially when a service cluster is deployed, the asynchronous system data can be received by different services in the cluster.

Description

Method for processing HTTP blocking waiting step-by-step service data
Technical Field
The invention relates to the field of data communication between cloud servers, in particular to a method for processing HTTP blocking waiting step-by-step service data.
Background
At present, whether the system is an internet of things or other application environments, a large amount of data exchange exists, and due to different characteristics of the system, different modes of data exchange can be caused, and the most common mode is an asynchronous mode and a synchronous mode.
At present, the invention discloses a data synchronization method, a server, a mobile terminal and a data synchronization system, wherein the publication number is CN 201180001477.6. From the perspective of a server, the data synchronization method can comprise the steps of receiving a data synchronization request sent by a request synchronization terminal, determining a matched synchronization identifier of the request synchronization terminal synchronization identifier according to a corresponding relation between preset synchronization identifiers, and determining a communication identifier of a terminal to be synchronized corresponding to the matched synchronization identifier according to the corresponding relation between the synchronization identifier and the communication identifier; and sending a data synchronization notification to the terminal to be synchronized according to the communication identifier, wherein the notification carries the synchronization data. In the invention, the matched synchronization identification is arranged in the mobile terminal, and under the condition of synchronization requirement, the terminal to be synchronized is determined by the server according to the synchronization identification, and then the synchronization processing information is sent to the terminal to be synchronized, so that the data synchronization between the mobile terminals is realized.
The publication number CN201310012928.7 provides a data synchronization method and a data synchronization device for a terminal device and a synchronization server. The data synchronization method for the synchronization server comprises the following steps: maintaining a TCP/IP long connection between the synchronization server and at least one cloud server; maintaining data synchronization between the synchronization server and the at least one cloud server by using the TCP/IP long connection; receiving a synchronization request from a terminal device; and carrying out data synchronization between the terminal equipment and the synchronization server. The data synchronization method for the terminal equipment comprises the following steps: transmitting a data synchronization request to a synchronization server through a first file system interface deployed on the terminal equipment, wherein the data synchronization request is used for indicating to perform data synchronization between the terminal equipment and the synchronization server, and the synchronization server and at least one cloud server keep TCP/IP long connection; and carrying out data synchronization between the terminal equipment and the synchronization server through the first file system interface.
The existing methods are all methods for synchronizing data in the system, and are not used for realizing data synchronization among different business logics of different systems, and are not used for realizing the requirement that one HTTP request needs to asynchronously wait for data of other third-party systems.
Disclosure of Invention
To overcome the disadvantages and shortcomings of the prior art, the present invention provides a method of handling HTTP blocking wait for step-by-step service data.
The technical scheme adopted by the invention is that the method comprises the following steps:
step S1: synchronizing data of the third party system A in a mode of blocking HTTP, so that the third party system A is in a waiting state;
step S2: creating a Map set of a single instance, collecting HTTP requests, and finding out corresponding HTTP requests by cloud service;
step S3: after receiving the reply of the third party equipment B, the cloud service finds out a corresponding HTTP request by utilizing the implementation of the step S2 and releases the blocking state of HTTP;
step S4: when the corresponding HTTP request cannot be found, writing the reply of the third party equipment B into Redis;
step S5: when the cloud service receives the HTTP request, a self-circulation thread is activated, data in Redis is checked according to circulation logic of the self-circulation thread, and the blocked HTTP request in the service is activated to unlock;
step S6: and (3) synchronously acquiring asynchronous data of the third party system by using the HTTP under the condition that the cluster is completed through the blocking of the HTTP and the circulation of the thread by utilizing the steps S1, S2, S3, S4 and S5.
The invention provides a method for processing HTTP blocking waiting step-by-step service data, which is characterized in that the invention has 2 innovation points, namely, a self-circulation mode structure design is adopted, and the other is a mode for searching blocked HTTP request mode, so that the invention can enable a synchronous HTTP request to acquire other asynchronous system data in time, especially when a service cluster is deployed, the data of the asynchronous system can be received by different services in the cluster.
Drawings
FIG. 1 is a flow chart of the overall method steps of the present invention;
FIG. 2 is a diagram of FIG. 1 according to an embodiment of the present invention;
fig. 3 is the embodiment of fig. 2.
Detailed Description
It should be noted that, without conflict, the embodiments and features of the embodiments in the present application may be combined with each other, and the present application will be further described in detail with reference to the drawings and the specific embodiments.
As shown in fig. 1, a method of processing HTTP blocking wait-for-step service data,
the method comprises the following steps:
step S1: synchronizing data of the third party system A in a mode of blocking HTTP, so that the third party system A is in a waiting state;
step S2: creating a Map set of a single instance, collecting HTTP requests, and finding out corresponding HTTP requests by cloud service;
step S3: after receiving the reply of the third party equipment B, the cloud service finds out a corresponding HTTP request by utilizing the implementation of the step S2 and releases the blocking state of HTTP;
step S4: when the corresponding HTTP request cannot be found, writing the reply of the third party equipment B into Redis;
step S5: when the cloud service receives the HTTP request, a self-circulation thread is activated, data in Redis is checked according to circulation logic of the self-circulation thread, and the blocked HTTP request in the service is activated to unlock;
step S6: and (3) synchronously acquiring asynchronous data of the third party system by using the HTTP under the condition that the cluster is completed through the blocking of the HTTP and the circulation of the thread by utilizing the steps S1, S2, S3, S4 and S5.
Embodiment one:
demand: the mobile phone controls the intelligent air conditioner through the HTTP request, and the mobile phone needs to synchronously obtain the execution result of the executed air conditioner.
The solution is as follows: the mobile phone requests the cloud IOT system through HTTP, the IOT system sends the command to the equipment through MQTT protocol, the air conditioner receives the control command, after executing, the execution result is sent to the IOT system through the MQTT protocol, and the IOT system returns the result to the mobile phone to tell the execution result of the air conditioner of the mobile phone.
The mobile phone is the third party system A in the following content, the IOT system is HTTP blocking service, and the air conditioner is the third party system B.
Embodiment two:
demand: in the package service, the user speaks into the air conditioner: after the washing machine is started, the air conditioner needs to wait for the execution of the washing machine, and after the execution result is returned, the result is broadcasted to a user in a voice mode. Why the air conditioner needs to wait for the execution result of the washing machine, instead of immediately replying to the user: good results are obtained because the washing machine may have different recovery results when performing the opening operation, such as already on, in washing, etc. It is necessary to block the request of the air conditioner, let the air conditioner wait until the washing machine correctly returns the result.
The solution is as follows: the air conditioner requests the semantic platform through HTTP, the semantic platform firstly blocks the HTTP request and then requests the cloud IOT system, the IOT system transmits a command of the washing machine to the washing machine equipment through an MQTT protocol, the washing machine receives the control command, after executing, the washing machine transmits an execution result to the IOT system through the MQTT protocol, the IOT system returns the result to the semantic platform, the semantic platform activates the blocked HTTP request, and the HTTP returns the result to tell the execution result of the washing machine of the air conditioner.
The above air conditioner is the third party system A in the following content, the semantic platform is HTTP blocking service, and the IOT system and the air conditioner are the third party system B.
When the third party system A requests the service of the third party by means of HTTP, the key value pair set of the shared Map of a single instance is used in the service of the third party system A, and the mark of the request is stored as a key, for example: and the sn of the device stores the thread ID of the current request as a value.
Then logic of self service is carried out, and finally the third party system B is notified asynchronously, such as: and sending a device command to the air conditioner. And simultaneously, blocking the thread and waiting for a reply result of the third party system B so as to meet the synchronous requirement of the third party system A.
The third party system A waits for receiving the message of the third party system B, and after receiving the message of the third party system B, the third party system A searches for a corresponding thread in the key value pair of the shared Map of a single instance by marking sn, and the two cases are now divided into two cases:
1. if the thread is found, the corresponding blocking state is released, and the acquired data are returned to the third party system A together after the blocking state is released; corresponding to the single service deployment mode of fig. 2 as follows.
2. If the thread is not found, indicating that the corresponding HTTP request is not in the service, and writing the data into a Redis memory database; corresponding to the service cluster deployment mode of fig. 3 as follows.
Only the data results in the second case above need be processed at this time. The process comprises the following steps: when a service receives an HTTP request of a third party system A, the service triggers a dead loop, the loop searches whether data exists in Redis at regular intervals, the interval time of the loop is determined by the emergency degree of the HTTP request, if the data exists in the Redis, the service searches whether a corresponding thread exists in the service, if the data exists in the Redis, the blocking state of the corresponding thread is released, the data in the Redis is directly returned to the third party system A, and if the data in the Redis is not detected, the loop is continued until the key value pair of the shared Map of the service single instance has no data in the set. Thus, the problem of acquiring different service data during cluster deployment is solved.
As shown in fig. 2, by way of example two above, the user is presented to the air conditioner: turning on the washing machine, the flow of the single service of fig. 2 is described:
the user turns on the washing machine for the air conditioner, the air conditioner serves as a third party platform A to initiate HTTP call, and the cloud end receives HTTP requests.
The cloud end blocks the HTTP request, and does not return a result, so that the air conditioner is in a waiting state.
The cloud executes logic of the cloud to find the washing machine, and asynchronously sends opening operation to the washing machine, and at the moment, the washing machine is the third party system B.
After the washing machine executes the opening operation, the result is returned to the cloud, and the data returned to the cloud can only be consistent with the HTTP sending service due to single service deployment, namely, the single service is a sender of a command for opening the washing machine and a replying person for receiving the washing machine.
After receiving the reply of the washing machine, the cloud end searches for the HTTP request which is blocked in the service
The blocked HTTP request can be found certainly, then the return data of the washing machine is filled in the HTTP request, the blocking state of the HTTP is opened, and the result of the washing machine is returned to the waiting air conditioner.
The air conditioner plays the result of the washing machine execution.
As shown in fig. 3, by way of example two above, the user is presented to the air conditioner: turning on the washing machine illustrates the flow of the cluster service of fig. 2:
the user turns on the washing machine for the air conditioner, the air conditioner serves as a third party platform A to initiate HTTP call, and the cloud end receives HTTP requests.
The cloud end blocks the HTTP request, and does not return a result, so that the air conditioner is in a waiting state.
The cloud executes logic of the cloud to find the washing machine, and asynchronously sends opening operation to the washing machine, and at the moment, the washing machine is the third party system B.
After the washing machine executes the opening operation, the result is returned to the cloud, and because the result is the deployment of the cluster service, the data returned to the cloud may be consistent with the HTTP sending service, or may be above other deployed services, that is, the service sending the washing machine command may not receive the command replied by the washing machine, and the service without the command sent can receive the command of the washing machine.
After receiving the reply of the washing machine, the cloud end searches for the HTTP request which is blocked in the service
If found, directly removing HTTP blocking as single service version, returning result
If not, the result is written to Redis.
At the above step, another set of logic is added, namely when the service receives the HTTP request, a thread which is self-circulated every 200ms according to the emergency degree of the demand is activated, the thread checks whether the local machine has the blocked HTTP request, and if not, the thread is circulated to enter a blocking state; if the blocked HTTP request exists, inquiring whether data exists in the Redis, checking whether the data exists in the blocked HTTP request corresponding to the service when the data exists, if so, returning an HTTP result, and if not, continuing to circulate. Until there is no blocked HTTP request.
The returned HTTP is also broadcasted, and the air conditioner plays the result executed by the washing machine.
As shown in fig. 2 and fig. 3, the biggest difference between the cluster and the single service deployment is that the cluster deployment can support greater concurrency, and when HTTP requests become larger with the request amount, the single service cannot be supported continuously, and at this time, the single service needs to be supported by the cluster deployment service. However, in this patent, some of the data is sent and received asynchronously, which causes a problem that the reply result of the data sent by the HTTP-hold-up service a in the cluster may be received by the HTTP-hold-up service B in the cluster, so that the HTTP-hold-up service a can never receive the data that it wants to obtain.
The invention provides a method for processing HTTP blocking waiting step-by-step service data, which is characterized in that the invention has 2 innovation points, namely, a self-circulation mode structure design is adopted, and the other is a mode for searching blocked HTTP request mode, so that the invention can enable a synchronous HTTP request to acquire other asynchronous system data in time, especially when a service cluster is deployed, the data of the asynchronous system can be received by different services in the cluster.
In the description of the present invention, it should be noted that, unless explicitly specified and limited otherwise, the terms "disposed," "mounted," "connected," and "fixed" are to be construed broadly, and may be, for example, fixedly connected, detachably connected, or integrally connected; can be mechanically or electrically connected; can be directly connected or indirectly connected through an intermediate medium, and can be communication between two elements. The specific meaning of the above terms in the present invention can be understood by those of ordinary skill in the art in a specific case.
Although embodiments of the present invention have been shown and described, it will be understood by those skilled in the art that various equivalent changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.

Claims (1)

1. A method for processing HTTP blocking wait for step-by-step service data, comprising the steps of:
step S1: the cloud service receives an HTTP request of the third party system A, the HTTP request requests the third party device B to execute a task, and the HTTP request is blocked, so that the third party system A is in a waiting state;
step S2: the cloud service asynchronously informs the third party equipment B and creates a Map set of a single instance;
step S3: after receiving the execution result of the third party equipment B, the cloud service searches whether a corresponding blocked HTTP request exists or not by utilizing the Map set in the step S2, and if the corresponding HTTP request is found, the blocking state of the HTTP is released, and the step S6 is entered;
step S4: if the corresponding HTTP request cannot be found, writing the reply of the third-party equipment B into Redis;
step S5: when the cloud service receives the HTTP request, a self-circulation thread is activated, data in Redis is checked according to circulation logic of the self-circulation thread, and the blocked HTTP request in the service is activated to unlock;
step S6: and the cloud service returns an execution result of the third party equipment B to the third party system A, and the third party system A plays the execution result.
CN202210399869.2A 2022-04-15 2022-04-15 Method for processing HTTP blocking waiting step-by-step service data Active CN114979174B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210399869.2A CN114979174B (en) 2022-04-15 2022-04-15 Method for processing HTTP blocking waiting step-by-step service data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210399869.2A CN114979174B (en) 2022-04-15 2022-04-15 Method for processing HTTP blocking waiting step-by-step service data

Publications (2)

Publication Number Publication Date
CN114979174A CN114979174A (en) 2022-08-30
CN114979174B true CN114979174B (en) 2023-07-21

Family

ID=82977179

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210399869.2A Active CN114979174B (en) 2022-04-15 2022-04-15 Method for processing HTTP blocking waiting step-by-step service data

Country Status (1)

Country Link
CN (1) CN114979174B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108055311A (en) * 2017-12-07 2018-05-18 畅捷通信息技术股份有限公司 HTTP Asynchronous Requests method, apparatus, server, terminal and storage medium
CN108259595A (en) * 2018-01-11 2018-07-06 北京值得买科技股份有限公司 The method and system of asynchronous call between a kind of service

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9692725B2 (en) * 2005-05-26 2017-06-27 Citrix Systems, Inc. Systems and methods for using an HTTP-aware client agent
CN105426326A (en) * 2015-11-05 2016-03-23 上海斐讯数据通信技术有限公司 High-concurrency queue storage method and system
CN111262923B (en) * 2020-01-14 2022-08-19 深圳壹账通智能科技有限公司 Data synchronization method and device, computer equipment and storage medium
CN112099864B (en) * 2020-09-24 2024-09-10 中国建设银行股份有限公司 Asynchronous data processing method and device

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108055311A (en) * 2017-12-07 2018-05-18 畅捷通信息技术股份有限公司 HTTP Asynchronous Requests method, apparatus, server, terminal and storage medium
CN108259595A (en) * 2018-01-11 2018-07-06 北京值得买科技股份有限公司 The method and system of asynchronous call between a kind of service

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于Web-Socket协议的推送数据技术在监控系统中的应用研究;周乐钦;计算机应用与软件(第05期);全文 *

Also Published As

Publication number Publication date
CN114979174A (en) 2022-08-30

Similar Documents

Publication Publication Date Title
US12096518B2 (en) Data transmission method and apparatus
CN112600693B (en) Service request processing method, system, electronic equipment and computer storage medium
CN104936282A (en) Method and device for registering converged communication service
CN105635083A (en) Service processing method and service processing system based on server and client architecture
CN1972276B (en) A management method and system for protocol access
CN114158030B (en) Session binding method, system and storage medium
CN114979174B (en) Method for processing HTTP blocking waiting step-by-step service data
CN112788518A (en) Location service processing method and related equipment
CN115334155B (en) Message queue proxy method and device
CN114125068B (en) Resource scheduling method, MEC controller, system and computer readable storage medium
CN114338584B (en) Message withdraw method and message transmission system
CN108882185B (en) Configuration method and device of supplementary service and mobile terminal
CN108882184B (en) Supplementary service configuration method, supplementary service configuration device and terminal
CN109218156A (en) A kind of management method of Dynamic link library data
CN109962834A (en) Information processing method, system, terminal and computer storage medium
CN112689013A (en) System, method and device for service discovery
CN109890016B (en) Method and device for supporting multiple applications to access Bluetooth equipment
CN110209474B (en) Task processing method and device
CN107994928B (en) Method and communication device for realizing synchronous receiving and transmitting of Bluetooth data
CN113542350B (en) Browsing state event downloading method, USIM, terminal and storage medium
CN113015155B (en) eSIM server discovery method and device
US20230044681A1 (en) Udsf record retrieval and deletion
CN113596890B (en) Communication method, system, device and storage medium
CN114666313B (en) Parameter acquisition method, server, terminal and readable storage medium
CN114982257B (en) Paging method and device and storage medium

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