CN107104999B - Method and device for processing service interface call request - Google Patents

Method and device for processing service interface call request Download PDF

Info

Publication number
CN107104999B
CN107104999B CN201610099097.5A CN201610099097A CN107104999B CN 107104999 B CN107104999 B CN 107104999B CN 201610099097 A CN201610099097 A CN 201610099097A CN 107104999 B CN107104999 B CN 107104999B
Authority
CN
China
Prior art keywords
service interface
count value
state
failure count
connection
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
CN201610099097.5A
Other languages
Chinese (zh)
Other versions
CN107104999A (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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information 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 Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201610099097.5A priority Critical patent/CN107104999B/en
Publication of CN107104999A publication Critical patent/CN107104999A/en
Application granted granted Critical
Publication of CN107104999B publication Critical patent/CN107104999B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • 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/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching

Abstract

The application discloses a method and a device for processing a service interface calling request. A specific embodiment of the method for processing the service interface call request includes: acquiring the state of a service interface when a service interface calling instruction is received; if the state is normal, sending a service interface calling request to a provider of the service interface through a connection pool, and waiting for an execution result, wherein the execution result comprises a response result of the service interface calling request sent by the provider of the service interface; after waiting for a preset time length, if the execution result is not obtained, updating a pre-stored failure count value of the service interface; and if the updated failure count value is larger than a preset threshold value, setting the state of the service interface as abnormal. The implementation method avoids the problem that the thread for requesting to call the service interface occupies the connection in the connection pool for a long time when the service interface is abnormal, and further avoids the false death phenomenon of the system.

Description

Method and device for processing service interface call request
Technical Field
The present application relates to the field of computer technologies, in particular, to the field of information interaction technologies, and in particular, to a method and an apparatus for processing a service interface call request.
Background
At present, information interaction between different systems is generally realized by calling a service interface. In the prior art, when a service interface is called, a connection is generally obtained from a connection pool, then a service interface calling request is sent to a provider of the service interface through the obtained connection, and a response result of the service interface returned by the provider of the service interface is waited.
However, when an abnormal condition occurs in the service interface requested to be called, if the prior art is adopted, the thread for requesting to call the service interface can occupy the connection in the connection pool for a long time, and the connection can be returned to the connection pool only after waiting for a predetermined timeout. Therefore, the consumption of the connection in the connection pool is easy to be exhausted, so that a large number of other threads are in a waiting state, and the phenomenon of system false death occurs.
Disclosure of Invention
The present application aims to provide a method and an apparatus for processing a service interface call request, so as to solve the technical problems mentioned in the above background section.
In a first aspect, the present application provides a method for processing a service interface call request, where the method includes: acquiring the state of a service interface when a service interface calling instruction is received; if the state is normal, sending a service interface calling request to a provider of the service interface through a connection pool, and waiting for an execution result, wherein the execution result comprises a response result of the service interface calling request sent by the provider of the service interface; after waiting for a preset time length, if the execution result is not obtained, updating a pre-stored failure count value of the service interface; and if the updated failure count value is larger than a preset threshold value, setting the state of the service interface as abnormal.
In some embodiments, the sending a service interface invocation request to a provider of the service interface through a connection pool includes: acquiring a connection in the connection pool; and if the connection is acquired within the first preset time length, sending a service interface calling request to the service interface providing end through the connection.
In some embodiments, the execution result further includes the obtained connection in the connection pool; and after waiting for the preset time length, if the execution result is not obtained, updating a pre-stored failure count value of the service interface, including: if the connection is not acquired within a first preset time length, updating a pre-stored failure count value of the service interface; or if the response result sent by the provider of the service interface is not obtained within a second preset time length, updating the pre-stored failure count value of the service interface.
In some embodiments, the method further comprises: after the state of the service interface to be called is obtained, if the state is abnormal, an abnormal message is sent.
In some embodiments, the updating the pre-stored failure count value of the service interface after waiting for the predetermined period of time if the execution result is not obtained further includes: after waiting for a predetermined length of time, if the execution result is not obtained, an exception message is sent.
In some embodiments, the method further comprises: and clearing the failure count value of the service interface at preset time intervals, and initializing the state of the service interface to be normal.
In a second aspect, the present application provides an apparatus for processing a service interface call request, the apparatus including: the state acquisition unit is used for acquiring the state of the service interface when receiving a service interface calling instruction; a service interface call request sending unit, configured to send a service interface call request to a provider of the service interface through a connection pool when the state is normal, and wait for an execution result, where the execution result includes a response result of the service interface call request sent by the provider of the service interface; a failure count value updating unit, configured to update a pre-stored failure count value of the service interface if the execution result is not obtained after waiting for a predetermined time period; and the state updating unit is used for setting the state of the service interface as abnormal when the updated failure count value is greater than a preset threshold value.
In some embodiments, the service interface call request sending unit includes: a connection acquisition subunit, configured to acquire a connection in the connection pool; and the service interface calling request sending subunit is used for sending a service interface calling request to the service interface providing terminal through the connection when the connection is obtained within a first preset time length.
In some embodiments, the execution result further includes the obtained connection in the connection pool; and the failure count value updating unit includes: the first failure count value updating subunit is configured to update a pre-stored failure count value of the service interface when a connection is not acquired within a first predetermined time length; and the second failure count value updating subunit is configured to update the pre-stored failure count value of the service interface when the response result sent by the provider of the service interface is not obtained within a second predetermined time length.
In some embodiments, the apparatus further comprises: and the abnormal message sending unit is used for sending the abnormal message if the state is abnormal after the state of the service interface needing to be called is acquired.
In some embodiments, the failure count value updating unit is further configured to send an exception message if the execution result is not obtained after waiting for a predetermined length of time.
In some embodiments, the apparatus further comprises: and the initialization unit is used for clearing the failure count value of the service interface at preset time intervals and initializing the state of the service interface to be normal.
According to the method and the device for processing the service interface calling request, after the service interface calling request is sent, if the execution result is not obtained after the preset waiting time length, the prestored failure count value of the service interface is updated, the state of the service interface is updated according to whether the updated failure count value is larger than the preset threshold value, and the state of the service interface is accurately updated in real time. Meanwhile, the state of the service interface is acquired when the service interface calling instruction is received, and if the state is normal, the service interface calling request is sent to the providing end of the service interface through the connection pool, so that the problem that when the service interface is abnormal, a thread for requesting to call the service interface occupies the connection in the connection pool for a long time is avoided, and the phenomenon of system false death is avoided.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flow diagram for one embodiment of a method for processing a service interface call request according to the present application;
FIG. 3 is a flow diagram of another embodiment of a method for processing a service interface call request according to the present application;
FIG. 4 is a flow diagram for one embodiment of a processing device for a service interface call request, according to the present application;
FIG. 5 is a block diagram of a computer system suitable for implementing a service interface requestor according to embodiments of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 illustrates an exemplary system architecture 100 to which embodiments of a method of processing a service interface call request or a device for processing a service interface call request of the present application may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. Various client applications, such as a browser application, a reading application, a music application, etc., may be installed on the terminal devices 101, 102, 103.
The terminal devices 101, 102, 103 may be various electronic devices that support information communication, including but not limited to smart phones, tablet computers, notebook computers, desktop computers, and the like.
The server 105 may be a server that provides various services, such as a database server or a cloud server that provides a service interface for a browser application, a reading-type application, or the like on the terminal devices 101, 102, 103 when issuing a service interface call request. The server can execute the method in the service interface according to the received service interface calling request so as to perform processing such as storage and analysis, and feed back the processing result to the terminal equipment.
It should be noted that the processing method of the service interface call request provided in the embodiment of the present application may be executed by the terminal devices 101, 102, and 103. Accordingly, the processing means of the service interface invocation request may be provided in the terminal device 101, 102, 103.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to FIG. 2, FIG. 2 illustrates a flow 200 of one embodiment of a method for processing a service interface call request according to the present application.
As shown in fig. 2, the method for processing a service interface call request of this embodiment includes the following steps:
step 201, acquiring the state of the service interface when receiving a service interface calling instruction.
In this embodiment, a service interface request end (for example, the terminal device shown in fig. 1) on which the processing method of the service interface call request is executed may obtain the state of the service interface by reading a flag indicating the state of the service interface from a computer-readable storage medium (for example, a memory). Among other things, service interfaces are shared boundaries between one system and another system or person that provide syntactic interoperability support for different applications on the internet using a range of standard specifications. The system for interacting by using the service interface only needs to follow the corresponding service interface without considering respective internal implementation, thereby greatly reducing the coupling degree between the interactive systems and increasing the flexibility of enterprise application. The service interface may be, for example, an HTTP (Hyper Text Transfer Protocol) interface or the like.
Step 202, if the state is normal, sending a service interface calling request to the provider of the service interface through the connection pool, and waiting for an execution result.
Wherein, the execution result includes a response result of the service interface calling request sent by the service interface providing terminal. In this embodiment, the service interface request end may first obtain a connection in the connection pool, then send a service interface call request to the service interface provision end through the obtained connection, and then wait for an execution result. Where connection pooling is a technique for creating and managing a buffer pool of connections, the connections in the connection pool are ready for use by any thread that needs them. When a thread needs to send a service interface request and receive a response, it requests a connection from the connection pool, and when the thread runs out of the connection (e.g., receives a response), it returns the connection to the connection pool so that it can be used by other threads that need to use it.
Step 203, after waiting for a predetermined time period, if the execution result is not obtained, updating the pre-stored failure count value of the service interface.
In this embodiment, after waiting for a predetermined period of time, if the execution result is not obtained, the service interface request end may read an original failure count value of the service interface from a predetermined computer-readable storage medium (e.g., a memory), add 1 to the original failure count value, and then write the failure count value after adding 1 into the storage medium.
Step 204, if the updated failure count value is greater than the predetermined threshold, setting the state of the service interface to be abnormal.
In this embodiment, the service interface request end may first determine whether the updated failure count value is greater than a predetermined threshold, and if so, change the state flag in the storage medium storing the state flag to be abnormal. So that the abnormal state information of the service interface can be obtained through step 201 when the service interface needs to be called subsequently.
In some optional implementation manners of this embodiment, the method for processing a service interface call request according to this embodiment may further include: after step 201, if the status is abnormal, an exception message is sent (e.g., an exception is thrown). Therefore, the service interface calling indicator can acquire the abnormal message of the service interface.
In some optional implementations of this embodiment, step 204 may further include: after waiting for a predetermined length of time, if the execution result is not obtained, an exception message is sent. Therefore, the service interface calling indicator can acquire the corresponding exception message.
In some optional implementation manners of this embodiment, the method for processing a service interface call request according to this embodiment may further include: and clearing the failure count value of the service interface at preset time intervals, and initializing the state of the service interface to be normal. Through the implementation mode, the problem of inaccurate state caused by long-term accumulation of the failure count value is solved, and the acquired state of the service interface is more accurate.
In the method for processing a service interface call request provided in this embodiment, after sending the service interface call request, if the execution result is not obtained after the waiting predetermined time length, the pre-stored failure count value of the service interface is updated, and the state of the service interface is updated according to whether the updated failure count value is greater than a predetermined threshold, so that the state of the service interface is accurately updated in real time. Meanwhile, the state of the service interface is acquired when a service interface calling instruction is received, and if the state is normal, a service interface calling request is sent to a providing end of the service interface through the connection pool, so that the problem that when the service interface is abnormal, a thread for requesting to call the service interface occupies the connection in the connection pool for a long time is avoided, and the phenomenon of system false death is avoided.
With further reference to FIG. 3, FIG. 3 illustrates a flow 300 of another embodiment of a method of processing a service interface call request according to the present application.
As shown in fig. 3, the method for processing a service interface call request of this embodiment includes the following steps:
step 301, obtaining the state of the service interface when receiving a service interface calling instruction.
In this embodiment, the specific processing of step 301 may refer to the related description of step 201 in the corresponding embodiment of fig. 2, and is not repeated herein.
Step 302, if the status is normal, acquiring a connection in a connection pool, and waiting for the connection acquired in the connection pool.
In this embodiment, for a specific process of the service interface request end obtaining a connection in the connection pool, reference may be made to the description of the relevant part of step 202 in the corresponding embodiment of fig. 2, which is not described herein again.
Step 303, determine whether a connection is obtained within a first predetermined time period.
In this embodiment, if the connection is acquired within the first predetermined length of time, step 304 is performed, otherwise step 306 is performed.
Step 304, sending a service interface calling request to the provider of the service interface through the connection, and waiting for a response result of the service interface calling request sent by the provider of the service interface.
In this embodiment, the specific process of the service interface request end sending the service interface call request to the service interface providing end through the connection may refer to the description of the relevant part of step 202 in the corresponding embodiment of fig. 2, and is not described herein again. After sending the service interface call request to the provider of the service interface through the connection, step 305 is executed.
Step 305, determining whether a response result sent by the provider of the service interface is obtained within a second predetermined time length.
In this embodiment, if the response result sent by the provider of the service interface is not obtained within the second predetermined time length, step 306 is executed.
Step 306, updating the pre-stored failure count value of the service interface, and if the updated failure count value is greater than a predetermined threshold, setting the state of the service interface as abnormal.
In this embodiment, the service interface request end may first read an original failure count value of the service interface from a predetermined computer-readable storage medium (e.g., a memory), then add 1 to the original failure count value, and then write the failure count value after adding 1 into the storage medium. And if the failure count value after adding 1 is larger than a preset threshold value, changing the state flag in the storage medium storing the state flag into an abnormal state.
As can be seen from fig. 3, compared with the embodiment corresponding to fig. 2, in the process 300 of the method for processing a service interface invocation request in this embodiment, when a connection is not acquired within a first predetermined time length, the failure count value of the service interface is also updated, and the state of the service interface is correspondingly set according to the updated failure count value. Therefore, the scheme described in this embodiment can set different timeout lengths for response results that the service interface providing terminal cannot be connected and cannot be received, respectively, so that the state of the service interface can be set more accurately.
Referring to fig. 4, as an implementation of the method shown in the above diagrams, the present application provides an embodiment of a device for processing a service interface call request, where the embodiment of the device corresponds to the embodiment of the method shown in fig. 2, and the device may be specifically applied to a service interface request end.
As shown in fig. 4, the apparatus 400 for processing a service interface call request provided in this embodiment includes: a status acquisition unit 401, a service interface call request transmission unit 402, a failure count value update unit 403, and a status update unit 404. The state obtaining unit 401 is configured to obtain a state of the service interface when receiving a service interface calling instruction; a service interface call request sending unit 402, configured to send a service interface call request to a provider of the service interface through a connection pool when the state is normal, and wait for an execution result, where the execution result includes a response result of the service interface call request sent by the provider of the service interface; the failure count value updating unit 403 is configured to, after waiting for a predetermined time period, update a pre-stored failure count value of the service interface if the execution result is not obtained; the status updating unit 404 is configured to set the status of the service interface to abnormal when the updated failure count value is greater than a predetermined threshold.
In this embodiment, the specific processing of the status obtaining unit 401, the service interface call request sending unit 402, the failure count value updating unit 403, and the status updating unit 404 may refer to the related descriptions of step 201, step 202, step 203, and step 204 in the corresponding embodiment of fig. 2, which are not described herein again.
In some optional implementations of this embodiment, the service interface call request sending unit 402 may include: a connection acquiring subunit 4021, configured to acquire a connection in the connection pool; the service interface call request sending subunit 4022 is configured to send a service interface call request to the service interface providing end through the connection when the connection is acquired within a first predetermined time length.
In some optional implementation manners of this embodiment, the execution result may further include a connection obtained in the connection pool. And, the failure count value updating unit 203 may include: a first failure count value updating subunit 2031, configured to update a pre-stored failure count value of the service interface when a connection is not acquired within a first predetermined time length; a second failure count value updating subunit 2032, configured to update a pre-stored failure count value of the service interface when the response result sent by the provider of the service interface is not obtained within a second predetermined time length.
In some optional implementation manners of this embodiment, the processing device for a service interface call request according to this embodiment may further include: an exception message sending unit 405, configured to, after obtaining a state of a service interface to be called, send an exception message if the state is an exception. The specific processing of the exception message sending unit 405 may refer to the relevant description of the corresponding implementation manner in the embodiment corresponding to fig. 2, and is not described herein again.
In some optional implementations of this embodiment, the failure count value updating unit 403 may be further configured to send an exception message if the execution result is not obtained after waiting for a predetermined length of time. The specific processing of this implementation may refer to the related description of the corresponding implementation in the embodiment corresponding to fig. 2, and is not described herein again.
In some optional implementation manners of this embodiment, the processing device for a service interface call request according to this embodiment may further include: and an initialization unit (not shown in the figure) configured to clear the failure count value of the service interface at predetermined time intervals, and initialize the state of the service interface to normal. The detailed processing of the initialization unit 406 may refer to the related description of the corresponding implementation manner in the corresponding embodiment of fig. 2, and is not described herein again.
In the processing apparatus for a service interface invocation request provided in this embodiment, after the service interface invocation request is sent by the failure count value updating unit 403, if the execution result is not obtained after the predetermined waiting time length, the pre-stored failure count value of the service interface is updated, and the state of the service interface is updated by the state updating unit 404 according to whether the updated failure count value is greater than the predetermined threshold, so that the service interface state is accurately updated in real time. Meanwhile, when receiving a service interface calling instruction, the state obtaining unit 401 obtains the state of the service interface first, and when the state is normal, the service interface calling request sending unit 402 sends a service interface calling request to the service interface providing terminal through the connection pool, so that the problem that when the service interface is abnormal, a thread for requesting to call the service interface occupies the connection in the connection pool for a long time is avoided, and the phenomenon of system false death is avoided.
Referring now to FIG. 5, shown is a block diagram of a computer system 500 suitable for use in implementing a service interface requirement terminal of an embodiment of the present application.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU)501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the method of the present application when executed by the Central Processing Unit (CPU) 501.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present application may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a state acquisition unit, a service interface call request transmission unit, a failure count value update unit, and a state update unit. The names of these units do not in some cases constitute a limitation on the unit itself, and for example, the status acquisition unit may also be described as "a unit that acquires the status of the service interface when receiving a service interface call instruction".
As another aspect, the present application also provides a non-volatile computer storage medium, which may be the non-volatile computer storage medium included in the apparatus in the above-described embodiments; or it may be a non-volatile computer storage medium that exists separately and is not incorporated into the terminal. The non-transitory computer storage medium stores one or more programs that, when executed by a device, cause the device to: acquiring the state of a service interface when a service interface calling instruction is received; if the state is normal, sending a service interface calling request to a provider of the service interface through a connection pool, and waiting for an execution result, wherein the execution result comprises a response result of the service interface calling request sent by the provider of the service interface; after waiting for a preset time length, if the execution result is not obtained, updating a pre-stored failure count value of the service interface; and if the updated failure count value is larger than a preset threshold value, setting the state of the service interface as abnormal.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by a person skilled in the art that the scope of the invention as referred to in the present application is not limited to the embodiments with a specific combination of the above-mentioned features, but also covers other embodiments with any combination of the above-mentioned features or their equivalents without departing from the inventive concept. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

Claims (12)

1. A method for processing a service interface call request, the method comprising:
acquiring the state of a service interface when a service interface calling instruction is received;
if the state is normal, sending a service interface calling request to a provider of the service interface through a connection pool, and waiting for an execution result, wherein the execution result comprises a response result of the service interface calling request sent by the provider of the service interface and the connection acquired in the connection pool;
after waiting for a preset time length, if the execution result is not obtained, updating a pre-stored failure count value of the service interface;
if the updated failure count value is larger than a preset threshold value, setting the state of the service interface as abnormal;
after waiting for the preset time length, if the execution result is not obtained, updating a pre-stored failure count value of the service interface, including:
if the connection is not acquired within a first preset time length, updating a pre-stored failure count value of the service interface; or
And if the response result sent by the provider of the service interface is not obtained within a second preset time length, updating a pre-stored failure count value of the service interface.
2. The method of claim 1, wherein sending a service interface invocation request to a provider of the service interface through a connection pool comprises:
acquiring a connection in the connection pool;
and if the connection is acquired within the first preset time length, sending a service interface calling request to the service interface providing end through the connection.
3. The method according to any one of claims 1-2, further comprising:
after the state of the service interface to be called is obtained, if the state is abnormal, an abnormal message is sent.
4. The method according to any one of claims 1-2, wherein if the execution result is not obtained after waiting for the predetermined time period, updating a pre-stored failure count value of the service interface, further comprises:
after waiting for a predetermined length of time, if the execution result is not obtained, an exception message is sent.
5. The method according to any one of claims 1-2, further comprising:
and clearing the failure count value of the service interface at preset time intervals, and initializing the state of the service interface to be normal.
6. An apparatus for processing a service interface call request, the apparatus comprising:
the state acquisition unit is used for acquiring the state of the service interface when receiving a service interface calling instruction;
a service interface call request sending unit, configured to send a service interface call request to a provider of the service interface through a connection pool when the state is normal, and wait for an execution result, where the execution result includes a response result of the service interface call request sent by the provider of the service interface and a connection obtained in the connection pool;
a failure count value updating unit, configured to update a pre-stored failure count value of the service interface if the execution result is not obtained after waiting for a predetermined time period;
a state updating unit, configured to set a state of the service interface as abnormal when the updated failure count value is greater than a predetermined threshold value;
the failure count value updating unit includes:
the first failure count value updating subunit is configured to update a pre-stored failure count value of the service interface when a connection is not acquired within a first predetermined time length;
and the second failure count value updating subunit is configured to update the pre-stored failure count value of the service interface when the response result sent by the provider of the service interface is not obtained within a second predetermined time length.
7. The apparatus of claim 6, wherein the service interface call request sending unit comprises:
a connection acquisition subunit, configured to acquire a connection in the connection pool;
and the service interface calling request sending subunit is used for sending a service interface calling request to the service interface providing terminal through the connection when the connection is obtained within a first preset time length.
8. The apparatus of any of claims 6-7, further comprising: and the abnormal message sending unit is used for sending the abnormal message if the state is abnormal after the state of the service interface needing to be called is acquired.
9. The apparatus according to any of claims 6-7, wherein the failure count value updating unit is further configured to send an exception message if the execution result is not obtained after waiting for a predetermined length of time.
10. The apparatus of any of claims 6-7, further comprising: and the initialization unit is used for clearing the failure count value of the service interface at preset time intervals and initializing the state of the service interface to be normal.
11. A server, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-5.
12. A computer-readable storage medium, on which a computer program is stored, wherein the program, when executed by a processor, implements the method of any one of claims 1-5.
CN201610099097.5A 2016-02-23 2016-02-23 Method and device for processing service interface call request Active CN107104999B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610099097.5A CN107104999B (en) 2016-02-23 2016-02-23 Method and device for processing service interface call request

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610099097.5A CN107104999B (en) 2016-02-23 2016-02-23 Method and device for processing service interface call request

Publications (2)

Publication Number Publication Date
CN107104999A CN107104999A (en) 2017-08-29
CN107104999B true CN107104999B (en) 2021-05-25

Family

ID=59658327

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610099097.5A Active CN107104999B (en) 2016-02-23 2016-02-23 Method and device for processing service interface call request

Country Status (1)

Country Link
CN (1) CN107104999B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107562551A (en) * 2017-09-05 2018-01-09 北京小度信息科技有限公司 Monitoring method, device and the computer-readable recording medium of outside access system
CN108021462B (en) * 2017-12-08 2019-06-04 北京百度网讯科技有限公司 Method and apparatus for calling cloud service
CN109343955B (en) * 2018-09-14 2021-03-16 阿里巴巴(中国)有限公司 Recommendation service calling method, medium, device and computing equipment
CN110336856B (en) * 2019-05-10 2021-11-26 成都终身成长科技有限公司 Interface calling method and device, electronic equipment and storage medium
CN113419876A (en) * 2021-06-30 2021-09-21 广州华多网络科技有限公司 Remote interface proxy calling method and device, computer equipment and storage medium
CN116048829B (en) * 2022-07-01 2023-10-10 荣耀终端有限公司 Interface calling method, device and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102325148A (en) * 2011-05-25 2012-01-18 重庆新媒农信科技有限公司 WebService service calling method
WO2013097674A1 (en) * 2011-12-28 2013-07-04 北京奇虎科技有限公司 Distributed system and data operation method thereof
CN104239156A (en) * 2013-06-21 2014-12-24 阿里巴巴集团控股有限公司 External service call method and system
CN104270472A (en) * 2014-10-24 2015-01-07 杭州高达软件系统股份有限公司 Remote service invocation method, device and system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102325148A (en) * 2011-05-25 2012-01-18 重庆新媒农信科技有限公司 WebService service calling method
WO2013097674A1 (en) * 2011-12-28 2013-07-04 北京奇虎科技有限公司 Distributed system and data operation method thereof
CN104239156A (en) * 2013-06-21 2014-12-24 阿里巴巴集团控股有限公司 External service call method and system
CN104270472A (en) * 2014-10-24 2015-01-07 杭州高达软件系统股份有限公司 Remote service invocation method, device and system

Also Published As

Publication number Publication date
CN107104999A (en) 2017-08-29

Similar Documents

Publication Publication Date Title
CN107104999B (en) Method and device for processing service interface call request
US10002202B2 (en) Realtime websites with publication and subscription
CN111475180A (en) Method and system for updating client cache
CN106557288B (en) Method and device for acquiring printing data
CN110098998B (en) Method and apparatus for processing information
US8856365B2 (en) Computer-implemented method, computer system and computer readable medium
CN108011949B (en) Method and apparatus for acquiring data
CN113934464A (en) Method and device for starting android application in Linux system and electronic equipment
CN110619096B (en) Method and apparatus for synchronizing data
CN110365745B (en) Data processing system, method, apparatus, server and computer readable medium
CN113779054A (en) Data updating method, device, server, storage medium and program product
CN111246228A (en) Method, device, medium and electronic equipment for updating gift resources of live broadcast room
CN109428926B (en) Method and device for scheduling task nodes
CN110113176B (en) Information synchronization method and device for configuration server
CN109981546B (en) Method and device for acquiring remote call relation between application modules
CN110730197B (en) Service discovery method and system
CN111783005B (en) Method, device and system for displaying web page, computer system and medium
CN109471713B (en) Method and device for inquiring information
CN110807535A (en) Construction method and construction device of unified reservation platform and unified reservation platform system
CN112948138A (en) Method and device for processing message
CN113127561B (en) Method and device for generating service single number, electronic equipment and storage medium
CN115442420A (en) Block chain cross-chain service management method and device
CN112559001B (en) Method and device for updating application
CN112882895A (en) Health examination method, device, computer system and readable storage medium
CN112784139A (en) Query method, query device, electronic equipment and computer readable 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