Disclosure of Invention
Therefore, the application provides a message isolation communication method adapting to multi-mode micro-applications, which aims to solve the problem of inconsistent message buses in the prior art.
In order to achieve the above object, the present application provides the following technical solutions:
in a first aspect, a message isolation communication method for adapting a multi-modal micro-application includes:
introducing SDK and initializing a client;
setting a plug-in name and connecting to a message bus through an SDK;
receiving connection success information returned by the message bus through the SDK;
Judging the application type, and reporting channel information and an online notification to the message bus through the SDK according to the application type; the message bus sets a message channel according to channel information and broadcasts an online message to all clients;
Transmitting real-time information or offline information to the message bus through the SDK; and after receiving the information, the message bus sends the information to the target application according to the online condition of the target application and the reporting condition of the message channel.
Preferably, the judging application type reports channel information and online notification to the message bus through the SDK according to the application type; the message bus sets a message channel according to channel information and broadcasts an online message to all clients, and the message bus specifically comprises the following steps:
Judging whether the application is a composite application or not;
if the channel information is the composite application, reporting channel information to the message bus through the SDK; the message bus sets message channels according to channel information;
If the application is not the composite application, judging whether the application is the micro application or not;
If the application is the micro application, judging whether the application is the B-terminal application, and reporting channel information and uploading information to the message bus through the SDK according to the judging condition.
Preferably, the determining whether the application is a B-side application, and reporting channel information and an online notification to the message bus through the SDK according to the determining situation specifically includes:
If the application is the B-side application, opening a webpage to modify a webpage user agent, adding channel information, and setting a plug-in name through an SDK; the SDK analyzes channel information in the user agent and reports the channel information to the message bus; the message bus sets message channels according to channel information;
If the application is not the B-side application, setting a plug-in name through the SDK; the SDK searches an application process tree, judges whether the application belongs to the composite application again through the application process tree, if the application is not the composite application, the SDK sends an online notification to the message bus, and if the application is the composite application, the composite application process number is analyzed as channel information.
Preferably, the sending real-time information or offline information to the message bus through the SDK specifically includes:
The SDK judges whether the application is connected with the message bus or not;
if so, sending the message to the message bus;
If no connection exists, adding the message to a cache offline message queue;
Judging whether the message is overtime;
If not, continuing to judge whether the application is connected with the message bus or not;
if the connection is made, judging whether the time is overtime;
If not, dequeuing the message and sending an offline message to the message bus;
if the time is out, the message is dequeued and no longer sent.
Preferably, after receiving the information, the message bus sends the message to the target application according to the online condition of the target application and the reporting condition of the message channel, and specifically includes:
Judging whether the target application is online or not;
if yes, judging whether a message channel exists between the target application and the sending application;
if a message channel exists, sending the message to a target application;
If the target application is not online or the target application does not have a message channel, storing the message into an offline message queue to wait for the target application to be online or report the message channel;
if the messages in the offline message queue are overtime, the messages are removed from the queue, and the message transmission fails; if the messages in the offline message queue are not overtime, the target application is continued to wait for the online or message reporting channel.
In a second aspect, a message isolation communication system adapted for multimodal micro applications, comprising:
the SDK introducing module is used for introducing the SDK and initializing the client;
The connection module is used for setting the plug-in name and is connected to the message bus through the SDK;
receiving connection success information returned by the message bus through the SDK;
The application registration module is used for judging the application type, and reporting channel information and online notification to the message bus through the SDK according to the application type; the message bus sets a message channel according to channel information and broadcasts an online message to all clients;
The message sending module is used for sending real-time information or offline information to the message bus through the SDK; and after receiving the information, the message bus sends the information to the target application according to the online condition of the target application and the reporting condition of the message channel.
In a third aspect, a computer device includes a memory storing a computer program and a processor implementing steps of a message quarantine communication method adapted to a multimodal micro-application when the computer program is executed.
In a fourth aspect, a computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of a message quarantine communication method adapted to multimodal micro-applications.
Compared with the prior art, the application has at least the following beneficial effects:
The application provides a message isolation communication method adapting to multi-mode micro-applications, which initializes a client by introducing an SDK; setting a plug-in name, and connecting to a message bus through an SDK; receiving connection success information returned by the message bus through the SDK; judging the application type, and reporting channel information and an online notification to the message bus through the SDK according to the application type; the message bus sets a message channel according to the channel information and broadcasts the online message to all clients; transmitting real-time information or offline information to a message bus through an SDK; and after receiving the information, the message bus sends the information to the target application according to the online condition of the target application and the reporting condition of the message channel. The message isolation communication method adapting to the multi-mode micro-application provided by the application supports end-to-end message transmission between applications developed by different application developers and message communication isolation between processes in the composite application, can meet the message communication requirement of the multi-mode application, realizes message isolation of inter-process communication in the composite application, and meets the communication requirement in the composite application.
Detailed Description
The application will be further described in detail by means of specific embodiments with reference to the accompanying drawings.
In the description of the present application: unless otherwise indicated, the meaning of "a plurality" is two or more. The terms "first," "second," "third," and the like in this disclosure are intended to distinguish between the referenced objects without a special meaning in terms of technical connotation (e.g., should not be construed as emphasis on the degree of importance or order, etc.). The expressions "comprising", "including", "having", etc. also mean "not limited to" (certain units, components, materials, steps, etc.).
The terms such as "upper", "lower", "left", "right", "middle", etc. are generally used herein for convenience of visual understanding with reference to the drawings and are not to be construed as absolute limitations on the positional relationship of the actual product. Such changes in the relative positional relationship without departing from the technical idea of the present application are also considered as the scope of the present application.
Example 1
Referring to fig. 1, the present embodiment provides a message isolation communication method adapted to a multi-mode micro-application, which relates to the field of message communication between multi-mode applications, wherein the multi-mode applications refer to a WEB application, a C/S structure application, and a composite application composed of a plurality of processes and having a common parent process.
The method provided by the embodiment is mainly used for communication and data exchange among the various different multi-mode applications, supports offline message sending and receiving, and can automatically add channel identifiers for message clients in the same father process in the composite application, so that message isolation in the same father process is effectively realized, and message receiving and transmitting disorder of the same message client identifiers is avoided.
The method comprises the following steps:
S1: introducing SDK and initializing a client;
Specifically, an SDK, i.e., a software development kit, is a collection of development tools used by software engineers to create application software for a specific software package, software framework, hardware platform, operating system, etc., and in general, an SDK is an SDK used to develop applications under a Windows platform.
S2: setting a plug-in name and connecting to a message bus through an SDK;
Specifically, after the connection to the message bus, the message bus sets the plug-in name as a unique theme, sets the client as an upper line, and then sends the connection success information to the application through the SDK.
S3: receiving connection success information returned by the message bus through the SDK;
Specifically, the application completes the connection of the application after receiving the connection success information.
S4: judging the application type, and reporting channel information and an online notification to a message bus through an SDK according to the application type; the message bus sets a message channel according to the channel information and broadcasts the online message to all clients;
referring to fig. 2, specifically, it is determined whether the application is a composite application;
If the channel information is the composite application, reporting the channel information to a message bus through the SDK; the message bus sets a message channel according to the channel information to finish application registration;
If the application is not the composite application, judging whether the application is the micro application or not;
If the application is the micro application, judging whether the application is the B-end application or not;
If the application is applied at the B end, opening a webpage to modify a webpage user agent, adding channel information, setting a plug-in name through an SDK, analyzing channel information in the user agent by the SDK, reporting a message bus, setting a message channel according to the channel information by the message bus, and finishing application registration;
If the application is not the B-side application, setting a plug-in name through the SDK, searching an application process tree by the SDK, and judging whether the application belongs to the composite application or not again through the application process tree; if the application is not the composite application, sending an online notification to a message bus, receiving the online message by the message bus, and broadcasting the message to all clients; if the application is the composite application, analyzing the composite application process number as channel information, reporting the channel information to a message bus, receiving the channel information by the message bus and setting a message channel, thereby completing application registration.
S5: transmitting real-time information or offline information to a message bus through an SDK; and after receiving the information, the message bus sends the information to the target application according to the online condition of the target application and the reporting condition of the message channel.
Referring to fig. 3, the method for sending real-time information or offline information to the message bus through the SDK specifically includes:
the application sends a message to the SDK, and the SDK judges whether the application is connected with a message bus or not;
if so, sending the message to the message bus;
If no connection exists, adding the message to a cache offline message queue;
Judging whether the message is overtime or not by the message in the message queue;
if the message bus is not overtime, attempting disconnection reconnection, and continuously judging whether the application is connected with the message bus or not;
If the connection is made, judging whether the time is overtime; if not, the message dequeues and sends an offline message to the message bus; if the time is out, the message is dequeued and is not sent any more;
if the connection is not available, the disconnection reconnection is continuously attempted until the time-out dequeue is reached, and the transmission is not performed.
Referring to fig. 4, after receiving information, a message bus sends the message to a target application according to a target application online condition and a message channel reporting condition, and specifically includes:
Judging whether the target application is online or not;
if yes, judging whether a message channel exists between the target application and the sending application;
if a message channel exists, sending the message to a target application;
If the target application is not online or the target application does not have a message channel, storing the message into an offline message queue to wait for the target application to be online or report the message channel;
if the messages in the offline message queue are overtime, the messages are removed from the queue, and the message transmission fails; if the messages in the offline message queue are not overtime, the target application is continued to wait for the online or message reporting channel.
After the steps are finished, the message is sent, the receiving party receives the message, or the sending party receives the message sending failure notification.
The method provided by the embodiment can be used in applications developed by a plurality of different developers and breaks an information island, the applications can realize a series of actions such as quote, connection, registration, channel, on-line notification, off-line notification, appointed application sending information, off-line receiving information and the like by sending certain standard information to a message bus, help users realize cooperative work among the applications, improve the efficiency and user experience of application programs, and help application developers realize borderless calling and storage of data.
Compared with the prior art, the embodiment supports end-to-end message transmission between applications developed by different developers and message communication isolation between processes in the composite application, and can meet the message communication requirements of multi-mode applications (such as WEB applications, C/S architecture applications, composite applications formed by combining a plurality of processes and the like). In addition, the offline messaging mechanism can ensure the reachability of the message, and by providing the encapsulated message SDK in different technology stacks to the upper layer business application, the upper layer business application can concentrate on the business development without concern for the messaging underlying technology.
Example two
The embodiment provides a message isolation communication system adapting to multi-mode micro-applications, which comprises the following steps:
the SDK introducing module is used for introducing the SDK and initializing the client;
The connection module is used for setting the plug-in name and is connected to the message bus through the SDK;
receiving connection success information returned by the message bus through the SDK;
The application registration module is used for judging the application type, and reporting channel information and online notification to the message bus through the SDK according to the application type; the message bus sets a message channel according to channel information and broadcasts an online message to all clients;
The message sending module is used for sending real-time information or offline information to the message bus through the SDK; and after receiving the information, the message bus sends the information to the target application according to the online condition of the target application and the reporting condition of the message channel.
For a specific limitation of a messaging system suitable for use between multimodal applications, reference is made to the above limitation of a messaging isolation communication method for adapting to a multimodal micro application, which is not described in detail herein.
Example III
The embodiment provides a computer device, which comprises a memory and a processor, wherein the memory stores a computer program, and the processor realizes the steps of a message isolation communication method adapting to multi-mode micro-applications when executing the computer program.
Example IV
The present embodiment provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of a message quarantine communication method adapted to multimodal micro-applications.
Any combination of the technical features of the above embodiments may be performed (as long as there is no contradiction between the combination of the technical features), and for brevity of description, all of the possible combinations of the technical features of the above embodiments are not described; these examples, which are not explicitly written, should also be considered as being within the scope of the present description.
The application has been described above with particularity and detail in connection with general description and specific embodiments. It should be understood that numerous conventional modifications and further innovations may be made to these specific embodiments, based on the technical concepts of the present application; but these conventional modifications and further innovations may also fall within the scope of the claims of the present application as long as they do not depart from the technical spirit of the present application.