CN114640720A - Service protocol switching method and device - Google Patents

Service protocol switching method and device Download PDF

Info

Publication number
CN114640720A
CN114640720A CN202210255450.XA CN202210255450A CN114640720A CN 114640720 A CN114640720 A CN 114640720A CN 202210255450 A CN202210255450 A CN 202210255450A CN 114640720 A CN114640720 A CN 114640720A
Authority
CN
China
Prior art keywords
service
protocol
actuator
request
publishing packet
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.)
Pending
Application number
CN202210255450.XA
Other languages
Chinese (zh)
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 Qianshi Technology Co Ltd
Original Assignee
Beijing Jingdong Qianshi 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 Qianshi Technology Co Ltd filed Critical Beijing Jingdong Qianshi Technology Co Ltd
Priority to CN202210255450.XA priority Critical patent/CN114640720A/en
Publication of CN114640720A publication Critical patent/CN114640720A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/08Protocols for interworking; Protocol conversion
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/2866Architectures; Arrangements
    • H04L67/30Profiles
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/18Multiprotocol handlers, e.g. single devices capable of handling multiple protocols

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a method and a device for switching service protocols, and relates to the technical field of computers. One embodiment of the method comprises: determining a service publisher corresponding to a publishing packet according to the configured publishing packet based on a first protocol, wherein the first protocol is a protocol different from a second protocol based on the service currently; loading the publishing packet through a service publisher corresponding to the publishing packet to publish the service according to a first protocol; the received request is processed by a service based on a first protocol. The implementation method can optimize the bottom program, reduce the occupied memory, reduce the research and development difficulty and the maintenance cost, and shorten the research and development time.

Description

Service protocol switching method and device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for switching a service protocol.
Background
For a tenant system, service protocols need to be switched frequently in a multi-tenant and multi-scenario. The current service protocol switching scheme is to pull a plurality of branches for a project, each branch corresponds to a service protocol, and the problems of high later maintenance cost and inconsistent codes exist.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
the adaptation of the protocol layer makes the bottom layer program of the project overstaffed, the project has strong dependence on the frame, and the occupied memory is large, the research and development difficulty is large, the research and development time is long, and the maintenance cost is high.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for switching a service protocol, which can optimize a bottom program, decouple dependence on a worker scheduling framework, reduce memory occupation, reduce research and development difficulty and maintenance cost, and shorten research and development time.
In order to achieve the above object, according to an aspect of an embodiment of the present invention, a method for switching a service protocol is provided.
A method for switching service protocols comprises the following steps: determining a service publisher corresponding to a configured publishing packet based on a first protocol, wherein the first protocol is a different protocol from a second protocol based on the service currently; loading the publishing packet through a service publisher corresponding to the publishing packet to publish the service according to the first protocol; processing the received request by the service based on the first protocol.
Optionally, the determining, according to the configured publishing packet based on the first protocol, that the service publisher corresponding to the publishing packet is before includes: and acquiring the configured first protocol-based publishing packet from the dependent packet management plugin, and loading a configuration file in a preset path through a configuration file loader, wherein the configuration file comprises an initialization file of a service publisher corresponding to the publishing packet.
Optionally, before the loading the publishing packet by the service publisher corresponding to the publishing packet to publish the service according to the first protocol, the method includes: and pre-configuring initialization files of a plurality of service publishers in the configuration file.
Optionally, the loading the publishing packet through a service publisher corresponding to the publishing packet to publish the service according to the first protocol includes: and dynamically loading the specific implementation class of the service publisher corresponding to the publishing packet according to the initialization file of the service publisher corresponding to the publishing packet in the configuration file so as to publish the service according to the first protocol.
Optionally, the processing the received request by the service based on the first protocol includes: determining a type of the request according to the first protocol; analyzing the request according to an analysis rule corresponding to the type of the request to obtain an actuator identifier, wherein the actuator identifier is an identifier of an actuator used for processing the request; and searching the corresponding actuator name from the actuator name searcher according to the actuator identification, and routing the request to the actuator instance corresponding to the actuator name for processing.
Optionally, the routing the request to the executor instance corresponding to the executor name for processing includes: according to the actuator name, retrieving a corresponding actuator instance from a spring container, or completing instantiation of the actuator through a reflection mechanism to create the actuator instance; the request is processed by the executor instance.
According to another aspect of the embodiments of the present invention, a device for switching a service protocol is provided.
A switching apparatus of a service protocol, comprising: the service publisher determining module is used for determining a service publisher corresponding to a configured publishing packet based on a first protocol, wherein the first protocol is a protocol different from a second protocol based on the service currently; the issuing package loading module is used for loading the issuing package through a service issuer corresponding to the issuing package so as to issue the service according to the first protocol; a request processing module for processing the received request by the service based on the first protocol.
Optionally, the system further comprises an initialization module, configured to: and acquiring the configured first protocol-based publishing packet from the dependent packet management plugin, and loading a configuration file in a preset path through a configuration file loader, wherein the configuration file comprises an initialization file of a service publisher corresponding to the publishing packet.
Optionally, the initialization module is further configured to: and pre-configuring initialization files of a plurality of service publishers in the configuration file.
Optionally, the publishing package loading module is further configured to: and dynamically loading the specific implementation class of the service publisher corresponding to the publishing packet according to the initialization file of the service publisher corresponding to the publishing packet in the configuration file so as to publish the service according to the first protocol.
Optionally, the request processing module is further configured to: determining a type of the request according to the first protocol; analyzing the request according to an analysis rule corresponding to the type of the request to obtain an actuator identifier, wherein the actuator identifier is an identifier of an actuator used for processing the request; and searching the corresponding actuator name from the actuator name searching device according to the actuator identifier, and routing the request to the actuator instance corresponding to the actuator name for processing.
Optionally, the request processing module is further configured to: according to the actuator name, retrieving a corresponding actuator instance from a spring container, or completing instantiation of the actuator through a reflection mechanism to create the actuator instance; the request is processed by the executor instance.
According to yet another aspect of an embodiment of the present invention, an electronic device is provided.
An electronic device, comprising: one or more processors; a memory for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement the method for switching service protocols provided by the embodiments of the present invention.
According to yet another aspect of an embodiment of the present invention, a computer-readable medium is provided.
A computer-readable medium, on which a computer program is stored, which, when executed by a processor, implements a method for switching a service agreement provided by an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: determining a service publisher corresponding to a publishing packet according to the configured publishing packet based on a first protocol, wherein the first protocol is a protocol different from a second protocol based on the service currently; loading the publishing packet through a service publisher corresponding to the publishing packet to publish the service according to a first protocol; the received request is processed by a service based on a first protocol. The method can optimize a bottom program, decouple the dependence on a worker scheduling framework, and completely use the framework to a productized project without intruding, so that the support or adaptation of a protocol is not required to be added to worker service for switching the protocol, the memory occupation is reduced, the research and development difficulty and the maintenance cost are reduced, and the research and development time is shortened.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a schematic diagram of the main steps of a handover method of a service agreement according to one embodiment of the present invention;
FIG. 2 is a schematic diagram of the architecture of a worker adapter kernel package according to one embodiment of the present invention;
FIG. 3 is a flow diagram of a handoff service protocol according to one embodiment of the present invention;
FIG. 4 is an architectural diagram of a handoff services protocol according to one embodiment of the present invention;
FIG. 5 is an architectural diagram of a lookup executor according to one embodiment of the invention;
FIG. 6 is an architectural diagram of a service publisher according to one embodiment of the invention;
FIG. 7 is a schematic diagram of the main blocks of a switching device for service agreements according to one embodiment of the present invention;
FIG. 8 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 9 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of main steps of a handover method of a service protocol according to an embodiment of the present invention.
As shown in fig. 1, the method for switching a service protocol according to an embodiment of the present invention mainly includes the following steps S101 to S103.
Step S101: and determining a service publisher corresponding to the publishing packet according to the configured publishing packet based on a first protocol, wherein the first protocol is different from a second protocol on which the service is currently based.
Determining, according to the configured first protocol-based publishing packet, that a service publisher corresponding to the publishing packet precedes, may include: and acquiring a configured first protocol-based publishing packet from the dependent packet management plugin, and loading a configuration file in a preset path through a configuration file loader, wherein the configuration file comprises an initialization file of a service publisher corresponding to the publishing packet.
A service publisher (ServerPublisher) is used to publish a service through a certain protocol, which may be referred to as a service based on the protocol.
Step S102: the publishing package is loaded by a service publisher corresponding to the publishing package to publish the service according to the first protocol.
Before loading the publishing packet through the service publisher corresponding to the publishing packet to publish the service according to the first protocol, the method may include: the initialization files of the plurality of service publishers are pre-configured in a configuration file.
Loading the publishing package through a service publisher corresponding to the publishing package to publish the service according to the first protocol may include: and dynamically loading the specific implementation class of the service publisher corresponding to the publishing packet according to the initialization file of the service publisher corresponding to the publishing packet in the configuration file so as to publish the service according to the first protocol.
Step S103: the received request is processed by a service based on a first protocol.
The service based on the first protocol may be a worker (timing) service.
Processing the received request through the first protocol based service may include: determining the type of a request according to a first protocol, wherein the types of the requests corresponding to different protocols are different; analyzing the request according to an analysis rule corresponding to the type of the request to obtain an executor (explorer) identifier, where the executor identifier is an identifier of an executor for processing the request, for example, when the issued service protocol is http service, the type of the request is http service, and the corresponding analysis rule is URI for analyzing http, then analyzing the URI of http contained in the request as routerkey (i.e., executor identifier); under the condition that the issued service protocol is jsf or the Dubbo protocol, the type of the request is jsf or the type of the Dubbo protocol, and the corresponding analysis rule is the alias (alias) used by the RPC (remote procedure call protocol), so that the alias used by the RPC contained in the request is analyzed as a routerkey; and searching the corresponding actuator name from an actuator name (InvokerName) finder according to the actuator identifier, and routing the request to the actuator instance corresponding to the actuator name for processing.
Routing the request to the executor instance corresponding to the executor name for processing may include: according to the actuator name, retrieving a corresponding actuator instance from a spring container, or completing instantiation of an actuator through a reflection mechanism to create an actuator instance, wherein the actuator instance comprises a method for processing a received request; the request is processed by the executor instance.
In one embodiment, according to the configured publishing package based on the first protocol, a service publisher corresponding to the publishing package is determined, and the configured publishing package based on the first protocol is obtained from the dependent package management plug-in, wherein the first protocol is different from a second protocol on which the service is currently based. Specifically, a required service protocol is determined according to a use environment, an publishing packet of the service protocol (namely, a first protocol) is configured into a dependent packet management plugin, and an original service protocol (namely, a second protocol) in the dependent packet management plugin is replaced, so that the configured publishing packet based on the service protocol is obtained from the dependent packet management plugin and serves as a worker-adapter-core packet (worker-adapter-core), wherein the worker-adapter-core packet is used for configuring the service protocol in a worker service. The framework of the worker adapter kernel package according to an embodiment of the present invention is shown in fig. 2, and the publishing package of the service protocol may be one of a rest (Representational State Transfer, a software architecture style) service publishing package, a dubbo (a service framework with excellent performance) protocol publishing package, and an jsf (a standard framework for constructing Java Web applications) publishing package. In the case of using a spring (J2 EE application framework of an open source code) container, the publishing packet of the service protocol may be used as a worker-adapter-spring packet (worker-adapter-spring), so as to obtain a worker-adapter kernel packet through the spring container. The worker adapter spring package is a worker adapter core package when spring hosting is performed.
In one embodiment, the initialization files of a plurality of service issuers are configured in a configuration file in advance, and the configuration file in the preset path is loaded through a configuration file loader, wherein the configuration file comprises the initialization file of the service issuer corresponding to the issuing package. After a worker adapter (worker adapter) is started, a configuration file in a preset path can be loaded through a configuration file loader, so that the initialization of a service publisher corresponding to a publishing packet is realized through initializing an executor manager, and the data initialization of an executor name finder and an executor instance finder is completed, so that the service publisher, the executor name finder and the executor instance finder can be used in a subsequent flow conveniently. The broker adapter is a defined packaging class in the broker service, and is used for packaging objects of incompatible interfaces, the packaged objects may be adapted classes, and the executor manager is provided with a service publisher API layer, which includes multiple service publishers such as a dubbo protocol publisher, an jsf protocol publisher, and a rest service protocol publisher. In the case of using the spring container for hosting, the preset path may be determined according to a variable (i.e., worker. configuration. path) configured by the user in the context of the spring container, and if the preset path is not configured, the preset path is a default path (i.e., worker. configuration. properties).
Fig. 3 is a flow diagram of a handover service protocol according to one embodiment of the invention.
As shown in fig. 3, in the worker (i.e., timing) service, a worker launcher (i.e., a worker adapter launcher) is started, where the worker adapter launcher is an entry for starting the worker service and is also a uniform scheduling entry for issuing and processing a load of a kernel service, and all internal flows are executed by the worker launcher, so as to provide a uniform entry for the worker service. And triggering the configuration file loader to load the configuration file, and finishing the initialization of the service publisher corresponding to the publishing packet by loading the initialization file of the service publisher corresponding to the publishing packet to obtain the service publisher corresponding to the publishing packet. And dynamically loading the issuing packet of the service protocol in an SPI (serial peripheral interface) mode through a service issuer corresponding to the issuing packet so as to issue the service protocol. And receiving a request to be processed, and acquiring a routerkey (namely an actuator identifier) in the request based on the issued service protocol. And searching the corresponding actuator name in the actuator name searching device according to the routerkey, obtaining an actuator example in the actuator example searching device based on the searched actuator name, and executing the method in the actuator example to process the received request. The embodiment of the invention can realize the modification of the service protocol of the worker, can be completed only by modifying the configuration file, does not need any modification on other code layers, and realizes the purpose of zero code one-key switching.
In one embodiment, the type of the request is determined according to the first protocol, and the request is parsed according to a parsing rule corresponding to the type of the request to obtain an executor identifier, which is an identifier of an executor for processing the request. For example, when the issued service protocol is http service, and the type of the request is http service, the URI of http contained in the request is parsed as routerkey; in the case that the issued service protocol is jsf or the dubbo protocol, and the type of the request is jsf or the type of the dubbo protocol, the alias (alias) used by the RPC (remote procedure call protocol) included in the request is parsed as the routerkey. The routerkey is a key of the configuration file, and is a unique identifier of the actuator in the worker service.
In one embodiment, the corresponding actuator instance is retrieved from the spring container according to the actuator name, or instantiation of the actuator is completed through a reflection mechanism to create the actuator instance, and the request is processed through the actuator instance. Specifically, in the case of using spring hosting, the corresponding actuator instance may be retrieved through a built-in spring container according to the actuator name, and the creation of the actuator instance is completed through a default reflection mechanism.
In one embodiment, the dependency package management plug-in may be a maven (project management tool) plug-in, the maven plug-in may configure a plurality of environments according to a dependency package (i.e., a publishing package) used as needed, each environment may use a different dependency package, and a service protocol to be used is activated through profiles (personalized environments) of maven.
Fig. 4 is an architecture diagram of a handover services protocol according to one embodiment of the present invention.
As shown in fig. 4, the protocol enumeration class includes service protocols such as http, jsf, and dubbo, the service configuration includes a configuration file, and configures a protocol according to a service protocol that needs to be used, the protocol configuration manager includes a plurality of service issuers, a service configuration loader (i.e., a configuration file loader) is used to load the configuration file, and a service configuration loader interface is used to configure a preset path.
FIG. 5 is an architectural diagram of a lookup executor, according to one embodiment of the invention.
As shown in fig. 5, the executor is configured to process a message class, and may specifically process a received request, the service instance factory (beans factorayware) includes multiple executor instances, a default executor finder (defaultinvokefinder) is configured to find an executor (explorer) that processes the request, a spring context instance finder (spring invokefinder) and a default instance finder are configured to find a specific instance of the executor, an instance name finder (beans finder) is configured to find a name of the executor instance, and an executor finder (invokefinder) interface is configured to interface with an executor manager (invokemanager).
FIG. 6 is an architectural diagram of a service publisher according to one embodiment of the invention.
As shown in fig. 6, the API layer of the service publisher may be located in the executor manager, and its specific implementation class includes multiple service publishers, such as a dubbo protocol publisher, an jsf protocol publisher, and a rest service protocol publisher, and an instance initializibean (initializibean) is configured according to the multiple service publishers, where the instance initializer is an interface for one of the springs to further adjust an instance of the bean.
Fig. 7 is a schematic diagram of main blocks of a switching apparatus of a service agreement according to an embodiment of the present invention.
As shown in fig. 7, a switching apparatus 700 for a service agreement according to an embodiment of the present invention mainly includes: a service publisher determining module 701, a publishing packet loading module 702 and a request processing module 703.
The service publisher determining module 701 is configured to determine, according to a configured publishing packet based on a first protocol, a service publisher corresponding to the publishing packet, where the first protocol is a protocol different from a second protocol on which the service is currently based.
The publishing packet loading module 702 is configured to load the publishing packet through a service publisher corresponding to the publishing packet, so as to publish the service according to the first protocol.
A request processing module 703, configured to process the received request through a service based on the first protocol.
In one embodiment, the apparatus may further include an initialization module to: and acquiring the configured issuing package based on the first protocol from the dependent package management plug-in, and loading a configuration file in a preset path through a configuration file loader, wherein the configuration file comprises an initialization file of a service issuer corresponding to the issuing package.
In one embodiment, the initialization module is specifically configured to: the initialization files of the plurality of service publishers are pre-configured in a configuration file.
In an embodiment, the publishing packet loading module 702 is specifically configured to: and dynamically loading the specific implementation class of the service publisher corresponding to the publishing packet according to the initialization file of the service publisher corresponding to the publishing packet in the configuration file so as to publish the service according to the first protocol.
In one embodiment, the request processing module 703 is specifically configured to: determining a type of the request according to a first protocol; analyzing the request according to an analysis rule corresponding to the type of the request to obtain an actuator identifier, wherein the actuator identifier is an identifier of an actuator for processing the request; and searching the corresponding actuator name from the actuator name searching device according to the actuator identifier, and routing the request to the actuator instance corresponding to the actuator name for processing.
In one embodiment, the request processing module 703 is specifically configured to: according to the actuator name, retrieving a corresponding actuator instance from a spring container, or completing instantiation of an actuator through a reflection mechanism to create an actuator instance; the request is processed by the executor instance.
In addition, the detailed implementation of the switching device of the service protocol in the embodiment of the present invention has been described in detail in the above switching method of the service protocol, and therefore, the repeated content is not described again.
Fig. 8 shows an exemplary system architecture 800 of a switching method of a service protocol or a switching apparatus of a service protocol to which an embodiment of the present invention can be applied.
As shown in fig. 8, the system architecture 800 may include terminal devices 801, 802, 803, a network 804, and a server 805. The network 804 serves to provide a medium for communication links between the terminal devices 801, 802, 803 and the server 805. Network 804 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 801, 802, 803 to interact with a server 805 over a network 804 to receive or send messages or the like. The terminal devices 801, 802, 803 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 801, 802, 803 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 805 may be a server that provides various services, such as a back-office management server (for example only) that supports shopping-like websites browsed by users using the terminal devices 801, 802, 803. The backend management server may analyze and process the received data such as the product information query request, and feed back a processing result (for example, target push information and product information — just an example) to the terminal device.
It should be noted that the method for switching the service protocol provided by the embodiment of the present invention is generally executed by the server 805, and accordingly, the switching device for the service protocol is generally disposed in the server 805.
It should be understood that the number of terminal devices, networks, and servers in fig. 8 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 9, a block diagram of a computer system 900 suitable for use with a terminal device or server implementing an embodiment of the invention is shown. The terminal device or the server shown in fig. 9 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 9, the computer system 900 includes a Central Processing Unit (CPU)901 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)902 or a program loaded from a storage section 908 into a Random Access Memory (RAM) 903. In the RAM 903, various programs and data necessary for the operation of the system 900 are also stored. The CPU 901, ROM 902, and RAM 903 are connected to each other via a bus 904. An input/output (I/O) interface 905 is also connected to bus 904.
The following components are connected to the I/O interface 905: an input portion 906 including a keyboard, a mouse, and the like; an output section 907 including components such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 908 including a hard disk and the like; and a communication section 909 including a network interface card such as a LAN card, a modem, or the like. The communication section 909 performs communication processing via a network such as the internet. The drive 910 is also connected to the I/O interface 905 as necessary. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 910 as necessary, so that a computer program read out therefrom is mounted into the storage section 908 as necessary.
In particular, according to the embodiments 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 embodied on a computer 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 909, and/or installed from the removable medium 911. The above-described functions defined in the system of the present invention are executed when the computer program is executed by a Central Processing Unit (CPU) 901.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
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 invention. 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 or flowchart illustration, and combinations of blocks in the block diagrams 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 modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor comprises a service publisher determining module, a publishing packet loading module and a request processing module. Where the names of these modules do not constitute a limitation on the module itself in some cases, for example, the service publisher determination module may also be described as "a module for determining a service publisher corresponding to a distribution package according to a configured distribution package based on a first protocol".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: determining a service publisher corresponding to a publishing packet according to the configured publishing packet based on a first protocol, wherein the first protocol is a protocol different from a second protocol based on the service currently; loading the publishing packet through a service publisher corresponding to the publishing packet to publish the service according to a first protocol; the received request is processed by a service based on a first protocol.
According to the technical scheme of the embodiment of the invention, a service publisher corresponding to a distribution packet is determined according to the configured distribution packet based on a first protocol, wherein the first protocol is a protocol different from a second protocol based on the service currently; loading the publishing packet through a service publisher corresponding to the publishing packet to publish the service according to a first protocol; the received request is processed by a service based on a first protocol. The method can optimize the bottom program, reduce the memory occupation, reduce the research and development difficulty and the maintenance cost, and shorten the research and development time.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for switching a service agreement, comprising:
determining a service publisher corresponding to a configured publishing packet based on a first protocol, wherein the first protocol is a different protocol from a second protocol based on the service currently;
loading the publishing packet through a service publisher corresponding to the publishing packet to publish the service according to the first protocol;
processing the received request by the service based on the first protocol.
2. The method of claim 1, wherein determining, according to the configured first protocol-based publishing packet, a service publisher corresponding to the publishing packet is preceded by:
and acquiring the configured first protocol-based publishing packet from the dependent packet management plug-in, and loading a configuration file in a preset path through a configuration file loader, wherein the configuration file comprises an initialization file of a service publisher corresponding to the publishing packet.
3. The method of claim 2, wherein prior to loading the publishing packet by a service publisher corresponding to the publishing packet to publish the service according to the first protocol, the method comprises:
and pre-configuring initialization files of a plurality of service publishers in the configuration file.
4. The method of claim 2, wherein the loading the publishing packet by a service publisher corresponding to the publishing packet to publish the service according to the first protocol comprises:
and dynamically loading the specific implementation class of the service publisher corresponding to the publishing packet according to the initialization file of the service publisher corresponding to the publishing packet in the configuration file so as to publish the service according to the first protocol.
5. The method of claim 1, wherein processing the received request through the service based on the first protocol comprises:
determining a type of the request according to the first protocol;
analyzing the request according to an analysis rule corresponding to the type of the request to obtain an actuator identifier, wherein the actuator identifier is an identifier of an actuator used for processing the request;
and searching the corresponding actuator name from the actuator name searching device according to the actuator identifier, and routing the request to the actuator instance corresponding to the actuator name for processing.
6. The method of claim 5, wherein routing the request to the actuator instance corresponding to the actuator name for processing comprises:
according to the actuator name, retrieving a corresponding actuator instance from a spring container, or completing instantiation of the actuator through a reflection mechanism to create the actuator instance;
the request is processed by the executor instance.
7. An apparatus for switching a service agreement, comprising:
the service publisher determining module is used for determining a service publisher corresponding to a configured publishing packet based on a first protocol, wherein the first protocol is a protocol different from a second protocol based on the service currently;
the issuing package loading module is used for loading the issuing package through a service issuer corresponding to the issuing package so as to issue the service according to the first protocol;
a request processing module for processing the received request by the service based on the first protocol.
8. The apparatus of claim 7, further comprising an initialization module to:
and acquiring the configured first protocol-based publishing packet from the dependent packet management plug-in, and loading a configuration file in a preset path through a configuration file loader, wherein the configuration file comprises an initialization file of a service publisher corresponding to the publishing packet.
9. An electronic device, 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-6.
10. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN202210255450.XA 2022-03-15 2022-03-15 Service protocol switching method and device Pending CN114640720A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210255450.XA CN114640720A (en) 2022-03-15 2022-03-15 Service protocol switching method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210255450.XA CN114640720A (en) 2022-03-15 2022-03-15 Service protocol switching method and device

Publications (1)

Publication Number Publication Date
CN114640720A true CN114640720A (en) 2022-06-17

Family

ID=81948604

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210255450.XA Pending CN114640720A (en) 2022-03-15 2022-03-15 Service protocol switching method and device

Country Status (1)

Country Link
CN (1) CN114640720A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060094413A1 (en) * 2004-11-01 2006-05-04 Evans Mark S Application protocol identification
US20130275489A1 (en) * 2012-04-12 2013-10-17 Oracle International Corporation Integration of web services with a clustered actor based model
CN105245369A (en) * 2015-10-12 2016-01-13 天津市普迅电力信息技术有限公司 Component issuing container method supporting multiple transport protocols
CN112751812A (en) * 2019-10-31 2021-05-04 北京京东振世信息技术有限公司 Method and device for self-adapting application protocol
CN113778499A (en) * 2020-08-21 2021-12-10 北京京东振世信息技术有限公司 Method, device, equipment and computer readable medium for publishing service

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060094413A1 (en) * 2004-11-01 2006-05-04 Evans Mark S Application protocol identification
US20130275489A1 (en) * 2012-04-12 2013-10-17 Oracle International Corporation Integration of web services with a clustered actor based model
CN105245369A (en) * 2015-10-12 2016-01-13 天津市普迅电力信息技术有限公司 Component issuing container method supporting multiple transport protocols
CN112751812A (en) * 2019-10-31 2021-05-04 北京京东振世信息技术有限公司 Method and device for self-adapting application protocol
CN113778499A (en) * 2020-08-21 2021-12-10 北京京东振世信息技术有限公司 Method, device, equipment and computer readable medium for publishing service

Similar Documents

Publication Publication Date Title
US11170065B2 (en) Technology agnostic UI microservices
CN111045833B (en) Interface calling method and device
US10656972B2 (en) Managing idempotent operations while interacting with a system of record
CN109327490B (en) Method and server for deploying cloud service component
CN110968340A (en) Method and device for realizing multi-version dependence isolation
CN111831461A (en) Method and device for processing business process
CN107809470B (en) Method and device for automatically deploying application program
CN113595927A (en) Method and device for processing mirror flow in bypass mode
CN109981546B (en) Method and device for acquiring remote call relation between application modules
CN112214250A (en) Application program assembly loading method and device
CN112748962A (en) Application loading method and device, electronic equipment and computer readable medium
US10776133B2 (en) Preemptive loading of code dependencies for improved performance
CN114640720A (en) Service protocol switching method and device
CN113779122B (en) Method and device for exporting data
CN113765983A (en) Site service deployment method and device
WO2021243665A1 (en) Compilation method, compilation apparatus, compilation system, storage medium, and electronic device
CN113760487A (en) Service processing method and device
CN112099841A (en) Method and system for generating configuration file
CN113516523A (en) Order data processing method and order receiving system
CN113448652A (en) Request processing method and device
CN111984616A (en) Method, device and system for updating shared file
CN113495747B (en) Gray scale release method and device
CN111176679A (en) Application program updating method and device
CN113077201A (en) Method, device and system for analyzing service parameters
CN112835609A (en) Method and device for modifying dependent package download address

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