A method and device for transmitting super large messages
By designing a very large message transmission method in the message middleware, the security problem of large message transmission in a weak network environment is solved, the message transmission capability and breakpoint resumption capability under resource constraints are realized, and the security of message transmission is improved. and reliability.
Patent Information
- Application Number
- CN202210256891.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-16
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-03-16
AI Technical Summary
In a weak network environment, existing message middleware has security issues when transmitting large messages, which are difficult to effectively solve.
A very large message transmission method is designed, including sending client, server and receiving client. By organizing and managing message metadata, slicing metadata and slicing data, a connection channel is established, and the ability to resume transmission at breakpoints is provided to ensure that messages secure transmission. Specific steps include establishing a connection between the client and the server, processing message metadata, verifying and retransmitting sliced data, and using NATS connection information to communicate with grpc to ensure the integrity and security of the message.
It provides the ability to transmit very large messages under conditions of limited resources, and realizes breakpoint resuming through local caching, which improves the security and reliability of message transmission.
Smart Images

Figure CN114697376B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of message middleware, and specifically provides a method and device for transmitting an extremely large message. Background Art
[0002] NATS is a simple, secure, high-performance digital, service and device communication system that provides a good message transmission system for modern enterprises. At the same time, NATS is an open source, lightweight, high-performance distributed message middleware that implements high scalability and an elegant Publish / Subscribe model.
[0003] Under the existing technology, large messages are transmitted abnormally in a weak network environment, and there are often security issues. How to avoid this situation is an urgent issue to be solved by those skilled in the art. Summary of the invention
[0004] The present invention aims at solving the above-mentioned deficiencies of the prior art and provides a highly practical method for transmitting very large messages.
[0005] A further technical task of the present invention is to provide a reasonably designed, safe and applicable ultra-large message transmission device.
[0006] The technical solution adopted by the present invention to solve its technical problem is:
[0007] A very large message transmission method, comprising a sending client, a service end and a receiving client, wherein the sending client organizes and sends message metadata, slice metadata and slice data, establishes a connection channel and sends a creation request;
[0008] The server manages the message metadata, slice metadata and slice data, creates and manages channels, and provides the capabilities of ultra-large message caching and breakpoint resuming;
[0009] The receiving client pulls data from the server and verifies and restores large messages according to rules, caches the pulled data, and provides data retransmission capability.
[0010] Further, firstly, a sending client, a server and a receiving client are connected and a channel is created, the sending client and the receiving client use grpc to send NATS connection information to the server, and the server uses the NATS information to connect to the NATS server;
[0011] At the same time, the server assigns clientID to the sending client and the receiving client. The sending client uses grpc to create, delete, and update the queue model. The receiving client obtains queue model information, queue list, and determines whether the queue exists.
[0012] Furthermore, the sending client sends the task description information to the server, and the server processes it according to the message management logic. If it is a new message, it initializes the data stream and data storage bucket of the corresponding message, replies to the temporary data storage bucket to the ack-inbox, and sends a task message format encoded data to the message event Stream.
[0013] Furthermore, after the sending client obtains the data storage bucket information, it sends the slice meta information in the data storage bucket to the server. The server compares the slice meta information with the slice meta information stored in the data storage to determine whether the corresponding data segment needs to be sent. If it needs to be sent, the mark bit in the slice meta information is marked and the marked slice meta information is returned to the sending client.
[0014] Further, the marked slice meta information is returned to the sending client, and the sending client decides whether to send the relevant slice data to the corresponding data storage bucket according to the returned result, where the key in the data storage bucket is the slice index and the value is the corresponding data segment;
[0015] After the slice data is successfully stored, a slice event is sent to the server. The server writes the slice event into the data stream based on the received slice event if the corresponding data storage bucket contains the corresponding data slice.
[0016] Furthermore, after writing the slice event into the data stream, the sending client sends a task end message to the server, and the server verifies whether the data stored on the server is complete according to the task meta information, and returns relevant retransmission logic information if it is incomplete;
[0017] If complete, the task completion reply message is returned and the task completion event is written to the data stream.
[0018] Furthermore, the receiving client sends a message to pull the queue name to the server, and the server creates a Consumer corresponding to the message Stream and returns the created Consumer to the receiving client using the pull mode.
[0019] Furthermore, after the receiving client parses and obtains the Consumer corresponding to the message Stream, it parses and obtains the data slice Stream from the message Stream. The receiving client creates a Consumer corresponding to the data slice Stream and pulls and obtains the slice event.
[0020] Furthermore, the pulled slice event is parsed to obtain the corresponding data storage bucket information and the verification value of the corresponding data, and decide whether to obtain the relevant data from the target bucket based on the local cache situation. When the corresponding task end event is read, this large message ends, the corresponding data slice Consumer is deleted, and the receiving client submits confirmation of the message event Consumer.
[0021] A super large message transmission device, comprising: at least one memory and at least one processor;
[0022] The at least one memory is used to store a machine-readable program;
[0023] The at least one processor is used to call the machine-readable program to execute a very large message transmission method.
[0024] Compared with the prior art, the method and device for transmitting a large message of the present invention have the following outstanding beneficial effects:
[0025] The present invention includes a sending client, a receiving client and a server, and can provide the ability to transmit super-large messages under resource-constrained conditions. At the same time, the server and the receiving end provide local cache capabilities, and can achieve the breakpoint-resume transmission capability of super-large messages. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0027] Attached Figure 1 It is a flow chart of sending a large message from a client to a server in a method of transmitting a large message;
[0028] Attached Figure 2 It is a flow chart of receiving a message from a client to a server in a very large message transmission method;
[0029] Attached Figure 3 It is a schematic diagram of the architecture of a very large message transmission method. DETAILED DESCRIPTION
[0030] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention is further described in detail below in conjunction with specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0031] A best embodiment is given below:
[0032] like Figure 1 , 2 As shown, a very large message transmission method in this embodiment includes a sending client, a server and a receiving client. The sending client organizes and sends message metadata, slice metadata and slice data, and establishes a connection channel and sends a creation request.
[0033] The server manages the message metadata, slice metadata and slice data, creates and manages channels, and provides the ability to cache large messages and resume breakpoint transmission.
[0034] The receiving client pulls data from the server and verifies and restores large messages according to the rules, caches the pulled data, and provides data retransmission capability.
[0035] First, the sending client, the server, and the receiving client are connected and a channel is created. The sending client and the receiving client use grpc to send NATS connection information to the server, and the server uses NATS information to connect to the NATS server. Among them, NATS connection information includes cluster address, user name, and password. This method solves the problem of inconsistent NATS information used by the client and server.
[0036] At the same time, the server assigns clientID to the sending client and the receiving client to ensure the uniqueness of the client, and performs client information management, NATS information management, and account management. The sending client uses grpc to create, delete, and update the queue model, and the receiving client obtains the queue model information, queue list, and determines whether the queue exists.
[0037] The specific process of sending a large message from the client to the server is as follows:
[0038] The sending client sends the task description information to the server, which processes it according to the message management logic. If it is a new message, the data stream and data storage bucket of the corresponding message are initialized. In addition to data slices, the data storage bucket also contains additional meta information such as the total number of data fragments and the number of received fragments. The temporary data storage bucket and other information are replied to the ack-inbox, and a task message format encoding data is sent to the message event stream. The message event stream data enables the receiver to perceive the large message transmission event and obtain the data stream associated with the message.
[0039] After the sending client obtains the data storage bucket information, it sends the slice meta information to the server. The server compares the slice meta information with the slice meta information stored in the data storage to determine whether the corresponding data segment needs to be sent. If it needs to be sent, it marks the flag bit in the slice meta information. Finally, the marked slice meta information is returned to the sending client.
[0040] The sending client decides whether to send the relevant slice data to the corresponding data storage bucket based on the returned result. The key in the data storage bucket is the slice index and the value is the corresponding data segment. After the slice data is successfully stored, the slice event is sent to the server. After receiving the slice event, if the corresponding data storage bucket contains the corresponding data slice, the server writes the slice event to the data stream. The slice event contains the message ID, slice index number, slice checksum, data storage bucket, etc.
[0041] After the large message is sent, the sending client sends an end-of-task message to the server. The server verifies whether the data stored on the server is complete based on the task metadata. If it is incomplete, it returns the relevant retransmission logic information. If it is complete, it returns the task end reply information and writes the task end event to the data Stream.
[0042] like Figure 3 As shown in the figure, the specific steps for the receiving client to pull large messages from the server are:
[0043] The receiving client sends a pull message to the server, which includes the name of the queue to be used. The server performs relevant processing based on the pull information:
[0044] Create a Consumer corresponding to the message stream and use the pull mode. Finally, return the created Consumer to the receiving client. After the receiving client parses and obtains the Consumer corresponding to the message stream, it parses and obtains the data slice stream from the message stream.
[0045] The receiving client creates the Consumer corresponding to the data slice Stream and pulls the slice event. Parse the slice event to obtain the corresponding data storage bucket information and the checksum of the corresponding data, and decide whether to obtain the relevant data from the target bucket based on the local cache situation. When the corresponding task end event is read, this large message ends and the corresponding data slice Consumer is deleted. The client submits the confirmation of the message event Consumer and obtains the next message event.
[0046] The five message transmission formats in the present invention are:
[0047] (1) Message metadata:
[0048] The overall information of a large message includes: message ID, channel ID, client ID, message size, and message slice size. Message ID: identifies the uniqueness of a large message; channel ID: the channel used to transmit messages, that is, the logical link between the sending and receiving client and the server to transmit messages; client ID: identifies the uniqueness of the client; message size: the overall length of a large message; message slice size: a large message needs to be cut into small message segments for transmission.
[0049] (2) Slice metadata:
[0050] The overall information of the slice metadata includes: message identifier, channel identifier, client identifier, and slice message body. The slice message body contains: large message slice index, large message slice fingerprint, and mark bit. Large message slice index: the index number of each large message; large message slice fingerprint: the hash value of each large message, used to verify the slice data; mark bit: the mark bit is used to identify whether the slice data segment has been successfully transmitted. If the mark bit has been marked, the corresponding slice data segment does not need to be sent, otherwise the slice data segment needs to be sent.
[0051] (3) Slice event:
[0052] The slice event as a whole includes: message ID, channel ID, client ID, large message shard index, large message shard fingerprint, and data storage bucket name. Data storage bucket: used to store each slice data segment. Each super large file corresponds to a data storage bucket and data stream. The slice event needs to be saved in the data stream, and the receiving client obtains the stored slice data based on the data storage bucket information.
[0053] (4) Message events:
[0054] The message event as a whole includes: data stream information, which is stored in the message stream, and each channel corresponds to a message stream. The receiving client obtains the data stream according to the message stream information, thereby obtaining the slice data.
[0055] (5) End task message:
[0056] The task end message includes: message ID, channel ID, client ID, and task end ID. Task end ID: indicates whether the task is ended. When the server receives the task end ID, it verifies the data. If the data is complete, it returns to the client to complete the task. Otherwise, it retransmits the data.
[0057] A super large message transmission device, comprising: at least one memory and at least one processor;
[0058] The at least one memory is used to store a machine-readable program;
[0059] The at least one processor is used to call the machine-readable program to execute a very large message transmission method.
[0060] The above-mentioned specific implementations are only specific cases of the present invention. The patent protection scope of the present invention includes but is not limited to the above-mentioned specific implementations. Any appropriate changes or substitutions made by any ordinary technician in the technical field that conform to the claims of a method and device for transmitting a very large message in the present invention shall fall within the patent protection scope of the present invention.
[0061] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for transmitting an extremely large message, characterized in that: It includes a sending client, a server and a receiving client. The sending client organizes and sends message metadata, slice metadata and slice data, establishes a connection channel and sends a creation request; The server manages the message metadata, slice metadata and slice data, creates and manages channels, and provides the capabilities of ultra-large message caching and breakpoint resuming; The receiving client pulls data from the server and verifies and restores large messages according to rules, caches the pulled data, and provides data retransmission capability; First, a sending client, a server, and a receiving client are connected and a channel is created. The sending client and the receiving client use grpc to send NATS connection information to the server, and the server uses the NATS information to connect to the NATS server; At the same time, the server assigns clientID to the sending client and the receiving client. The sending client uses grpc to create, delete, and update the queue model. The receiving client obtains queue model information, queue list, and determines whether the queue exists. The sending client sends the task description information to the server, and the server processes it according to the message management logic. If it is a new message, it initializes the data stream and data storage bucket corresponding to the new message, replies to the temporary data storage bucket in the ack-inbox, and sends a task message format encoded data to the message event stream; After the sending client obtains the data storage bucket information, it sends the slice metadata in the data storage bucket to the server. The server compares the slice metadata with the slice metadata stored in the data storage to determine whether the corresponding data segment needs to be sent. If it needs to be sent, it marks the mark bit in the slice metadata and returns the marked slice metadata to the sending client. The marked slice metadata is returned to the sending client, and the sending client decides whether to send the relevant slice data to the corresponding data storage bucket according to the returned result. The key in the data storage bucket is the slice index, and the value is the corresponding data segment; After the slice data is successfully stored, the slice event is sent to the server. The server writes the slice event into the data stream if the corresponding data storage bucket contains the corresponding data slice according to the received slice event. After writing the slice event into the data stream, the sending client sends a task end message to the server, and the server verifies whether the data stored on the server is complete according to the task meta information. If it is incomplete, it returns the relevant retransmission logic information; If complete, the task completion reply message is returned and the task completion event is written to the data stream; The receiving client sends a message to pull the queue name to the server, and the server creates a Consumer corresponding to the message Stream and returns the created Consumer to the receiving client using the pull mode; After the receiving client parses and obtains the Consumer corresponding to the message Stream, it parses and obtains the data slice Stream from the message Stream. The receiving client creates a Consumer corresponding to the data slice Stream and pulls and obtains the slice event. Parse the pulled slice event to obtain the corresponding data storage bucket information and the verification value of the corresponding data, and decide whether to obtain the relevant data from the target bucket according to the local cache situation. When the corresponding task end event is read, this large message ends, the corresponding data slice Consumer is deleted, and the receiving client submits confirmation of the message event Consumer.
2. A super large message transmission device, characterized in that: include: at least one memory and at least one processor; The at least one memory is used to store a machine-readable program; The at least one processor is configured to call the machine-readable program to execute the method of claim 1.
