CN115766374A - Dds and REST protocol conversion method - Google Patents

Dds and REST protocol conversion method Download PDF

Info

Publication number
CN115766374A
CN115766374A CN202211426216.5A CN202211426216A CN115766374A CN 115766374 A CN115766374 A CN 115766374A CN 202211426216 A CN202211426216 A CN 202211426216A CN 115766374 A CN115766374 A CN 115766374A
Authority
CN
China
Prior art keywords
protocol data
protocol
data
dds
rest
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
CN202211426216.5A
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.)
Anhui Leju Artificial Intelligence Application Technology Service Co ltd
Harbin Institute of Technology
Original Assignee
Anhui Leju Artificial Intelligence Application Technology Service Co ltd
Harbin Institute of Technology
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 Anhui Leju Artificial Intelligence Application Technology Service Co ltd, Harbin Institute of Technology filed Critical Anhui Leju Artificial Intelligence Application Technology Service Co ltd
Priority to CN202211426216.5A priority Critical patent/CN115766374A/en
Publication of CN115766374A publication Critical patent/CN115766374A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Computer And Data Communications (AREA)

Abstract

The application relates to a dds and REST protocol conversion method, in particular to the technical field of data communication. The method comprises the following steps: receiving first protocol data; when the first protocol data is detected to be REST protocol data in a Json format, converting the first protocol data through a mapping file to obtain second protocol data of a target theme; the mapping file contains the mapping relation between the data of the REST protocol and the subject data of the dds protocol; creating a publishing entity object of a target topic in a target domain; and writing the second protocol data of the target subject into the publishing entity object of the target subject according to the write QOS strategy. According to the scheme, when REST protocol data in a Json format is received, communication among different protocols can be achieved through the converted data after simple conversion is carried out through the mapping file.

Description

Dds and REST protocol conversion method
Technical Field
The invention relates to the technical field of data communication, in particular to a dds and REST protocol conversion method.
Background
Representational State Transfer (REST) is a software architecture style, and is a design and development mode aiming at network application, which can reduce the development complexity and improve the scalability of a system.
In the application layer of the internet of things, resources in the internet of things are opened through REST/HTTP frequently, and services are called by other applications. The method and the device are used for realizing loose coupling of interaction between the client and the server, and interaction delay between the client and the server is reduced. The core of the existing REST application layer transmission protocol is that resources are used as the center, data services are opened in an Internet of things application system in a REST API opening mode, REST is stateless communication, safety is weak, and communication data volume is closely related to API content. The dds protocol adopts a subscription-publishing mechanism, realizes point-to-point direct communication by taking data as a center, and has strong compatibility, high reliability and real-time performance. When data is transmitted, only data in one protocol format is supported for transmission, and other protocols cannot be supported.
Therefore, a solution for performing protocol conversion between the dds protocol and the REST protocol is needed to enable devices supporting different protocols to implement data communication.
Disclosure of Invention
The application provides a dds and REST protocol conversion method, which can realize communication between different protocols through converted data.
In one aspect, a method for converting dds and REST protocol is provided, the method comprising:
receiving first protocol data;
when the first protocol data is detected to be REST protocol data in a Json format, converting the first protocol data through a mapping file to obtain second protocol data of a target theme; the mapping file comprises a mapping relation between data of the REST protocol and subject data of the dds protocol;
creating a publishing entity object of a target topic in a target domain;
and writing the second protocol data of the target subject into the publishing entity object of the target subject according to the write QOS strategy.
In another aspect, a dds and REST protocol conversion apparatus is provided, the apparatus comprising:
the protocol data receiving module is used for receiving first protocol data;
the protocol conversion module is used for converting the first protocol data through a mapping file to obtain second protocol data of a target subject when the first protocol data is detected to be REST protocol data in a Json format; the mapping file comprises a mapping relation between data of the REST protocol and subject data of the dds protocol;
the release object creating module is used for creating a release entity object of the target theme in the target domain;
and the data writing module is used for writing the second protocol data of the target subject into the issuing entity object of the target subject according to the writing QOS strategy.
In one possible implementation, the apparatus further includes:
and the protocol data sending module is used for sending the first protocol data to a corresponding application program when detecting that the first protocol data is dds protocol data received by the data subscription entity.
In a possible implementation manner, the protocol data sending module is further configured to obtain a theme of the first protocol data, and convert the first protocol data through the mapping file according to the theme of the first protocol data to obtain third protocol data in a Json format;
and sending the third protocol data in the Json format to a corresponding application program.
In one possible implementation, the apparatus further includes:
the initial data acquisition module is used for acquiring initial REST protocol data and initial dds protocol data;
the first mapping module is used for configuring key value pairs for the initial REST protocol data and generating a first mapping table;
the second mapping module is used for configuring key value pairs for the initial dds protocol data to obtain a second mapping table;
and the mapping file generating module is used for generating a mapping relation between the initial REST protocol data and the initial dds protocol data based on the first mapping table and the second mapping table, and storing the mapping relation into the mapping file.
In one possible implementation, the apparatus further includes:
and the subscription object creating module is used for creating a subscription entity object of the target topic in the target domain according to the target topic.
In one possible implementation, the apparatus further includes:
the data caching module is used for caching the first protocol data into a message queue after receiving the first protocol data;
the data polling module is used for polling the message queue according to a specified processing period and taking out first protocol data in the message queue;
the data checking module is used for performing data analysis after deserializing the first protocol data and checking the integrity of the first protocol data;
and the data detection module is used for detecting the protocol format of the first protocol data when the first protocol data is complete protocol data.
In a possible implementation manner, the data caching module is further configured to store the first protocol data in a temporary buffer area and splice the first protocol data with data in the temporary buffer area when the first protocol is incomplete;
the data verification module is further used for performing data analysis on the spliced first protocol data and verifying the integrity of the spliced first protocol data;
the data detection module is further configured to detect a protocol format of the spliced first protocol data when the spliced first protocol data is complete protocol data.
In another aspect, a computer device is provided, which includes a processor and a memory, where the memory stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the dds and REST protocol conversion method described above.
In yet another aspect, a computer-readable storage medium is provided, in which at least one instruction is stored, and the at least one instruction is loaded and executed by a processor to implement the dds and REST protocol conversion method described above.
In yet another aspect, a computer program product or computer program is provided, the computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer readable storage medium, and executes the computer instructions, so that the computer device executes the dds and REST protocol conversion method.
The technical scheme provided by the application can comprise the following beneficial effects:
when the computer device receives first protocol data, the computer device firstly identifies the protocol type of the first protocol data, when the first protocol data is detected to be REST protocol data in a Json format, the first protocol data is converted into second protocol data through a mapping file, the second protocol data is dds protocol data of a target topic type because the mapping file contains the mapping relation between the REST protocol data and the topic data of dds protocol, the computer device creates a publishing entity object of the target topic in a target domain in dds protocol, and writes the second protocol data of the target topic into the publishing entity object of the target topic through a write QOS strategy, and at the moment, an entity subscription object subscribing the target topic can detect the change of the data, so that the communication through dds protocol is realized. In the scheme, when REST protocol data in a Json format is received, communication among different protocols can be realized through the converted data after simple conversion is carried out through the mapping file.
Drawings
In order to more clearly illustrate the detailed description of the present application or the technical solutions in the prior art, the drawings needed to be used in the detailed description of the present application or the prior art description will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a block diagram illustrating a computer system in accordance with an exemplary embodiment.
Fig. 2 is a flowchart illustrating a method for dds and REST protocol conversion method according to an example embodiment.
Fig. 3 is a flowchart illustrating a method for dds and REST protocol conversion method according to an example embodiment.
Fig. 4 shows a schematic structural diagram of dds and REST protocol conversion apparatus according to an embodiment of the present application.
FIG. 5 is a schematic diagram of a computer device provided in accordance with an exemplary embodiment of the present application.
Detailed Description
The technical solutions of the present application will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be understood that "indication" mentioned in the embodiments of the present application may be a direct indication, an indirect indication, or an indication of an association relationship. For example, a indicates B, which may mean that a directly indicates B, e.g., B may be obtained by a; it may also mean that a indicates B indirectly, for example, a indicates C, and B may be obtained by C; it can also mean that there is an association between a and B.
In the description of the embodiments of the present application, the term "correspond" may indicate that there is a direct correspondence or an indirect correspondence between the two, may also indicate that there is an association between the two, and may also indicate and be indicated, configure and configured, and so on.
In the embodiment of the present application, "predefining" may be implemented by saving a corresponding code, table, or other manners that may be used to indicate related information in advance in a device (for example, including a terminal device and a network device), and the present application is not limited to a specific implementation manner thereof.
Before describing the various embodiments shown herein, several concepts related to the present application will be described.
1) Internet of things
The Internet of Things (Internet of Things, ioT for short) is to collect any object or process needing monitoring, connection and interaction in real time and collect various required information such as sound, light, heat, electricity, mechanics, chemistry, biology and location through various devices and technologies such as various information sensors, radio frequency identification technologies, global positioning systems, infrared sensors and laser scanners, and to realize ubiquitous connection of objects and people through various possible network accesses, and to realize intelligent sensing, identification and management of objects and processes. The internet of things is an information bearer based on the internet, a traditional telecommunication network and the like, and all common physical objects which can be independently addressed form an interconnected network. In the application layer of the internet of things, resources in the internet of things are opened through REST/HTTP frequently, and service is called by other applications. The method and the device are used for realizing loose coupling of interaction between the client and the server, and interaction delay between the client and the server is reduced.
2)REST
REST (REpresentational State Transfer), i.e., REST protocol, does not require a session, so each request must carry credentials. REST is based on the http protocol and is also stateless. Because the method is only an architectural mode, the security characteristic of the method needs to be realized by the user, and the method is not ready for use. It is proposed to send all requests via the https protocol. The core of the REST style web service concept is "resources". Resources may be represented by URIs. The client sends requests to these URIs using methods defined in the HTTP protocol. Of course, the state of these accessed "resources" may change.
3)dds
dds (data distribution Service) is a new generation of distributed real-time communication middleware protocol, with high real-time performance, high reliability, open architecture and non-coupling performance of publish/subscribe end, which greatly accelerates and simplifies the development of distributed system, making it very suitable for communication interaction in the field of internet of things. In the dds-based distributed system, a node joining dds network issues a Topic and a QoS (Quality of Service) which the node wants to issue (or want to subscribe), the node existing on dds network receives and listens the request and compares the request with the issue and subscription condition and the QoS standard of the node, if the Topic information of the newly joining node is related to the node and the QoS standard also meets the requirement, the node actively communicates with the newly joining node, sends the Topic information of the node to the newly joining node, and simultaneously registers the corresponding information of the newly joining node on the node so as to establish point-to-point connection when communication needs exist.
FIG. 1 is a block diagram of a computer system, according to an example embodiment. The system includes at least computer device 110 and computer device 120.
Optionally, the computer device 110 may be any one of a terminal device and a server; similarly, the computer device 120 may be any one of a terminal device and a server.
Optionally, the computer device 110 runs an application program, and the application program may call a communication component (such as a network card) of the computer device to implement communication with other computer devices (such as the computer device 120).
Optionally, the application may invoke a different protocol to communicate with computer device 120, for example, the application may invoke dds protocol to communicate with computer device 120, or the application may invoke REST protocol to communicate with computer device 120.
Optionally, at least two applications (such as a first application and a second application) invoking different communication protocols may run in the computer device 110, and the computer device may invoke the dds protocol to communicate with the computer device 120 through the first application; the computer device may also invoke the REST protocol to communicate with other computer devices through a second application.
At this time, if the computer device cannot directly forward data from other computer devices to the computer device 120, because the REST protocol is used, the transmitted protocol data is protocol data in a Json format, and when the dds protocol is used for data transmission, an issuing entity corresponding to a topic needs to be created, and data is written in the issuing entity, so as to implement data transmission.
Therefore, in the present application, the computer device 110 can be loaded with a protocol conversion device, and the protocol conversion device can implement simple data conversion between the dds protocol and the REST protocol.
Optionally, the terminal device may be a terminal device having a data processing function and a data storage function, where the terminal device may include one terminal or may include multiple terminals, and the number of the terminals is not limited in the embodiment of the present application. The terminal may be a terminal device having a data processor and a data storage component, such as a smart phone, a tablet computer, a notebook computer, a desktop computer, and the like, but is not limited thereto.
Optionally, the cloud server may be a cloud server providing basic operation and computing services such as cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a network service, cloud communication, middleware service, domain name service, security service, CDN, and a big data and artificial intelligence platform.
Optionally, the cloud server 110 and the terminal 120 may be connected through a communication network. Alternatively, the communication network may be a wired network or a wireless network.
Optionally, the wireless network or wired network described above uses standard communication techniques and/or protocols. The network is typically the internet, but may be any other network including, but not limited to, a local area network, a metropolitan area network, a wide area network, a mobile, a limited or wireless network, a private network, or any combination of virtual private networks. In some embodiments, data exchanged over the network is represented using techniques and/or formats including hypertext markup language, extensible markup language, and the like. All or some of the links may also be encrypted using conventional encryption techniques such as secure sockets layer, transport layer security, virtual private network, internet protocol security, and the like. In other embodiments, custom and/or dedicated data communication techniques may also be used in place of, or in addition to, the data communication techniques described above.
Fig. 2 is a flowchart illustrating a method for dds and REST protocol conversion method according to an example embodiment. The method is performed by a computer device, which may be the computer device 110 in a computer system as shown in fig. 1. As shown in fig. 2, the dds and REST protocol conversion method may include the following steps:
step 201, receiving first protocol data.
In the embodiment of the present application, the first protocol data may be data received by the computer device 110 and transmitted by other computer devices.
Optionally, when receiving the first protocol data, the computer device 110 may determine, according to a data format of the received first protocol data, a protocol type of a communication protocol adopted by the first protocol data; or when receiving the first protocol data, the computer device 110 may determine the protocol type of the communication protocol adopted by the first protocol data according to a receiving manner of receiving the first protocol data.
For example, when the first protocol data is data received by a data subscription entity created in advance in the computer device, the computer device may determine that the first protocol data is dds protocol data for communication transmission by adopting dds protocol.
Step 202, when it is detected that the first protocol data is the REST protocol data in the Json format, the first protocol data is converted through a mapping file to obtain second protocol data of the target subject.
The mapping file contains the mapping relation between the data of the REST protocol and the subject data of the dds protocol.
After the computer device receives the first protocol data and detects that the first protocol data is REST protocol data in a Json format, the protocol conversion can be performed through a mapping file preset in the computer device, and the first protocol data is converted into second protocol data (namely dds protocol data) of a target subject.
In this embodiment of the present application, the mapping file includes a mapping relationship between data of the REST protocol and theme data of the dds protocol, where the mapping relationship may be implemented by a mapping table, for example, the computer device may query each piece of data in the received first protocol data through the mapping table to query the second protocol data corresponding to the piece of data and the target theme corresponding to the second protocol data.
Optionally, in this embodiment of the application, a mapping relationship between the data of the REST protocol and the subject data of the dds protocol may be preset by a developer, and according to the mapping file, important information in the data included in the REST protocol may be screened out, so as to be converted into dds protocol data in a corresponding format, and the data is forwarded to other computer devices through the dds protocol.
Step 203, a publishing entity object of the target topic is created in the target domain.
After the computer device converts the first protocol data into the second protocol data of the target topic, in order to implement the transmission of the second protocol data of the target data, the computer device needs to control the computer device to create a publishing entity object (i.e. DataWriter) of the target topic in a target Domain (Domain) according to the dds protocol.
The publishing entity object of the target topic is an entity responsible for publishing messages, a user must provide a topic when creating the entity, the topic is a topic for publishing data, and the data of the corresponding topic can be transmitted to the user subscribing to the topic through the publishing entity object.
Step 204, writing the second protocol data of the target topic into the publishing entity object of the target topic according to the write QOS policy.
In the communication system based on dds protocol, before transmitting data (i.e. issuing message), it is also necessary to determine the QOS policy for issuing the message, and in other node devices, the data issued by the issuing entity object can be received only by adopting the matching QOS policy.
In one possible implementation of the embodiments of the present application, the write QOS policy may be predetermined, that is, the corresponding QOS policy is used by the computer device and other computer devices in dds communication with the computer device, the write QOS policy is used by the computer device, and the read QOS policy matching the write QOS policy is used by other computer devices in dds communication with the computer device.
In summary, when the computer device receives the first protocol data, the computer device first identifies the protocol type of the first protocol data, and when it is detected that the first protocol data is REST protocol data in Json format, the first protocol data is converted into second protocol data through the mapping file, and because the mapping relation between the data of the REST protocol and the subject data of the dds protocol is included in the mapping file, the second protocol data is dds protocol data of the target subject type, and at this time, the computer device creates a publishing entity object of the target subject in the target domain of the dds protocol, and writes the second protocol data of the target subject into the publishing entity object of the target subject through writing a QOS policy, and at this time, the subscribing entity object of the target subject can detect a change in data, thereby achieving communication through dds. In the scheme, when the REST protocol data in the Json format is received, the communication among different protocols can be realized through the converted data after the simple conversion is carried out through the mapping file.
Fig. 3 is a flowchart illustrating a method for dds and REST protocol conversion method according to an example embodiment. The method is performed by a computer device, which may be the computer device 110 in a computer system as shown in fig. 1. As shown in fig. 2, the dds and REST protocol conversion method may include the following steps:
step 301, acquiring initial REST protocol data and initial dds protocol data.
In this embodiment of the present application, before the REST protocol and dds protocol conversion are implemented, a mapping file for implementing the protocol conversion needs to be obtained first, and the mapping file is stored in a computer device, so that when data of the REST protocol is obtained, the mapping file can be directly used for protocol conversion.
In order to generate the mapping file, in this embodiment of the application, the computer device may first acquire initial REST protocol data and initial dds protocol data, where the initial REST protocol data and the initial dds protocol data are corresponding data, that is, the initial REST protocol data and the initial dds protocol data are corresponding data of different protocols that complete the same or similar functions.
For example, if the initial REST protocol data is data for "instructing the computer device to turn on a flash light", the initial dds protocol data should also be data for "instructing the computer device to turn on a flash light", that is, a developer needs to send standard REST protocol data corresponding to a certain application scenario and standard dds protocol data to the computer device in advance, and a mapping file generated by the computer device according to the standard REST protocol data and the standard dds protocol data makes sense to implement protocol conversion between the REST protocol data and dds protocol data in a certain application scenario.
Step 302, configuring key value pairs for the initial REST protocol data, and generating a first mapping table.
After the initial REST protocol data is acquired, the computer device may configure key-value pairs of the initial REST protocol data, use each piece of data in the initial REST protocol data as a value, and configure corresponding keys, thereby acquiring each key-value pair, where the key-value pair constitutes a first mapping table.
Optionally, the computer device may configure the RSET protocol data according to a preset REST protocol configuration rule, for example, the REST protocol configuration rule includes a correspondence between a keyword and a key, after the computer device acquires the initial REST protocol data, the computer device may segment the initial REST protocol data, perform keyword identification on the initial REST protocol data, and when a keyword is identified, take a paragraph corresponding to the keyword as a value, and take a key corresponding to the keyword as a key corresponding to the value.
Step 303, configuring a key value pair for the initial dds protocol data to obtain a second mapping table.
When key value pairs are configured for the initial dds protocol data, topic (namely a theme) of each data in the initial dds protocol data can be directly obtained, according to a corresponding relation between the theme and a key included in the dds protocol configuration rule, the initial dds protocol data is used as a value, and the corresponding relation among the value, the theme and the key is determined, so that a second mapping table is generated.
Step 304, based on the first mapping table and the second mapping table, generating a mapping relationship between the initial REST protocol data and the initial dds protocol data, and storing the mapping relationship in the mapping file.
After the first mapping table and the second mapping table are obtained, because the first mapping table includes the correspondence between the key and the value, the value in the first mapping table is a keyword in the REST protocol, and the value in the second mapping table is dds protocol data and the subject of the dds protocol data, the mapping relationship (i.e., the mapping table) between the dds protocol data and the REST protocol data can be established by the same key in the first mapping table and the second mapping table and stored in the mapping file.
Step 305, receiving first protocol data.
In a possible implementation manner, after receiving the first protocol data, caching the first protocol data into a message queue; polling the message queue according to a designated processing period, and taking out first protocol data in the message queue; performing deserialization on the first protocol data, then performing data analysis, and checking the integrity of the first protocol data; and when the first protocol data is complete protocol data, detecting the protocol format of the first protocol data.
After receiving the first protocol data, the computer device does not need to be a complete segment of protocol data, so the computer device will buffer the first protocol data into the message queue, fetch the data including the first protocol data in the message queue according to the specified processing period, and determine whether the fetched data contains complete data after deserialization. If the first protocol data is complete protocol data, then detecting the protocol format of the first protocol data.
In a possible implementation manner, when the first protocol is incomplete protocol data, storing the first protocol data in a temporary buffer area, and splicing the first protocol data with the data of the temporary buffer area; performing data analysis on the spliced first protocol data, and checking the integrity of the spliced first protocol data; and when the spliced first protocol data is complete protocol data, detecting the protocol format of the spliced first protocol data.
If the first protocol data is not complete protocol data, or the first protocol data and the jointly taken data do not form complete data, at least the first protocol data is stored in a temporary buffer area, at this time, the first protocol data can be spliced with the data previously stored in the temporary buffer area after the first protocol data until the spliced first protocol data is complete protocol data.
Step 306A, when it is detected that the first protocol data is REST protocol data in the Json format, converting the first protocol data through a mapping file to obtain second protocol data of the target subject.
In a possible implementation manner of the embodiment of the present application, when the computer device detects that the first protocol data is REST protocol data in a Json format, the computer device may perform segmentation processing on the first protocol data, perform keyword detection on each segmented protocol data, obtain a keyword of each protocol, and query, according to the keyword, second protocol data of a target topic through a mapping file.
Optionally, in the keyword detection process, the computer device performs deserialization on the segmented protocol data according to a preset keyword, performs keyword detection, and determines whether the keyword exists in each deserialized protocol segment.
Step 306B, when it is detected that the first protocol data is the DDS protocol data received by the data subscription entity, the first protocol data is sent to the corresponding application program.
That is, the first protocol data received by the computer device may not be REST protocol data, for example, the computer device may simultaneously run at least two applications, one of the applications calls the REST protocol to communicate with other computer devices, and the other application calls the dds protocol to communicate with other computer devices, where the computer device receives the first protocol data, that is, data of the REST protocol or data of the dds protocol.
When data of the REST protocol is received, the data can be converted through the protocol conversion process related to the embodiment of the application.
When data of dds protocol is received, it may be data received by the computer device through normal communication with other computer devices through dds protocol, so that the computer device can directly send the received data of dds protocol to a corresponding application program for processing.
Further, in another possible implementation manner of the embodiment of the application, a theme of the first protocol data is obtained, and the first protocol data is converted through the mapping file according to the theme of the first protocol data, so that third protocol data in a Json format is obtained; and sending the third protocol data in the Json format to a corresponding application program.
That is, in the computer device, neither the application program adopting dds protocol nor the application program adopting REST protocol performs actual functions, that is, the computer device is only used for converting dds protocol and REST protocol, therefore, when the computer device receives dds protocol, the computer device still needs to convert the first protocol data of dds protocol into the third protocol data of REST protocol, and the computer device sends the third protocol data of Json format to the corresponding application program, so that the application program calls the network communication unit to communicate with other computer devices through REST protocol.
The proposal takes the computer equipment as the conversion equipment of the REST protocol and the dds protocol, and realizes the bidirectional conversion between the REST protocol and the dds protocol.
Step 307, a publishing entity object for the target topic is created in the target domain.
In one possible implementation manner, in order to realize the normal operation of dds communication, the computer device may further create a subscription entity object of the target topic in the target domain according to the target topic.
Step 308, writing the second protocol data of the target topic into the publishing entity object of the target topic according to the write QOS policy.
In another possible implementation manner in the embodiment of the present application, the write QOS policy may be determined by the first protocol data.
For example, when the computer device acquires the first protocol data and determines that the first protocol data is protocol data in the Json format, the computer device may further perform mapping processing on the first protocol data through a QOS policy mapping table to obtain a write QOS policy corresponding to the first protocol data.
That is to say, when receiving the first protocol data, the computer device may perform screening of the write QOS policy according to the content in the first protocol data, thereby determining the write QOS policy adopted by writing the first protocol data, and at this time, if there are a plurality of other devices subscribing to the target topic of the computer device, the computer device may determine the object to be sent by the first protocol data according to the write QOS policy, so that the first protocol data may be accurately sent to the user to be sent.
For example, when the computer device a, the computer device B, and the computer device C form a dds communication system, the computer device B and the computer device C subscribe to the target topic at the same time, and the computer device a constructs the publishing entity object of the target topic according to the target topic mapped by the first protocol data. At this time, if the first protocol data only needs to be forwarded to the computer device B, it can be set that the computer device B and the computer device C use different QOS reading policies, and a mapping relationship between a certain keyword in the first protocol data and a target QOS writing policy is preset to the QOS policy mapping file, and the target QOS writing policy is matched with the QOS reading policy used by the computer device B.
After the first protocol data is mapped to the second protocol data of the target theme, the computer device A can also determine a write QOS strategy corresponding to the first protocol data according to the first protocol data, so that the data can be accurately issued to the computer device B.
In summary, when the computer device receives the first protocol data, the computer device first identifies the protocol type of the first protocol data, and when it is detected that the first protocol data is REST protocol data in Json format, the first protocol data is converted into second protocol data through the mapping file, and because the mapping relation between the data of the REST protocol and the subject data of the dds protocol is included in the mapping file, the second protocol data is dds protocol data of the target subject type, and at this time, the computer device creates a publishing entity object of the target subject in the target domain of the dds protocol, and writes the second protocol data of the target subject into the publishing entity object of the target subject through writing a QOS policy, and at this time, the subscribing entity object of the target subject can detect a change in data, thereby achieving communication through dds. In the scheme, when the REST protocol data in the Json format is received, the communication among different protocols can be realized through the converted data after the simple conversion is carried out through the mapping file.
Please refer to fig. 4, which illustrates a schematic structural diagram of a dds and REST protocol conversion apparatus according to an embodiment of the present application. The device comprises:
a protocol data receiving module 401, configured to receive first protocol data;
a protocol conversion module 402, configured to, when it is detected that the first protocol data is REST protocol data in a Json format, convert the first protocol data through a mapping file to obtain second protocol data of a target topic; the mapping file comprises a mapping relation between data of the REST protocol and subject data of the dds protocol;
a published object creation module 403 for creating a published entity object of the target topic in the target domain;
a data writing module 404, configured to write the second protocol data of the target topic into the publishing entity object of the target topic according to the write QOS policy.
In one possible implementation, the apparatus further includes:
and the protocol data sending module is used for sending the first protocol data to a corresponding application program when detecting that the first protocol data is dds protocol data received by the data subscription entity.
In a possible implementation manner, the protocol data sending module is further configured to obtain a theme of the first protocol data, and convert the first protocol data through the mapping file according to the theme of the first protocol data to obtain third protocol data in a Json format;
and sending the third protocol data in the Json format to a corresponding application program.
In one possible implementation, the apparatus further includes:
an initial data acquisition module, configured to acquire initial REST protocol data and initial dds protocol data;
the first mapping module is used for configuring key value pairs for the initial REST protocol data and generating a first mapping table;
the second mapping module is used for configuring key value pairs for the initial dds protocol data to obtain a second mapping table;
and the mapping file generating module is used for generating a mapping relation between the initial REST protocol data and the initial dds protocol data based on the first mapping table and the second mapping table, and storing the mapping relation into the mapping file.
In one possible implementation, the apparatus further includes:
and the subscription object creating module is used for creating a subscription entity object of the target topic in the target domain according to the target topic.
In one possible implementation, the apparatus further includes:
the data caching module is used for caching the first protocol data into a message queue after receiving the first protocol data;
the data polling module is used for polling the message queue according to a specified processing period and taking out first protocol data in the message queue;
the data checking module is used for performing data analysis after deserializing the first protocol data and checking the integrity of the first protocol data;
and the data detection module is used for detecting the protocol format of the first protocol data when the first protocol data is complete protocol data.
In a possible implementation manner, the data caching module is further configured to, when the first protocol is incomplete protocol data, store the first protocol data in a temporary buffer, and splice the first protocol data with data in the temporary buffer;
the data verification module is further used for performing data analysis on the spliced first protocol data and verifying the integrity of the spliced first protocol data;
the data detection module is further configured to detect a protocol format of the spliced first protocol data when the spliced first protocol data is complete protocol data.
In summary, when the computer device receives the first protocol data, the computer device first identifies the protocol type of the first protocol data, and when it is detected that the first protocol data is REST protocol data in Json format, the first protocol data is converted into second protocol data through the mapping file, and because the mapping relation between the data of the REST protocol and the subject data of the dds protocol is included in the mapping file, the second protocol data is dds protocol data of the target subject type, and at this time, the computer device creates a publishing entity object of the target subject in the target domain of the dds protocol, and writes the second protocol data of the target subject into the publishing entity object of the target subject through writing a QOS policy, and at this time, the subscribing entity object of the target subject can detect a change in data, thereby achieving communication through dds. In the scheme, when the REST protocol data in the Json format is received, the communication among different protocols can be realized through the converted data after the simple conversion is carried out through the mapping file.
Refer to fig. 5, which is a schematic diagram of a computer device according to an exemplary embodiment of the present application, the computer device including a memory and a processor, the memory storing a computer program, the computer program being executed by the processor to implement the method.
The processor may be a Central Processing Unit (CPU). The Processor may also be other general purpose processors, digital Signal Processors (DSPs), application Specific Integrated Circuits (ASICs), field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, or a combination thereof.
The memory, which is a non-transitory computer readable storage medium, may be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules corresponding to the methods of the embodiments of the present invention. The processor executes various functional applications and data processing of the processor by executing non-transitory software programs, instructions and modules stored in the memory, that is, the method in the above method embodiment is realized.
The memory may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created by the processor, and the like. Further, the memory may include high speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory optionally includes memory located remotely from the processor, and such remote memory may be coupled to the processor via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
In an exemplary embodiment, a computer readable storage medium is also provided for storing at least one computer program, which is loaded and executed by a processor to implement all or part of the steps of the above method. For example, the computer-readable storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a Compact Disc Read-Only Memory (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, and the like.
In an exemplary embodiment, a computer program product or a computer program is also provided, which comprises computer instructions, which are stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform all or part of the steps of the method described in any of the embodiments of fig. 2 or fig. 3.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (10)

1. A dds and REST protocol conversion method, comprising:
receiving first protocol data;
when the first protocol data is detected to be REST protocol data in a Json format, converting the first protocol data through a mapping file to obtain second protocol data of a target theme; the mapping file comprises a mapping relation between data of the REST protocol and subject data of the dds protocol;
creating a publishing entity object of a target topic in a target domain;
and writing the second protocol data of the target subject into the publishing entity object of the target subject according to the write QOS strategy.
2. The method of claim 1, further comprising:
and when the first protocol data is detected to be dds protocol data received by the data subscription entity, sending the first protocol data to a corresponding application program.
3. The method of claim 2, wherein sending the first protocol data to a corresponding application further comprises:
obtaining the theme of the first protocol data, and converting the first protocol data through the mapping file according to the theme of the first protocol data to obtain third protocol data in a Json format;
and sending the third protocol data in the Json format to a corresponding application program.
4. The protocol conversion method according to any one of claims 1 to 3, characterized in that the method further comprises:
acquiring initial REST protocol data and initial dds protocol data;
configuring key value pairs for the initial REST protocol data to generate a first mapping table;
configuring key value pairs for the initial dds protocol data to obtain a second mapping table;
and generating a mapping relation between the initial REST protocol data and the initial dds protocol data based on the first mapping table and the second mapping table, and storing the mapping relation into the mapping file.
5. The protocol conversion method of claim 1, further comprising:
and creating a subscription entity object of the target topic in the target domain according to the target topic.
6. The protocol conversion method according to claim 1, wherein before converting the first protocol data into the mapping file when it is detected that the first protocol data is the first REST protocol data in Json format, the method further comprises:
after receiving the first protocol data, caching the first protocol data into a message queue;
polling the message queue according to a designated processing period, and taking out first protocol data in the message queue;
performing deserialization on the first protocol data, then performing data analysis, and checking the integrity of the first protocol data;
and when the first protocol data is complete protocol data, detecting the protocol format of the first protocol data.
7. The method of claim 6, further comprising:
when the first protocol is incomplete protocol data, storing the first protocol data in a temporary buffer area, and splicing the first protocol data with the data in the temporary buffer area;
performing data analysis on the spliced first protocol data, and checking the integrity of the spliced first protocol data;
and when the spliced first protocol data is complete protocol data, detecting the protocol format of the spliced first protocol data.
8. A dds and REST protocol conversion apparatus, comprising:
the protocol data receiving module is used for receiving first protocol data;
the protocol conversion module is used for converting the first protocol data through a mapping file to obtain second protocol data of a target subject when the first protocol data is detected to be REST protocol data in a Json format; the mapping file comprises a mapping relation between data of the REST protocol and subject data of the dds protocol;
the release object creating module is used for creating a release entity object of the target theme in the target domain;
and the data writing module is used for writing the second protocol data of the target subject into the issuing entity object of the target subject according to the writing QOS strategy.
9. A computer device comprising a processor and a memory, the memory having stored therein at least one instruction, the at least one instruction being loaded and executed by the processor to implement the dds and REST protocol conversion method of any of claims 1-7.
10. A computer-readable storage medium having stored therein at least one instruction which is loaded and executed by a processor to implement the dds and REST protocol conversion method of any of claims 1-7.
CN202211426216.5A 2022-11-15 2022-11-15 Dds and REST protocol conversion method Pending CN115766374A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211426216.5A CN115766374A (en) 2022-11-15 2022-11-15 Dds and REST protocol conversion method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211426216.5A CN115766374A (en) 2022-11-15 2022-11-15 Dds and REST protocol conversion method

Publications (1)

Publication Number Publication Date
CN115766374A true CN115766374A (en) 2023-03-07

Family

ID=85371195

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211426216.5A Pending CN115766374A (en) 2022-11-15 2022-11-15 Dds and REST protocol conversion method

Country Status (1)

Country Link
CN (1) CN115766374A (en)

Similar Documents

Publication Publication Date Title
CN108306877B (en) NODE JS-based user identity information verification method and device and storage medium
WO2019000871A1 (en) Method and device for providing voice service, and server
CN108833950B (en) Barrage message issuing method, server, system and storage medium
CN111600909A (en) Data processing method, device, protocol conversion equipment and storage medium
US11909845B2 (en) Methods and systems for managing applications of a multi-access edge computing environment
US10623450B2 (en) Access to data on a remote device
US11689626B2 (en) Transport channel via web socket for ODATA
US20230297557A1 (en) Method for monitoring a state of an external data source, device, and medium
US9128886B2 (en) Computer implemented method, computer system, electronic interface, mobile computing device and computer readable medium
CN108989404B (en) Barrage message issuing method, server, system and storage medium
CN115766374A (en) Dds and REST protocol conversion method
CN114285859B (en) Data processing method, device, equipment and storage medium for middle layer block chain service
WO2021232860A1 (en) Communication method, apparatus and system
CN112929453B (en) Method and device for sharing session data
US20190014179A1 (en) Bluetooth low energy devices
CN113992641A (en) Data processing method, device, equipment and storage medium
CN115766373A (en) Dds and Zigbee protocol conversion method
US11609916B1 (en) Robotics application development and monitoring over distributed networks
CN113128200B (en) Method and device for processing information
US11663058B1 (en) Preemptive filtering of events of an event bus with a deterministic filter
US11736336B2 (en) Real-time monitoring of machine learning models in service orchestration plane
US20230088655A1 (en) Automatic non-code test suite generation from api specification
US20230376628A1 (en) Privacy Manager for Connected TV and Over-the-Top Applications
US20220353109A1 (en) Artificial intelligence integration of third-party software into large-scale digital platforms
US20140244764A1 (en) Methods, apparatus, and articles of manufacture to provide a protocol-enabled interface definition language

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