Information transmission method and device, equipment and storage medium
By converting information into length bytes and content bytes using custom encoding and decoding strategies, the problem of low transmission flexibility and efficiency caused by inconsistent message lengths is solved, enabling efficient joint transmission of structured and unstructured information and improving system performance.
Patent Information
- Application Number
- CN202310252744.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-07
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2043-03-07
AI Technical Summary
In existing technologies, message lengths are inconsistent and variable, resulting in low flexibility and efficiency in information transmission, especially when transmitting unstructured data, which presents limitations and restricts the number of connections.
A custom encoding strategy is used to convert the information to be processed into a stream of length bytes and content bytes. The encoded information is sent through a socket protocol channel and decoded on the server side using a corresponding decoding strategy. This supports flexible transmission of structured and unstructured information and optimizes the transmission process by combining preset fields and byte buffers.
It improves the flexibility and efficiency of information transmission, solves the problem of limited transmission length, supports the joint transmission of structured and unstructured information, and enhances the system's throughput and resource utilization.
Smart Images

Figure CN116320037B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the fields of computer technology or financial technology, and more particularly to an information transmission method, apparatus, device, storage medium, and program product. Background Technology
[0002] Information transmission involves sending commands or status information from one end to another via a channel, and receiving the information. Information transmission includes both sending and receiving. It is generally conducted in the form of messages, which contain the complete data to be sent. In realizing the inventive concept of this disclosure, the inventors discovered the following problems in related technologies: While message lengths are not fixed and can be variable, related technologies suffer from limitations in message length, thus reducing the flexibility and efficiency of information transmission. Summary of the Invention
[0003] In view of the above problems, this disclosure provides an information transmission method, apparatus, device, storage medium, and program product.
[0004] One aspect of this disclosure provides an information transmission method, comprising: responding to an information transmission instruction, converting information to be processed carried in the information transmission instruction into a length byte representing the length of the information to be processed and a content byte stream representing the content of the information to be processed, wherein the information to be processed includes structured information, unstructured information, and information combining structured and unstructured information; encoding the length byte and the content byte stream using a first custom encoding strategy to obtain encoded information, wherein the first custom encoding strategy is associated with the length byte of the information to be processed; and sending the encoded information to a server through a socket protocol channel so that the server can decode the encoded information using a first custom decoding strategy to obtain the information to be processed, wherein the first custom decoding strategy is associated with the first custom encoding strategy.
[0005] According to embodiments of this disclosure, the method further includes: assigning preset fields to the structured information, the unstructured information, and the information combining the structured and unstructured information; and sending the preset fields to the server through the socket protocol channel.
[0006] According to embodiments of this disclosure, the method further includes: extracting the preset fields through a preset script; analyzing the type of the message to be processed based on the preset fields to obtain analysis results; determining a decoding process based on the analysis results; and decoding the encoded information according to the decoding process and the first custom decoding strategy to obtain the message to be processed.
[0007] According to embodiments of this disclosure, the method further includes: decoding the encoded information using a first custom decoding strategy on the server side to obtain information to be processed; converting the information to be processed to obtain a string; obtaining a response message based on the string; processing the response message using a second custom encoding strategy to obtain an encoded response message, wherein the second custom encoding strategy is associated with the length bytes of the response message; and sending the encoded response message through the socket protocol channel.
[0008] According to an embodiment of this disclosure, the method further includes: decoding the encoded response message using a second custom decoding strategy to obtain a processing result related to the information to be processed, wherein the second custom decoding strategy is associated with the second custom encoding strategy.
[0009] According to an embodiment of this disclosure, the method further includes: monitoring the interaction of the socket protocol channel and obtaining monitoring results; maintaining the connection state of the socket protocol channel when the monitoring results indicate that an interaction has occurred in the socket protocol channel; and adjusting the connection state of the socket protocol channel to a closed state when the monitoring results indicate that no interaction has occurred in the socket protocol channel within a preset time.
[0010] According to embodiments of this disclosure, the method further includes: storing the length byte and the content byte stream in a byte buffer; and reading the length byte and the content byte stream from the byte buffer during the decoding of the encoded information using the first custom decoding strategy.
[0011] According to embodiments of this disclosure, the method further includes: transmitting the byte buffer in the socket protocol channel using a direct buffer; and reading and writing the byte buffer in the socket protocol channel using off-heap memory.
[0012] According to embodiments of this disclosure, the method further includes: generating a connection request when the encoded information is sent to the server via a socket protocol channel or when the encoded response message is sent via the socket protocol channel; and processing the connection request using a preset transmission framework.
[0013] According to embodiments of this disclosure, the aforementioned preset transmission framework includes a main reactor, a receiver, a sub-reactor, a dispatcher, and a thread pool; the aforementioned processing of the connection request using the preset transmission framework includes: after the main reactor responds to the connection request, it distributes the socket request established according to the connection request to the sub-reactor through the receiver; the sub-reactor distributes the socket request to the thread pool through the dispatcher, so that the thread pool can process the socket request.
[0014] Another aspect of this disclosure provides an information transmission apparatus, comprising: a first conversion module, configured to, in response to an information transmission instruction, convert information to be processed carried in the information transmission instruction into a length byte representing the length of the information to be processed and a content byte stream representing the content of the information to be processed, wherein the information to be processed includes structured information, unstructured information, and information combining structured and unstructured information; a first encoding module, configured to encode the length byte and the content byte stream using a first custom encoding strategy to obtain encoded information, wherein the first custom encoding strategy is associated with the length byte of the information to be processed; and a first sending module, configured to send the encoded information to a server through a socket protocol channel, so that the server can decode the encoded information using a first custom decoding strategy to obtain the information to be processed, wherein the first custom decoding strategy is associated with the first custom encoding strategy.
[0015] Another aspect of this disclosure provides an electronic device, including: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors perform the information transmission method described above.
[0016] Another aspect of this disclosure provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, cause the processor to perform the information transmission method described above.
[0017] Another aspect of this disclosure provides a computer program product, including a computer program that, when executed by a processor, implements the aforementioned information transmission method.
[0018] According to the information transmission method, apparatus, device, storage medium, and program product provided in this disclosure, in response to an information transmission instruction, information to be processed is converted into a stream of length bytes and content bytes. The information to be processed may include structured information, unstructured information, or a combination of structured and unstructured information. Encoding is performed using a first custom encoding strategy related to the length bytes to obtain encoded information. The encoded information is then sent to a server via a socket protocol channel, so that the server performs decoding according to a first custom decoding strategy associated with the first custom encoding strategy. Because a custom encoding strategy related to the length bytes of the information to be processed is used during information transmission, the transmission length can be automatically adjusted according to the length bytes, at least partially solving the problem of limited transmission length in related technologies. Furthermore, the embodiments of this application can also support the transmission of structured information, unstructured information, and a combination of structured and unstructured information, thereby achieving the technical effect of improving the flexibility and efficiency of information transmission. Attached Figure Description
[0019] The foregoing contents, as well as other objects, features, and advantages of this disclosure, will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0020] Figure 1 This diagram illustrates an application scenario of the information transmission method and apparatus according to embodiments of the present disclosure.
[0021] Figure 2 A flowchart illustrating an information transmission method according to an embodiment of the present disclosure is shown schematically.
[0022] Figure 3 A flowchart illustrating the processing of connection requests using a preset framework according to an embodiment of the present disclosure is shown schematically.
[0023] Figure 4 An information transmission method according to another embodiment of the present disclosure is illustrated schematically;
[0024] Figure 5 This illustration schematically depicts information transmission between a client and a server according to an embodiment of the present disclosure.
[0025] Figure 6 This illustration schematically depicts an embodiment according to the present disclosure. Figure 5 A schematic diagram of the transmission path for the client.
[0026] Figure 7 A schematic diagram of a transmission system according to an embodiment of the present disclosure is shown.
[0027] Figure 8 A schematic block diagram of an information transmission apparatus according to an embodiment of the present disclosure is shown; and
[0028] Figure 9 A block diagram schematically illustrates an electronic device suitable for implementing an information transmission method according to an embodiment of the present disclosure. Detailed Implementation
[0029] The embodiments of the present disclosure will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of the present disclosure.
[0030] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0031] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0032] When using expressions such as "at least one of A, B, and C", they should generally be interpreted in accordance with the meaning that is commonly understood by a person skilled in the art (e.g., "a system having at least one of A, B, and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B, and C, etc.).
[0033] Currently, transaction message volume is large and the message length is not fixed. For example, ESB (Enterprise Service Bus) messages are generally constructed according to certain technical specifications (message length + XML (Extensible Markup Language) message format). When transmitting such messages, the WebSocket protocol built into Tomcat is typically used. This transmission method depends on Tomcat's connection concurrency, and Tomcat's performance is low when the connection limit is low. For example, Tomcat's processing performance is optimal when the number of connections it can handle is 200-300. If the request volume exceeds 300, connection errors or other abnormal situations may occur. Therefore, when Tomcat's connection limit is limited, Tomcat may limit the number of requests or increase the connection limit at the expense of performance to ensure normal system operation, but this will reduce the system's processing performance. Furthermore, the messages transmitted in related technologies are generally XML-formatted text data and do not support the transmission of unstructured data such as images and files, thus limiting the current information transmission capabilities.
[0034] Furthermore, in the WebSocket protocol, messages are generally read using the `read(char cbuf[], int off, int len)` method. This method starts from the `off`th byte of the received content and reads at most `len` bytes, storing them in an array `cbuf`. It's important to note that this is appended to the array. If the available length is greater than or equal to `len`, `len` bytes are read directly; otherwise, the entire available length is read. The WebSocket protocol is susceptible to incomplete packet splitting and packet merging. Packet splitting refers to the process where, if one end sends a data packet exceeding the maximum length of a single message, it is split into multiple messages of the maximum length for separate transmission. Packet merging refers to the process where, if one end sends multiple data packets consecutively, the protocol will package them into a single message for transmission.
[0035] In view of this, embodiments of the present disclosure provide an information transmission method, apparatus, device, storage medium, and program product that can effectively solve the problem of insufficient requested resource connections and enable unstructured information transmission, thereby improving the flexibility and efficiency of information transmission. Specifically, the method includes: responding to an information transmission instruction, converting the information to be processed carried in the information transmission instruction into a length byte representing the length of the information to be processed and a content byte stream representing the content of the information to be processed, wherein the information to be processed includes structured information, unstructured information, and information combining structured and unstructured information; encoding the length byte and content byte stream using a first custom encoding strategy to obtain encoded information, wherein the first custom encoding strategy is associated with the length byte of the information to be processed; and sending the encoded information to a server through a socket protocol channel so that the server can decode the encoded information using a first custom decoding strategy to obtain the information to be processed, wherein the first custom decoding strategy is associated with the first custom encoding strategy.
[0036] It should be noted that the information transmission method and apparatus determined in the embodiments of this disclosure can be used in the field of computer technology or financial technology, or in any field other than the field of computer technology or financial technology. The embodiments of this disclosure do not limit the application field of the determined information transmission method and apparatus.
[0037] In the technical solutions disclosed herein, the collection, storage, use, processing, transmission, provision, disclosure, and application of data (including but not limited to user personal information) comply with the provisions of relevant laws and regulations, necessary confidentiality measures have been taken, and they do not violate public order and good morals.
[0038] Figure 1 The illustration shows an application scenario of the information transmission method and apparatus according to embodiments of the present disclosure.
[0039] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, a server 105, a socket protocol channel 106, and a server 107.
[0040] The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be various electronic devices with displays that are in public environments or various independent environments, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0041] Users can interact with server 105 via network 104 using at least one of the first terminal device 101, second terminal device 102, and third terminal device 103 to receive or send information transmission instructions, etc. Various communication client applications can be installed on the first terminal device 101, second terminal device 102, and third terminal device 103, such as financial applications, shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).
[0042] Network 104 serves as a medium for providing a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. Network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.
[0043] Socket protocol channel 106 is used to provide a communication link between server 105 and server 107.
[0044] Server 107 decodes the received encoded information and sends the decoded information to be processed to the corresponding processing channel or server, so that the corresponding processing channel or server can generate a response message based on the information to be processed and complete the processing of the transaction message. Server 107 can also send the response message back to the terminal device through server 105.
[0045] Server 105 can be a server providing various services, such as a backend management server supporting information transmission instructions sent by users using first terminal device 101, second terminal device 102, and third terminal device 103 (this is just an example). For instance, in response to an information transmission instruction, server 105 can convert the information to be processed carried in the information transmission instruction into a length byte representing the length of the information to be processed and a content byte stream representing the content of the information to be processed. The information to be processed includes structured information, unstructured information, and a combination of structured and unstructured information. It can then encode the length byte and content byte stream using a first custom encoding strategy to obtain encoded information, where the first custom encoding strategy is associated with the length byte of the information to be processed. Finally, it can send the encoded information to the server via socket protocol channel 106 so that the server 107 can decode the encoded information using a first custom decoding strategy to obtain the information to be processed. The backend management server can not only analyze and process received information transmission instructions and other data, but also feed back the processing results (such as response messages generated according to the information transmission instructions, obtained or generated web pages, information, or data) to the terminal devices.
[0046] It should be noted that the information transmission method provided in this embodiment can generally be executed by server 105. Correspondingly, the information transmission device provided in this embodiment can generally be located in server 105. The information transmission method provided in this embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105. Correspondingly, the information transmission device provided in this embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105.
[0047] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, there can be any number of terminal devices, networks, servers, socket protocol channels, and servers.
[0048] The following will be based on Figure 1 The described application scenarios, through Figures 2-7 The information transmission method of the disclosed embodiments will be described in detail.
[0049] Figure 2 A flowchart illustrating an information transmission method according to an embodiment of the present disclosure is shown schematically.
[0050] like Figure 2 As shown, the information transmission method of this embodiment includes operations S201 to S203.
[0051] In operation S201, in response to the information transmission instruction, the information to be processed carried in the information transmission instruction is converted into a length byte stream representing the length of the information to be processed and a content byte stream representing the content of the information to be processed. The information to be processed includes structured information, unstructured information, and information combining structured and unstructured information.
[0052] In operation S202, the length byte and content byte stream are encoded using a first custom encoding strategy to obtain encoded information, wherein the first custom encoding strategy is associated with the length byte of the information to be processed.
[0053] In operation S203, encoded information is sent to the server through the socket protocol channel so that the server can use the first custom decoding strategy to decode the encoded information and obtain the information to be processed. The first custom decoding strategy is associated with the first custom encoding strategy.
[0054] According to embodiments of this disclosure, the information transmission instruction is initiated by the information transmitter. The information transmitter refers to the source of the information transmission. The information transmission instruction is a request initiated by the information transmitter to transmit information. For example, the information transmitter may need to use information transmission in a transaction scenario or during business processing. The information to be processed refers to the information that needs to be transmitted in the information transmission instruction.
[0055] According to embodiments of this disclosure, the information to be processed may include structured information, unstructured information, and information combining structured and unstructured information. Structured information generally refers to information whose nature and value are fixed in their location, such as data in XML format. Unstructured information covers a wide range of information, such as images and documents; specifically, it can refer to contracts, vouchers, letters, purchase records, document processing, spreadsheets, presentation files, emails, audio, images, and video. Information combining structured and unstructured information can refer to information containing both structured and unstructured information, such as information containing both text and images.
[0056] According to embodiments of this disclosure, the length byte and the content byte stream can respectively represent the length of the information to be processed and the content of the information to be processed. For example, if the information to be processed is "request to process the first transaction", then the length byte can be related to the number of words in the information to be processed, and the content byte stream can be related to the specific content of the information to be processed.
[0057] According to embodiments of this disclosure, the first custom encoding strategy can be automatically adjusted based on the length bytes. During encoding, the information to be processed (length bytes and content byte stream) can be defined as an object type, with the object attribute being a byte array. During information transmission, the first custom encoding strategy can automatically adjust the transmission length based on the length bytes, increasing the scalability of the transmission process.
[0058] According to embodiments of this disclosure, a socket protocol channel is an abstraction of endpoints for bidirectional communication between application processes on different hosts in a network. A socket can be one end of inter-process communication on the network, providing a mechanism for application-layer processes to exchange data using network protocols. A socket can connect to an application process upstream and a network protocol stack downstream; it is the interface through which applications communicate via network protocols and also the interface through which applications interact with the network protocol stack. In embodiments of this disclosure, a socket protocol channel can be used to establish a connection between a server and a client / terminal device, or between a client / terminal device and a server.
[0059] According to embodiments of this disclosure, decoding is the reverse process of encoding. Therefore, the first custom decoding strategy can be related to the first custom encoding strategy in order to be used to perform the reverse process on the encoded information and obtain the information to be processed.
[0060] According to the information transmission method, apparatus, device, storage medium, and program product provided in this disclosure, in response to an information transmission instruction, information to be processed is converted into a stream of length bytes and content bytes. The information to be processed may include structured information, unstructured information, or a combination of structured and unstructured information. Encoding is performed using a first custom encoding strategy related to the length bytes to obtain encoded information. The encoded information is then sent to a server via a socket protocol channel, so that the server performs decoding according to a first custom decoding strategy associated with the first custom encoding strategy. Because a custom encoding strategy related to the length bytes of the information to be processed is used during information transmission, the transmission length can be automatically adjusted according to the length bytes, at least partially solving the problem of limited transmission length in related technologies. Furthermore, the embodiments of this application can also support the transmission of structured information, unstructured information, and a combination of structured and unstructured information, thereby achieving the technical effect of improving the flexibility and efficiency of information transmission.
[0061] According to embodiments of this disclosure, before decoding the encoded information using the first decoding strategy, the following operations may be performed: assigning preset fields to structured information, unstructured information, and information combining structured and unstructured information respectively; and sending the preset fields to the server through a socket protocol channel.
[0062] According to embodiments of this disclosure, decoding encoded information using a first decoding strategy may include the following operations: extracting preset fields through a preset script; analyzing the type of the message to be processed based on the preset fields to obtain analysis results; determining a decoding process based on the analysis results; and decoding the encoded information according to the decoding process and the first custom decoding strategy to obtain the information to be processed.
[0063] According to embodiments of this disclosure, the preset field can be composed of numbers and characters. For example, a "01" field can be assigned to structured information, a "10" field to unstructured information, and a "11" field to information combining structured and unstructured information. The preset field can be sent along with the encoded information.
[0064] According to embodiments of this disclosure, the preset script can be used to obtain preset fields, such as MessageFactory.process(), etc. Based on the extracted preset fields, the type of information to be processed can be determined.
[0065] According to embodiments of this disclosure, the analysis result can be the type of information to be processed, which has been determined based on preset fields. Each type can correspond to a decoding processing flow. For example, structured information is configured with a structured decoding processing flow; unstructured information is configured with an unstructured decoding processing flow; and information combining structured and unstructured information is configured with a customized decoding processing flow. After determining the decoding processing flow based on the analysis result, the encoded information can be decoded using a first custom decoding strategy in the decoding processing flow to obtain the information to be processed.
[0066] According to embodiments of this disclosure, the length byte and content byte stream can also be stored in a byte buffer; during the decoding of the encoded information using a first custom decoding strategy, the length byte and content byte stream can be read from the byte buffer.
[0067] According to embodiments of this disclosure, when decoding encoded information, the length of the entire ESB message can be determined by using the first preset number of bytes (exemplarily, the first 8 bytes) as the length of the entire ESB message, based on an agreed transmission protocol format. The first 8 bytes of the byte buffer are read, padded with 0s if necessary, and converted into the length of the message body to be read. Then, the entire byte stream information is read at once to obtain the message content. Optionally, after obtaining the byte stream information and converting it into the corresponding entity class, the accuracy of the data can be verified. If the data is accurate, preset fields can be extracted according to a preset script, and subsequent operations can be performed.
[0068] According to embodiments of this disclosure, an ESB can be understood as a pipeline used to connect various nodes. To integrate services from different systems and protocols, the ESB can perform message conversion, interpretation, and routing to enable interoperability between different services. An ESB is a standard integration method for loosely coupled services and applications. It can be applied to: service-oriented architectures—distributed applications, where the ESB consists of generic services; message-oriented architectures—applications send and receive messages through the ESB; event-driven architectures—applications asynchronously generate and receive messages; and the ESB can also serve as a medium for intelligent integration and association between services in a Service Oriented Architecture (SOA) framework.
[0069] According to embodiments of this disclosure, when transmitting a byte buffer, a direct buffer can be used to transmit the byte buffer in the socket protocol channel; and the byte buffer can be read and written in the socket protocol channel using off-heap memory.
[0070] According to embodiments of this disclosure, by using a direct buffer to receive and send byte buffers and using an off-heap memory socket protocol channel for reading and writing, it is possible to avoid secondary copying of the byte buffer, thus saving memory usage space.
[0071] According to embodiments of this disclosure, the interaction status of the socket protocol channel can be monitored in real time during information transmission to obtain monitoring results; if the monitoring results indicate that an interaction has occurred on the socket protocol channel, the connection status of the socket protocol channel is maintained; if the monitoring results indicate that no interaction has occurred on the socket protocol channel within a preset time, the connection status of the socket protocol channel is adjusted to a closed state.
[0072] According to embodiments of this disclosure, the interaction status can be determined based on the read / write status within the socket protocol channel. For example, during the process of establishing a connection and conducting a transaction using a socket, the channel can be checked for read / write idleness. If there is a change in the read / write status, it can be assumed that there is interaction occurring within the channel, and the channel is in a non-idle state. Therefore, the connection status of the channel can be maintained. During the process of establishing a connection and conducting a transaction using a socket, if no interaction occurs within a certain time period, the transaction within the channel can be considered complete. Therefore, the channel can be closed, and its resources released. The preset time can be adaptively adjusted according to actual needs.
[0073] According to embodiments of this disclosure, when a network device malfunctions or becomes unstable, non-working connections will continuously occupy resources and cannot be automatically released. When data transmission feedback times out, read idle, write idle, and read-write idle events can be periodically detected. If the server does not execute a read request for a certain period, a read idle event is triggered; if no write request is executed for a certain period, a write idle event is triggered; and if neither a read nor a write request is executed for a certain period, a read-write idle event is triggered. When at least one of these idle events occurs during an online transaction, the channel is closed and connection resources are released, preventing resource waste.
[0074] According to embodiments of this disclosure, by monitoring the interaction within the socket protocol channel, if no interaction occurs within a certain period of time, the channel resources can be automatically released, saving memory usage space and improving resource utilization.
[0075] According to embodiments of this disclosure, after decoding the encoded information using a first custom decoding strategy on the server side to obtain the information to be processed, the following operations may be included: converting the information to be processed to obtain a string; obtaining a response message based on the string; processing the response message using a second custom encoding strategy to obtain an encoded response message, wherein the second custom encoding strategy is associated with the length bytes of the response message; and sending the encoded response message through a socket protocol channel.
[0076] According to embodiments of this disclosure, after receiving an encoded response message, the encoded response message can be decoded using a second custom decoding strategy to obtain a processing result related to the information to be processed, wherein the second custom decoding strategy is associated with a second custom encoding strategy.
[0077] According to embodiments of this disclosure, after the server decodes the encoded information to obtain the information to be processed, the server can send the information to be processed to a processing channel or processing server capable of processing the information, so that the processing channel or processing server can process the information and generate a response message. Specifically, the server can decode the encoded information and convert the decoded information into a string for subsequent processing. For unstructured data byte streams, it can be converted into images and then archived. After the processing channel or processing server processes the received information, the server can obtain the corresponding response message.
[0078] According to embodiments of this disclosure, the second custom encoding strategy can be automatically adjusted based on the length bytes of the response message. During encoding, the response message (length bytes and content byte stream) can be defined as an object type, with the object attribute being a byte array. During information transmission, the second custom encoding strategy can automatically adjust the transmission length based on the length bytes, increasing the scalability of the transmission process. The encoded response message can be fed back to the client / terminal device that initiated the information transmission command through the socket protocol channel.
[0079] According to embodiments of this disclosure, after receiving the encoded response message, the client / terminal device can use a second custom decoding strategy to decode the encoded response message and obtain a processing result associated with the information to be processed. It is understood that the second custom decoding strategy needs to correspond to the second custom encoding strategy in order to decode the encoded response message and obtain a processing result associated with the information to be processed.
[0080] According to embodiments of this disclosure, a connection request is generated when coded information is sent to the server via a socket protocol channel or when an coded response message is sent via a socket protocol channel; and the connection request is processed using a preset transport framework.
[0081] According to embodiments of this disclosure, a preset transport framework may include a main reactor, a receiver, a sub-reactor, a dispatcher, and a thread pool. Using the preset transport framework, processing connection requests may include the following operations: after the main reactor responds to a connection request, it distributes the socket request established based on the connection request to the sub-reactor via the receiver; the sub-reactor then distributes the socket request to the thread pool via the dispatcher, so that the thread pool can process the socket request.
[0082] According to embodiments of this disclosure, when a client / terminal device sends encoded information to a server, or when a server sends a response message to a client / terminal device, a connection request for connecting the client / terminal device and the server, or a connection request for connecting the server and the server, can be generated.
[0083] According to embodiments of this disclosure, the preset transmission frame can be an asynchronous communication framework that is a secondary encapsulation of the NIO framework (non-blocking IO, synchronous non-blocking IO framework). This asynchronous communication framework has better robustness than the native NIO framework and supports excellent performance in TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) network communication. It also supports various binary and text-based traditional protocols, such as the Netty framework. The preset framework can also be adaptively adjusted according to actual needs.
[0084] Figure 3 A flowchart illustrating the use of a preset framework to process connection requests according to an embodiment of the present disclosure is shown.
[0085] like Figure 3 As shown, the preset framework 300 may include a client 301, a main reactor 302, a receiver 303, a sub-reactor 304, a distributor 305, a thread pool 306, and a sending module 307.
[0086] According to embodiments of this disclosure, the main reactor 302 can monitor connection requests in real time. After responding to a connection request from the client 301 to the server, it can receive the connection request. The main reactor 302 will dispatch the socket request constructed according to the connection request to the sub-reactor 304 through the receiver 303. The sub-reactor 304 will then distribute the socket request to the thread pool through the dispatcher 305 so that the thread pool can process it.
[0087] According to embodiments of this disclosure, thread pool 306 may include a work unit 3061 and a queuing task unit 3062. The work unit 3061 can process socket requests, and the queuing task unit 3062 can be used to receive and store multiple tasks related to processing socket requests, so as to provide the next task for processing a connection when the current request has been completed by the work unit 3061.
[0088] According to embodiments of this disclosure, the sending module 307 can be used to send the processing result obtained from the connection processing to the client 301.
[0089] In the information transmission method provided in the embodiments of this disclosure, the general process of information transmission may be as follows: establish a connection using a preset framework; convert the message into a byte stream and send it to the channel; receive the byte stream information and parse the transaction code according to the byte stream information; forward the parsed transaction code to different processing channels or processing servers for processing and response; finally complete the processing of the entire transaction message and disconnect the connection.
[0090] According to embodiments of this disclosure, a thread pool is introduced into a preset framework. Within this framework, the main reactor monitors and receives connection requests. The connection request first reaches the main reactor, which then dispatches the established Socket to the slave reactors via a receiver. The request is then distributed via a dispatcher, and the slave reactors separate the Socket request and place it into a thread pool for processing. Because Tomcat is no longer used in connection processing, the connection request processing method provided in this application allows for flexible adjustment of the number of connections, independent of Tomcat limitations, thus improving system throughput. Stress testing shows that the connection request processing method based on the preset framework used in this disclosure improves performance compared to the original Tomcat-based method, increasing the number of connections from 200-300 to over 1000 and maintaining stability.
[0091] According to the embodiments of this disclosure, in addition to the above-described preset framework and custom encoding / decoding method for information transmission, other methods can also be used to transmit information, such as sending structured information and unstructured information separately in two separate transmissions, to achieve information transmission.
[0092] Figure 4 An information transmission method according to another embodiment of the present disclosure is illustrated schematically.
[0093] like Figure 4 As shown, the information transmission method of another embodiment may include operations S401 to S404.
[0094] When operating S401, the client requests both structured and unstructured data.
[0095] When operating S402, a custom encoder performs outbound encoding, which is then transmitted via socket to the server for inbound decoding.
[0096] When operating S403, the idle timeout processor listens to the channel status, including read idle, write idle, and read-write idle.
[0097] When operating S404, the decoded byte stream information from the inbound station is processed for business operations and a response message is returned.
[0098] According to the embodiments of this disclosure, the contents of S401 to S404 can be referred to the relevant contents of operations S201 to S203.
[0099] Figure 5 This illustration schematically depicts information transmission between a client and a server according to an embodiment of the present disclosure. Figure 6 This illustration schematically depicts an embodiment according to the present disclosure. Figure 5 A diagram illustrating the transmission path for the client.
[0100] like Figure 5 As shown, the information transmission mechanism of this embodiment can be used in devices such as client 501, socket protocol channel 502, and server 503. Figure 6 In this context, the client's transmission path 600 includes a first processing interface 601 (e.g., ChannelOutboundHandler) and a second processing interface 602 (ChannelInboundHandler). Taking client 501 as an example, if the event's direction of travel is from the client to the server, the event is called outbound; that is, data sent from the client to the server will pass through a series of first processing interfaces 601 in the transmission path 600 and be processed by the processors associated with these first processing interfaces 601. Conversely, if the event's direction of travel is from the server to the client, the event is called inbound.
[0101] Figure 7 A schematic diagram of a transmission system according to an embodiment of the present disclosure is shown.
[0102] like Figure 7 As shown, the transmission system 700 of this embodiment may include a message transmission entity module 710, a custom encoder module 720, a custom decoder module 730, a client handler module 740, a server handler module 750, and an idle timeout processor module 760. The transmission system 700 can be used to implement the methods described in operations S201 to S203 or operations S401 to S404.
[0103] The message transmission entity module 710 can identify commonalities based on the principle of supporting both structured and unstructured data transmission, and transmit data as a byte stream, such as transmitting length bytes and content byte streams. The attribute information of the entity class is defined as a byte array. Within the message transmission entity module, transmission strategies can be configured for network applications. These strategies are determined by how to parse the raw bytes transmitted between the client and server nodes, and how to convert the data formats of the network application and the target application. Based on the user's transmitted message format, structured and unstructured data are converted into a format suitable for transmission, such as using a byte stream as the transmission entity, and storing the byte stream information as a byte array in a custom Java class.
[0104] Data format conversion between network applications can be achieved by transforming byte streams from one format to another. Encoders handle outbound data, while decoders process inbound data. Netty's default message transmission can only handle 1024 bytes; any exceeding this length will be truncated. In practical applications, since the byte stream of each transmission request is not fixed, this application provides a custom, scalable encoding / decoding strategy when handling connection requests using the Netty framework. This can be understood as providing a variable frame size protocol to avoid information truncation issues caused by using the Netty framework. In this embodiment, the TooLongFrameException class is also used to set a maximum byte count threshold in the decoding strategy and to handle exceptions thrown when frames exceed the specified size limit.
[0105] The custom encoder module 720 can employ an abstract encoder, which defines the encoder's skeleton methods. The specific encoding logic can be implemented by subclasses of the abstract encoder. During encoding, messages can be defined as object types, with byte arrays as object attributes, increasing scalability during message transmission between transaction data. Since the size of each request is not fixed, two write operations can be used, for example, writing the length bytes and the content byte stream separately.
[0106] The custom encoder module implements ChannelOutboundHandler, which converts outbound data from one format to another. It uses Message To Byte Encoder to perform the reverse processing of POJO objects. Based on the custom transmission protocol format, it first calculates the encoded length of the entire message, converts the number into 8-bit bytes, and pads it with 0s if necessary. Then, it converts the entire message into bytes and writes the length information bytes and message bytes.
[0107] The custom decoder module 730, according to the agreed transmission protocol format, takes the first 8 bytes as the length of the entire ESB message, reads the first 8 bytes of the byte buffer, converts them into the length of the message body to be read, and then reads the entire byte stream information at once.
[0108] The custom decoder module inherits from the abstract base class Byte To Message Decoder and implements ChannelInboundHandler, as well as the process of converting incoming bytes into application POJO objects. This abstract base class buffers the incoming data until it is ready for processing. The decoding process can be based on a custom transmission protocol format, specifying the number of bytes required for data transmission and the byte processing method. The first eight bits are used as the representative byte length. The bytes are converted into numbers, space is allocated in the byte buffer, and then the encoding is converted into a message.
[0109] The client operation module 740 treats the encoder and decoder as separate entities, managing the transformation of inbound and outbound data in the same class. Each client will be bound to an encoder / decoder pair and implement the SimpleChannelInboundHandler and SimpleChannelOutboundHandler interfaces.
[0110] The server-side operation module 750 extracts the first 8 bits of the byte stream according to the agreed transmission protocol format, obtains the byte stream information, and converts it into the corresponding entity class. After verifying the accuracy of the data, the MessageFactory.process() script extracts preset fields. For example, 01 represents structured data messages, which undergo structured decoding processing; 10 represents unstructured data, which undergoes unstructured information processing; and 11 represents data that contains both structured and unstructured information, which undergoes customized information processing. After decoding the entire message, the decoded information is converted into a string for processing. For file tags containing unstructured data byte streams, they can be converted into images for archiving and a request / response message is returned.
[0111] The idle timeout processor module 760 performs read / write idle checks during the connection establishment and transaction process. If the current state is not idle, the connection status of the channel is maintained. If no transaction information occurs for a certain period of time, the transaction in the channel is considered to have ended, and the channel can be closed to release resources.
[0112] According to embodiments of this disclosure, when a network device malfunctions or becomes unstable, non-working connections will continuously occupy resources and cannot be automatically released. When data transmission feedback times out, read idle, write idle, and read-write idle events can be periodically detected. If the server does not execute a read request for a certain period, a read idle event is triggered; if no write request is executed for a certain period, a write idle event is triggered; and if neither a read nor a write request is executed for a certain period, a read-write idle event is triggered. When at least one of these idle events occurs during an online transaction, the channel is closed and connection resources are released, preventing resource waste.
[0113] According to embodiments of this disclosure, a custom information processing model can be constructed by combining a custom message transmission entity module, a custom encoder module, a custom decoder module, a client operation module, a server operation module, and an idle timeout processor module. This custom information processing model can optimize the limitations of connection resources during socket establishment. Furthermore, this custom information processing model can support the transmission of both structured and unstructured information.
[0114] The information transmission method provided in this disclosure can customize encoding and decoding processing according to actual application scenarios, solves the limitation that the maximum transmission length is 1024 bytes, and optimizes the packet splitting and packet merging problems caused by fixed-length byte array transmission.
[0115] The information transmission method provided in this disclosure uses direct buffers during the receiving and sending of byte buffers, and uses off-heap memory for socket reading and writing, eliminating the need for secondary copying of the byte buffer and saving memory usage.
[0116] The information transmission method provided in this disclosure converts structured and unstructured information into byte streams for transmission. Different types of information are obtained based on the parsed byte array information or the extracted preset fields, and then different branch processing is performed, which increases the flexibility of information transmission.
[0117] The information transmission method provided in this disclosure is applicable to a wide range of scenarios and does not depend on any specific computer hardware system or operating system. This disclosure can provide an information transmission method that supports the transmission of both structured and unstructured information. This information transmission method can be reliable, stable, and efficient.
[0118] It should be noted that, unless it is explicitly stated that there is a sequential order of execution between different operations, or that there is a sequential order of execution between different operations in terms of technical implementation, the execution order between multiple operations may not be significant, and multiple operations may be executed simultaneously.
[0119] Based on the above information transmission method, this disclosure also provides an information transmission device. The following will be combined with... Figure 8 The device is described in detail.
[0120] Figure 8 A schematic block diagram of an information transmission apparatus according to an embodiment of the present disclosure is shown.
[0121] like Figure 8 As shown, the information transmission device 800 in this embodiment includes a first conversion module 810, a first encoding module 820, and a first transmission module 830.
[0122] The first conversion module 810 is used to respond to the information transmission instruction by converting the information to be processed carried in the information transmission instruction into a length byte stream representing the length of the information to be processed and a content byte stream representing the content of the information to be processed. The information to be processed includes structured information, unstructured information, and information combining structured and unstructured information.
[0123] The first encoding module 820 is used to encode the length byte and content byte stream using a first custom encoding strategy to obtain encoded information, wherein the first custom encoding strategy is associated with the length byte of the information to be processed.
[0124] The first sending module 830 is used to send encoded information to the server through a socket protocol channel so that the server can decode the encoded information using a first custom decoding strategy to obtain information to be processed. The first custom decoding strategy is associated with the first custom encoding strategy.
[0125] According to the information transmission method, apparatus, device, storage medium, and program product provided in this disclosure, in response to an information transmission instruction, information to be processed is converted into a stream of length bytes and content bytes. The information to be processed may include structured information, unstructured information, or a combination of structured and unstructured information. Encoding is performed using a first custom encoding strategy related to the length bytes to obtain encoded information. The encoded information is then sent to a server via a socket protocol channel, so that the server performs decoding according to a first custom decoding strategy associated with the first custom encoding strategy. Because a custom encoding strategy related to the length bytes of the information to be processed is used during information transmission, the transmission length can be automatically adjusted according to the length bytes, at least partially solving the problem of limited transmission length in related technologies. Furthermore, the embodiments of this application can also support the transmission of structured information, unstructured information, and a combination of structured and unstructured information, thereby achieving the technical effect of improving the flexibility and efficiency of information transmission.
[0126] According to embodiments of this disclosure, the information transmission device may further include an assignment module and a second transmission module.
[0127] The assignment module is used to assign preset fields to structured information, unstructured information, and information combining structured and unstructured information.
[0128] The second sending module is used to send preset fields to the server through the socket protocol channel.
[0129] According to embodiments of this disclosure, the information transmission device may further include an extraction module, an analysis module, a first determination module, and a first decoding module.
[0130] The extraction module is used to extract preset fields using preset scripts.
[0131] The analysis module is used to analyze the type of the message to be processed based on preset fields and obtain the analysis results.
[0132] The first determination module is used to determine the decoding process based on the analysis results.
[0133] The first decoding module is used to decode the encoded information according to the decoding process and the first custom decoding strategy to obtain the information to be processed.
[0134] According to embodiments of this disclosure, the information transmission device may further include a second conversion module, an acquisition module, a second encoding module, and a second transmission module.
[0135] The second conversion module is used to convert the information to be processed into a string.
[0136] The retrieval module is used to retrieve response messages based on strings.
[0137] The second encoding module is used to process the response message using a second custom encoding strategy to obtain an encoded response message, wherein the second custom encoding strategy is associated with the length bytes of the response message.
[0138] The second sending module is used to send the encoded response message through the socket protocol channel.
[0139] According to embodiments of this disclosure, the information transmission device may further include a second decoding module.
[0140] The second decoding module is used to decode the encoded response message using a second custom decoding strategy to obtain the processing result related to the information to be processed. The second custom decoding strategy is associated with the second custom encoding strategy.
[0141] According to embodiments of this disclosure, the information transmission device may further include a monitoring module, a first state module, and a second state module.
[0142] The monitoring module is used to monitor the interaction of the socket protocol channel and obtain the monitoring results.
[0143] The first state module is used to maintain the connection state of the socket protocol channel when the monitoring results indicate that an interaction has occurred on the socket protocol channel.
[0144] The second state module is used to adjust the connection status of the socket protocol channel to the closed state if the monitoring results show that no interaction has occurred in the socket protocol channel within a preset time.
[0145] According to embodiments of this disclosure, the information transmission device may further include a storage module and a reading module.
[0146] The storage module is used to store the length bytes and content byte streams in a byte buffer.
[0147] The read module is used to read the length bytes and content byte stream from the byte buffer during the decoding of encoded information using a first custom decoding strategy.
[0148] According to embodiments of this disclosure, the information transmission device may further include a transmission module and a read / write module.
[0149] The transmission module is used to transmit byte buffers in a socket protocol channel using a direct buffer.
[0150] The read / write module is used to read and write byte buffers in the socket protocol channel using off-heap memory.
[0151] According to embodiments of this disclosure, the information transmission device may further include a generation module and a processing module.
[0152] The generation module is used to generate a connection request when sending encoded information to the server via the socket protocol channel or when sending an encoded response message via the socket protocol channel.
[0153] The processing module is used to process connection requests using a preset transmission framework.
[0154] According to embodiments of this disclosure, the processing module may include a first allocation unit and a second allocation unit.
[0155] The first allocation unit is used to allocate the socket request established according to the connection request to the sub-reactor through the receiver after the main reactor responds to the connection request.
[0156] The second allocation unit is used by the sub-reactor to allocate socket requests to the thread pool via a dispatcher, so that the thread pool can process the socket requests.
[0157] According to embodiments of this disclosure, any plurality of modules among the first conversion module 810, the first encoding module 820, and the first transmission module 830 may be combined into one module, or any one of these modules may be split into multiple modules. Alternatively, at least a portion of the functionality of one or more of these modules may be combined with at least a portion of the functionality of other modules and implemented in one module. According to embodiments of this disclosure, at least one of the first conversion module 810, the first encoding module 820, and the first transmission module 830 may be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or implemented in hardware or firmware by any other reasonable means of integrating or packaging the circuitry, or implemented in any one of software, hardware, and firmware implementations, or in a suitable combination of any of these. Alternatively, at least one of the first conversion module 810, the first encoding module 820, and the first transmission module 830 may be at least partially implemented as a computer program module, which, when run, can perform corresponding functions.
[0158] It should be noted that the information transmission device part in the embodiments of this disclosure corresponds to the information transmission method part in the embodiments of this disclosure. The description of the information transmission device part is specifically referred to in the information transmission method part, and will not be repeated here.
[0159] Figure 9 A block diagram schematically illustrates an electronic device suitable for implementing an information transmission method according to an embodiment of the present disclosure.
[0160] like Figure 9 As shown, an electronic device 900 according to an embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage portion 908 into a random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0161] RAM 903 stores various programs and data required for the operation of electronic device 900. Processor 901, ROM 902, and RAM 903 are interconnected via bus 904. Processor 901 performs various operations of the method flow according to embodiments of the present disclosure by executing programs in ROM 902 and / or RAM 903. It should be noted that the programs may also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in said one or more memories.
[0162] According to embodiments of this disclosure, the electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to a bus 904. The electronic device 900 may also include one or more of the following components connected to the I / O interface 905: an input section 906 including a keyboard, mouse, etc.; an output section 907 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 910 as needed so that computer programs read from it can be installed into the storage section 908 as needed.
[0163] This disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs that, when executed, implement the method according to the embodiments of this disclosure.
[0164] According to embodiments of this disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, such as including, but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this disclosure, the computer-readable storage medium may include ROM 902 and / or RAM 903 and / or one or more memories other than ROM 902 and RAM 903 described above.
[0165] Embodiments of this disclosure also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code enables the computer system to implement the information transmission method provided in the embodiments of this disclosure.
[0166] When the computer program is executed by the processor 901, it performs the functions defined in the system / apparatus of this disclosure embodiments. According to embodiments of this disclosure, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0167] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and downloaded and installed via the communication section 909, and / or installed from a removable medium 911. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0168] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, it performs the functions defined in the system of this disclosure embodiment. According to embodiments of this disclosure, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0169] According to embodiments of this disclosure, program code for executing the computer programs provided in embodiments of this disclosure can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can execute entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0170] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0171] Those skilled in the art will understand that the features described in the various embodiments and / or claims of this disclosure can be combined or combined in various ways, even if such combinations or combinations are not explicitly described in this disclosure. In particular, the features described in the various embodiments and / or claims of this disclosure can be combined or combined in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or combinations fall within the scope of this disclosure.
[0172] The embodiments of this disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of this disclosure. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. The scope of this disclosure is defined by the appended claims and their equivalents. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of this disclosure, and all such substitutions and modifications should fall within the scope of this disclosure.
Claims
1. An information transmission method, comprising: In response to an information transmission instruction, the information to be processed carried in the information transmission instruction is converted into a length byte stream representing the length of the information to be processed and a content byte stream representing the content of the information to be processed, wherein the information to be processed includes structured information, unstructured information, and information combining structured and unstructured information; Using a first custom encoding strategy, the encoding length is calculated based on the length bytes using a custom transmission protocol format, and the encoding length is converted into bytes of a predetermined number of bits and then written into the content byte stream to obtain encoded information. The first custom encoding strategy is associated with the length bytes of the information to be processed. The encoded information is sent to the server through a socket protocol channel so that the server can decode the encoded information using a first custom decoding strategy to obtain the information to be processed. The first custom decoding strategy is associated with the first custom encoding strategy. On the server side, the encoded information is decoded using a first custom decoding strategy to obtain the information to be processed. Based on the string obtained by converting the information to be processed, a response message is acquired. The response message is defined as an object type using a second custom decoding strategy, with the object attribute being a byte array, resulting in an encoded response message. The second custom decoding strategy automatically adjusts the transmission length according to the length of the response message in bytes. The encoded response message is then sent through the socket protocol channel. Decoding the encoded information on the server side using the first custom decoding strategy includes: analyzing the type of the information to be processed based on preset fields of the structured information, the unstructured information, and the combination of structured and unstructured information, obtaining an analysis result; and decoding the encoded information according to the decoding process obtained based on the analysis result and the first custom decoding strategy to obtain the information to be processed. The method further includes: if the read / write status of the socket protocol channel is detected to remain unchanged within a preset time, adjusting the connection status of the socket protocol channel to a closed state and releasing the resources of the socket protocol channel.
2. The method according to claim 1, further comprising: Preset fields are assigned to the structured information, the unstructured information, and the information combining the structured and unstructured information, respectively; The preset fields are sent to the server through the socket protocol channel.
3. The method according to claim 1, further comprising: The encoded response message is decoded using a second custom decoding strategy to obtain a processing result related to the information to be processed, wherein the second custom decoding strategy is associated with the second custom encoding strategy.
4. The method according to claim 1, further comprising: Monitor the interaction of the socket protocol channel and obtain the monitoring results; If the monitoring results indicate that interaction has occurred in the socket protocol channel, the connection status of the socket protocol channel shall be maintained.
5. The method according to claim 4, further comprising: Store the length byte and the content byte stream in a byte buffer; During the decoding of the encoded information using the first custom decoding strategy, the length byte and the content byte stream are read from the byte buffer.
6. The method according to claim 5, further comprising: The byte buffer is transmitted in the socket protocol channel using a direct buffer; as well as The byte buffer is read and written using off-heap memory in the socket protocol channel.
7. The method according to claim 1, further comprising: A connection request is generated when the encoded information is sent to the server via the socket protocol channel or when the encoded response message is sent via the socket protocol channel. as well as The connection request is processed using a preset transmission framework.
8. The method according to claim 7, wherein, The preset transmission framework includes a main reactor, a receiver, a sub-reactor, a distributor, and a thread pool; The process of handling the connection request using a preset transmission framework includes: After the main reactor responds to the connection request, it will allocate the socket request established according to the connection request to the sub-reactor through the receiver. The sub-reactor distributes the socket request to the thread pool via the dispatcher, so that the thread pool can process the socket request.
9. An information transmission device, comprising: The first conversion module is used to respond to the information transmission instruction by converting the information to be processed carried in the information transmission instruction into a length byte stream representing the length of the information to be processed and a content byte stream representing the content of the information to be processed, wherein the information to be processed includes structured information, unstructured information, and information combining structured and unstructured information. The first encoding module is used to calculate the encoding length based on the length bytes using a first custom encoding strategy and a custom transmission protocol format, convert the encoding length into bytes of a predetermined number of bits, and then write it into the content byte stream to obtain encoded information. The first custom encoding strategy is associated with the length bytes of the information to be processed. The first sending module is used to send the encoded information to the server through a socket protocol channel, so that the server can decode the encoded information using a first custom decoding strategy to obtain information to be processed, wherein the first custom decoding strategy is associated with the first custom encoding strategy; The second conversion module is used to convert the information to be processed into a string; The acquisition module is used to acquire the response message based on the string; The second encoding module is used to define the response message as an object type using a second custom encoding strategy. The object attribute is a byte array, and the encoded response message is obtained. The second custom encoding strategy automatically adjusts the transmission length according to the length of the response message in bytes. The second sending module is used to send the encoded response message through the socket protocol channel; The step of decoding the encoded information on the server using a first custom decoding strategy includes: analyzing the type of the information to be processed based on preset fields of the structured information, the unstructured information, and the combination of the structured information and the unstructured information, and obtaining an analysis result; and decoding the encoded information according to the decoding process obtained based on the analysis result and the first custom decoding strategy to obtain the information to be processed. The device further includes: if the read / write status of the socket protocol channel is detected to remain unchanged within a preset time, adjusting the connection status of the socket protocol channel to a closed state and releasing the resources of the socket protocol channel.
10. An electronic device, comprising: One or more processors; Storage device for storing one or more programs. Wherein, when the one or more programs are executed by the one or more processors, the one or more processors perform the method according to any one of claims 1 to 8.
11. A computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the method according to any one of claims 1 to 8.
12. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Information processing apparatus, and information processing method
CN102630009A