Instant messaging system, service plug-in, storage medium and electronic device
By designing a layered architecture and an event bus module, the problem of insufficient scalability of instant messaging systems in multiple business scenarios was solved, enabling flexible access to business plugins and asynchronous logic execution, thereby improving the scalability and stability of the system.
Patent Information
- Application Number
- CN202611264105.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-19
- Publication Date
- 2026-11-24
AI Technical Summary
Existing instant messaging system architectures suffer from insufficient scalability when facing diverse business needs, leading to the need for invasive modifications and repetitive development, which prolongs development cycles and wastes R&D resources.
It adopts a layered architecture design, and decouples business plugins from the main instant messaging process through predefined extension point interfaces and event bus modules. This allows business plugins to execute post-processing logic asynchronously, and isolates event bus instances through business identifiers, supporting flexible access for various instant messaging business scenarios.
It achieves seamless integration of different business scenarios, avoids redundant development, shortens the launch cycle, improves system scalability and operational reliability, and ensures the stability of the main process and the efficiency of business iteration.
Smart Images

Figure CN123164086A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to an instant messaging system, a service plugin, a storage medium, and an electronic device. Background Technology
[0002] Instant messaging (IM) systems are widely used in business scenarios such as social networking, enterprise office work, and online customer service, possessing basic communication functions such as session management, session member management, message sending and receiving, and push notifications. Existing commercial and open-source IM architectures are mostly customized for fixed business scenarios, with a high degree of coupling between the underlying basic communication capabilities and the upper-layer business logic, resulting in insufficient architectural scalability. When iterating on features to meet differentiated business needs, it often requires intrusive modifications to the core communication code.
[0003] If an enterprise needs to simultaneously support multiple types of instant messaging services or rapidly deploy new business scenarios, it cannot directly reuse the same set of underlying instant messaging capabilities. To adapt to new business requirements, developers typically need to perform large-scale invasive secondary development based on the open-source instant messaging kernel, or independently build a completely new instant messaging service. This results in a large amount of homogeneous development work, which not only prolongs the project development cycle but also causes a significant waste of R&D resources. Summary of the Invention
[0004] In view of this, the present invention provides an instant messaging system, a service plugin, a storage medium, and an electronic device that can simultaneously support multiple instant messaging service scenarios, effectively avoid redundant development, shorten the service launch cycle, and save R&D resources.
[0005] Specifically, the present invention is achieved through the following technical solution: According to a first aspect of the present invention, an instant messaging system is provided, comprising: A first module and at least one business plug-in that is communicatively connected to the first module; The first module includes a first expansion point interface and an event bus submodule; Each of the aforementioned service plugins corresponds to a single service. Each service plugin has built-in configuration information, which includes a service identifier used to uniquely identify the single service. The first module is used for: Obtain and parse the configuration information of each of the aforementioned business plugins, wherein the configuration information includes a business identifier; Through the first extension point interface, the first business logic corresponding to each of the business plugins is accessed into the instant messaging main process according to the configuration information. In addition, an event bus instance corresponding to each of the service identifiers is created through the event bus submodule, and the event listener of each service plugin is registered to the event bus instance corresponding to its own service identifier, so as to distribute the service event to the corresponding event bus instance according to the service identifier; The business plugin is used for: By adapting the first extension point interface, the first business logic is integrated into the main instant messaging process. Additionally, it subscribes to business events corresponding to its own business identifier through an event listener, and triggers the execution of the second business logic when the business event is listened to; The second business logic is a post-processing logic that is executed asynchronously relative to the main instant messaging process and does not interfere with the running state of the main instant messaging process.
[0006] In some embodiments, the first extension point interface includes a session extension point interface, a session member extension point interface, and a message extension point interface. The session extension point interface, the session member extension point interface, and the message extension point interface are respectively configured to set interception points before and after the execution of process nodes such as session lifecycle, member entry and exit from session, and message sending and receiving.
[0007] In some embodiments, the extension methods defined in the message extension point interface include a first strategy extension method and a second strategy extension method. The first strategy extension method is used to customize the range of message receiving objects, and the second strategy extension method is used to customize the message push channel and push priority corresponding to each receiving object.
[0008] In some embodiments, the configuration information further includes the event processing mode corresponding to each business event, wherein the event processing mode is a synchronous processing mode or an asynchronous processing mode; each event bus instance is equipped with an asynchronous queue and an independent thread pool; The first module is also used for: Based on the configuration information of the business plugin corresponding to the business identifier, determine whether the business event adopts synchronous or asynchronous processing mode; If it is a synchronous processing mode, the event listener of the business plugin is directly called to execute the second business logic; In asynchronous processing mode, business events are stored in the asynchronous queue corresponding to the event bus instance, and the business events are scheduled through the thread pool corresponding to the event bus instance so that the event listener of the business plugin can consume and process them.
[0009] In some embodiments, the first module is further configured to: When loading a business plugin, obtain the configuration information of the business plugin; Perform compatibility checks on the extension point interfaces recorded in the configuration information. If the check fails, terminate the loading of the business plugin.
[0010] In some embodiments, the compatibility verification includes a first verification and a second verification. Performing compatibility verification on the extension point interfaces recorded in the configuration information, and terminating the loading of the service plugin if the verification fails, includes: Perform the first verification and the second verification on the extension point interface recorded in the configuration information; If both the first and second checks are successful, the compatibility check is deemed to have passed, and the system continues to load the service plugin. If either the first or second verification fails, the compatibility verification is deemed unsuccessful, and the system terminates the loading of the service plugin.
[0011] In some embodiments, performing the first verification on the extension point interface recorded in the configuration information includes: Verify whether the extension point interface recorded in the business plugin configuration information is the first extension point interface preset by the first module; If the expansion point interface does not belong to the first expansion point interface preset by the first module, the first verification fails; if the expansion point interface belongs to the first expansion point interface preset by the first module, the first verification succeeds. Perform the second verification on the extension point interface recorded in the configuration information, including: Obtain the target implementation class in the business plugin that declares the implementation of the extension point interface; Verify whether the target implementation class fully implements all methods defined in the extension point interface; If the target implementation class does not implement the extension point interface, or if the target implementation class implements the extension point interface but has at least one of the following situations: unimplemented methods or method signatures that are inconsistent with the definition in the extension point interface, then the second verification is determined to have failed. If the target implementation class fully implements all the methods defined in the extension point interface, and the method signatures of each implementation method are consistent with the definitions in the extension point interface, then the second verification is successful.
[0012] In some embodiments, the first module assigns an independent class loader to each business plugin; The first module is also used for: When uninstalling or updating a business plugin, the event listener of the business plugin is unregistered, the event bus instance corresponding to the business identifier and the class loader corresponding to the business plugin are destroyed, and the asynchronous queue and thread pool resources corresponding to the event bus instance are released.
[0013] In some embodiments, at least one extension method is defined in the first extension point interface; The first module is also used for: When the instant messaging main process of the business corresponding to the business identifier reaches the preset node, the extension method of the first extension point interface is called to execute the first business logic in the business plugin corresponding to the business identifier.
[0014] In some embodiments, the first module is further configured to: The session master state is maintained uniformly, and the session master state includes created, in session, and ended. It also generates a session context carrying a service identifier, and stores the session sub-states that are custom-managed by the service plugin corresponding to the service identifier into the session context.
[0015] According to a second aspect of the invention, a storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the functions of an instant messaging system as described in the first aspect or any possible implementation thereof.
[0016] According to a third aspect of the present invention, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the functions of an instant messaging system as described in the first aspect or any possible implementation thereof.
[0017] According to a fourth aspect of the present invention, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the functionality of an instant messaging system in the first aspect or any possible implementation thereof.
[0018] According to a fifth aspect of the present invention, a service plugin is provided, the service plugin having built-in configuration information, the configuration information including a service identifier for uniquely identifying a single service; The business plugin is configured as follows: The configuration information is provided to the first module of the instant messaging system so that the first module can complete the loading and registration of the business plugin; By adapting to the first extension point interface of the first module, the first business logic is integrated into the main instant messaging process. An event listener is provided to the first module so that the first module can register the event listener to the event bus instance corresponding to the business identifier of the business plugin; When a business event corresponding to its own business identifier is detected by the event listener, the second business logic is executed.
[0019] In some embodiments, the extension methods defined in the first extension point interface include blocking extension methods and policy-based extension methods; the first business logic includes business verification logic and business processing logic. The business plugin is configured as follows: In response to the call initiated by the first module through the blocking extension method, the business verification logic is executed; In response to the call initiated by the first module through the strategy-based extension method, the business processing logic is executed.
[0020] In some embodiments, the configuration information further includes an event processing mode corresponding to the business event, wherein the event processing mode is a synchronous processing mode or an asynchronous processing mode; The business plugin is configured as follows: When the event handling mode is synchronous processing mode, the event listener receives the business events synchronously pushed by the event bus instance and executes the second business logic. When the event handling mode is asynchronous, the event listener receives business events distributed by the event bus instance through the asynchronous queue scheduling and executes the second business logic.
[0021] In some embodiments, the business plugin is configured as follows: Customize session sub-states; The first module can read and write the session sub-state stored in the session context through the first extension point interface.
[0022] The technical solution provided by this invention brings at least the following beneficial effects: This invention provides a unified underlying instant messaging capability through a first module. Relying on a first extension point interface, the first business logic of business plugins is integrated into the main instant messaging process. Simultaneously, an event bus submodule creates independent event bus instances based on business identifiers, enabling business events to be distributed in isolation according to their business nature. Business plugins subscribe to corresponding business events based on their own business identifiers and execute asynchronous, post-processed second business logic without interfering with the main process. This architecture decouples the underlying core communication capabilities from the differentiated business logic at the upper layer. Various business plugins can be integrated without intrusive modifications to the core communication code. A single underlying system can simultaneously support multiple instant messaging business scenarios, effectively avoiding redundant development, shortening the business launch cycle, and ensuring that events from different businesses are isolated and do not interfere with each other, guaranteeing the stable operation of the main instant messaging process and significantly improving system scalability, business iteration efficiency, and operational reliability. Attached Figure Description
[0023] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0024] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, those skilled in the art can obtain other drawings based on these drawings without creative effort.
[0025] Figure 1 The network architecture of the instant messaging system provided in the embodiments of the present invention; Figure 2 A schematic diagram of the structure of an instant messaging system provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the architecture of the event bus submodule in an instant messaging system provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0027] To better understand the content of this invention, some technical terms will be explained first.
[0028] Business Code: An identifier string used to uniquely identify a type of business, thereby achieving business resource isolation; for example, CS-001 can represent customer service business, and ROOM-001 can represent chat room business. In this invention, different business codes correspond to independent event bus instances and business plugins, ensuring that the operation of various businesses does not interfere with each other.
[0029] Extension Point: A standardized interface defined by the system core layer, serving as the sole entry point for business plugins to interact with the core layer. By implementing the extension point interface, business plugins can integrate custom business logic at key nodes in the instant messaging core process without modifying the underlying core layer code.
[0030] Event Bus: A message communication mechanism implemented based on Java Virtual Machine memory. The core layer pushes business events to business plugins through the event bus, thereby triggering bypass business logic. In this invention, the event bus is deployed in isolation according to business codes, ensuring that business events generated by different businesses only flow within their corresponding business domains.
[0031] Plugin: A business extension unit that exists as an independent JAR package. It contains program code that implements specific business functions, extension point implementation classes, and event listeners. Plugins support dynamic loading, unloading, and version upgrades, and are decoupled from the system core layer.
[0032] Metadata-driven: A design pattern that dynamically defines plugin behavior based on plugin metadata (such as the im-plugin.yml configuration file). The core layer can automatically complete extension point registration and event handling strategy configuration by reading the metadata, eliminating the need for hard-coding and improving the system's flexible scalability.
[0033] IM (Instant Messaging): Instant messaging refers to a communication system that can transmit messages such as text, images, and voice in real time, which is the main application scenario of this invention.
[0034] SaaS (Software as a Service): Software as a Service is a business model that delivers software services over a network. This invention is applicable to various instant messaging business needs in enterprise-level SaaS scenarios.
[0035] JVM (Java Virtual Machine): The Java Virtual Machine serves as the runtime environment for Java programs. The event bus scheduling and plugin loading mechanisms of this invention can both be implemented based on the Java Virtual Machine.
[0036] TCP (Transmission Control Protocol): A connection-oriented transport layer communication protocol with reliable transmission characteristics. The communication layer of this invention supports a custom TCP protocol to ensure the stability of message transmission.
[0037] WebSocket: A communication protocol that enables full-duplex communication over a single TCP connection, suitable for real-time data interaction between clients and servers, and is one of the transmission protocols compatible with the communication layer of this invention.
[0038] Stomp (Simple Text Oriented Messaging Protocol): A simple text-oriented messaging protocol used for asynchronous communication between clients and message brokers, and one of the transport protocols compatible with the communication layer of this invention.
[0039] JSON (JavaScript Object Notation): A lightweight data exchange format, which this invention applies to the serialization and transmission of business events and the storage of plugin metadata.
[0040] Next, the technical solutions provided by the embodiments of the present invention will be described in detail.
[0041] In related technologies, the underlying basic communication capabilities of instant messaging systems are highly coupled with the upper-layer business logic, resulting in insufficient architectural scalability. This invention aims to decouple the relatively fixed core execution processes in session management, session member management, and message processing from the business rules that change with business needs. By pre-defining extension point interfaces, differentiated business logic can be integrated into the system as plug-ins, thereby enabling the system to agilely adapt to and efficiently support various business models.
[0042] Figure 1 The diagram illustrates the network architecture of the instant messaging system provided in an embodiment of the present invention. Figure 2 The diagram illustrates the structure of an instant messaging system provided by an embodiment of the present invention.
[0043] like Figure 1 As shown, the instant messaging system provided in this embodiment of the invention adopts a layered architecture, which includes an IM communication layer, an IM core layer, and an IM plugin layer from bottom to top.
[0044] IM Communication Layer: This is the underlying communication support layer of the system, providing communication protocol support, including WebSocket and Stomp protocols. The IM communication layer is only responsible for the transparent transmission of network data packets and does not carry any business logic.
[0045] IM Core Layer: This is the core operating layer of the system, providing basic instant messaging capabilities and including three major functional modules: sessions, session members, and messages.
[0046] The session module manages session states and session events. Session states are divided into a system-defined main state and sub-states that are extended by business plugins. The main state includes "Created," "In Session," and "Ended." Session events are divided into basic events and extended events. Basic events include "Create Session" and "End Session," while extended events are implemented by business plugins as needed. The session module predefines session extension points, and the extended methods defined in these points include pre-processing for creating a session, post-processing for creating a session, pre-processing for ending a session, and post-processing for ending a session.
[0047] The session member module includes session events and session member extension points: session events are divided into basic events and extended events. Basic events include joining a session and leaving a session, while extended events are defined by business plugins. The extended methods defined in the session member extension points include pre-processing for joining a session, post-processing for joining a session, pre-processing for leaving a session, and post-processing for leaving a session.
[0048] The message module includes message flow, message types, and message extension points: The message flow includes message receiving, message parsing, message storage, message propagation, message routing, and message pushdown in sequence; Supported message types include text, image, video, and voice; The extension methods defined in the message extension points include message receiving post-processing, message parsing post-processing, message storage pre-processing, message propagation strategy, message routing strategy, and message push post-processing.
[0049] IM Plugin Layer: This layer hosts various business plugins. Each business corresponds to an independent plugin JAR package. For example, the customer service business corresponds to the customer service plugin package `im-plugin-customer-1.0.0.jar`. Each business plugin has built-in metadata, which includes the business ID (or business code), event configuration, and extension point configuration information. This metadata is typically stored in a configuration file within the business plugin (e.g., `im-plugin.yml`) and is packaged along with the plugin's JAR package. When the IM core layer loads a business plugin, it can directly read this configuration file. By parsing the metadata, the IM core layer automatically identifies the business ID, event handling mode, and required extension points for that plugin. The registration process for the business plugin can be completed without modifying the IM core layer code or restarting the core service. Internally, each business plugin is divided into three types of extension modules based on functionality: session extensions, session member extensions, and message extensions. Each type of extension module implements an extension point interface and has event listening capabilities. Business plugins leverage the aforementioned extension modules to integrate with the main instant messaging process, enabling differentiated business functions. For example, in a customer service scenario, business plugins can implement customized business logic such as agent allocation and session transfer.
[0050] like Figure 2As shown in the figure, an instant messaging system provided by an embodiment of the present invention includes: a first module 11 and at least one service plug-in 12 communicatively connected to the first module 11; the first module 11 includes a first extension point interface 111 and an event bus submodule 112; each service plug-in 12 corresponds to a single service, and the service plug-in 12 has built-in configuration information, which includes a service identifier used to uniquely identify the single service. The first module 11 is deployed in the aforementioned IM core layer, and the service plug-in 12 is deployed in the aforementioned IM plug-in layer.
[0051] Module 11 is used for: Obtain and parse the configuration information of each of the aforementioned business plugins, wherein the configuration information includes a business identifier; Through the first extension point interface, the first business logic corresponding to each of the business plugins is accessed into the instant messaging main process according to the configuration information. Furthermore, the event bus submodule creates an event bus instance that corresponds one-to-one with each of the service identifiers, and registers the event listeners of each service plugin to the event bus instance corresponding to its own service identifier, so as to distribute service events to the corresponding event bus instance according to the service identifier.
[0052] Business Plugin 12 is used for: By adapting the first extension point interface, the first business logic is integrated into the main instant messaging process. Additionally, it subscribes to business events corresponding to its own business identifier through an event listener, and triggers the execution of the second business logic when the business event is listened to; The second business logic is a post-processing logic that is executed asynchronously relative to the main instant messaging process and does not interfere with the running state of the main instant messaging process.
[0053] In this embodiment of the invention, the configuration information of the business plugin includes metadata, and the business identifier can be, for example, a business code. Based on the built-in metadata of the business plugin, configuration-driven operation is implemented. When the IM core layer loads a business plugin, it can automatically match the business plugin with the corresponding business identifier, register the extension point implementation class, and bind the event listener to the event bus instance corresponding to the same business identifier, all based on the metadata. This allows for dynamic loading and initialization of the business plugin without modifying the core code.
[0054] The first extension point interface includes the session extension point interface (hereinafter referred to as session extension point), the session member extension point interface (hereinafter referred to as session member extension point), and the message extension point interface (hereinafter referred to as message extension point). The session extension point interface, the session member extension point interface, and the message extension point interface are respectively set to interception points before and after the execution of process nodes such as session lifecycle, member entry and exit from session, and message sending and receiving.
[0055] The main instant messaging workflow is a built-in, fundamental communication process within the IM core layer, independent of specific business logic. It represents a fixed, unchanging underlying capability of the system and remains unchanged regardless of business scenarios such as customer service or chat rooms. It includes processing links such as session creation, adding / removing session members, message reception, message parsing, message storage, message propagation, message routing, message push, and session termination. The main workflow only maintains common communication capabilities such as session master status, message forwarding, and member management, and does not include various business-specific rules.
[0056] The first business logic is the main business logic that the business plugin embeds into the key nodes of the instant messaging main process through the extension point interface. It can intervene in the execution direction of the main process. Examples include blocking / strategy-based business rules such as pre-session creation business verification, member addition permission interception, message filtering, custom message routing strategy, and pre-session end verification.
[0057] The second business logic is a bypass business logic triggered by the business plugin listening to business events through the event bus instance. It is not embedded in the main instant messaging process and cannot interfere with the main process. It belongs to the post-processing auxiliary logic. Examples include agent allocation after session creation, session data statistics after session end, business notification push after message processing is completed, offline message caching, session archiving and other post-processing auxiliary business processes.
[0058] The instant messaging system provided in this invention effectively decouples the underlying basic communication capabilities from the upper-layer differentiated business logic through a layered architecture design of a first module and independent business plugins. Specifically, the first module, relying on a preset first extension point interface, controllably integrates the first business logic corresponding to each business plugin into the main instant messaging process based on the business identifier configuration information of the business plugins. This avoids the problems of high customization difficulty and high transformation costs caused by the high coupling between core capabilities and business logic in traditional instant messaging systems, without requiring intrusive code modifications to the core communication process. Simultaneously, the event bus submodule of the first module creates independent event bus instances based on each business identifier, enabling precise registration of event listeners for different businesses and isolated distribution of business events. This effectively avoids event crosstalk and mutual interference between businesses during parallel operation, ensuring the stability and security of system operation. Furthermore, this invention integrates the first business logic of the main process accessed through an extension point with the second business logic triggered by event listening. This separates the business verification, strategy customization logic, and asynchronous post-processing logic that can interfere with the main process. The second business logic executes asynchronously independent of the main instant messaging process and does not affect the main process's running state. This ensures both the efficient and stable operation of the main instant messaging process and the flexible expansion of various post-processing capabilities. In summary, this invention can adapt to various differentiated instant messaging business scenarios based on a unified underlying core architecture, supporting independent expansion and flexible access of business plugins. This significantly reduces the system development, iteration, and maintenance costs in multiple business scenarios, effectively avoids redundant development, and significantly improves the scalability, compatibility, and business iteration efficiency of the instant messaging system.
[0059] In some embodiments, at least one extension method is defined in the first extension point interface; the first module 11 is further configured to: when the instant messaging main process of the service corresponding to the service identifier runs to a preset node, call the extension method of the first extension point interface to execute the first business logic in the service plugin 12 corresponding to the service identifier.
[0060] For example, the predefined session extension point interface (SessionExtPoint) of this invention includes extension methods such as preSessionCreate, postSessionCreate, preSessionEnd, and postSessionEnd. The triggering time and functional purpose of each extension method are shown in Table 1 below.
[0061] Table 1
[0062] The `preSessionCreate` method is called before the session creation operation is executed. It is used to perform quota verification and blacklist verification. If the verification result does not meet the requirements, it can return a judgment result to block the main process of session creation.
[0063] The postSessionCreate method is triggered after the session is created and is used to initialize custom session sub-states for business applications. For example, the "pending allocation" business sub-state can be set.
[0064] The `preSessionEnd` method is called before the session end operation is executed. It is used to perform session end permission verification. If the verification fails, it can block the main session end process.
[0065] The postSessionEnd method is called after the session ends and is used to release session-related resources.
[0066] For example, the predefined session member extension point interface (SessionMemberExtPoint) of this invention includes extension methods such as preJoinSession, postJoinSession, preLeaveSession, and postLeaveSession. The triggering time and functional purpose of each extension method are shown in Table 2 below.
[0067] Table 2
[0068] The `preJoinSession` method is called before a member performs the join operation. It is used to verify the maximum number of members, the blacklist, and the member's access permission. If the verification fails, it can return a result to block the main process of the member joining the session.
[0069] The postJoinSession method is triggered after a member successfully joins the session. It is typically used to push system notification messages related to a member's online status to the session.
[0070] The `preLeaveSession` method is called before a member of the session performs an operation to leave the session. It is used to perform exit permission verification. For example, it can be used to implement permission control logic in a chat room scenario to prevent the session creator from actively leaving the session.
[0071] The postLeaveSession method is called after a member completes the exit operation. It can perform business logic such as pushing offline system messages to members, releasing member-associated resources, and automatically triggering session termination when there are no remaining members in the session.
[0072] For example, the predefined message extension point interface (MessageExtPoint) of this invention includes extension methods such as postRecvMessage, postParseMessage, prePersistMessage, fanoutMessagePharse, routeMessagePharse, and postPushMessage. The triggering time and functional purpose of each extension method are shown in Table 3 below.
[0073] Table 3
[0074] The postRecvMessage method is triggered after the system receives a message and is used to implement message validity verification and blacklist / whitelist filtering.
[0075] The postParseMessage method is called after message parsing is complete. It is used to perform sensitive content review and message security checks.
[0076] The `prePersistMessage` method is called before the message is stored and can perform preprocessing, data encryption, and message field completion operations before message storage.
[0077] The `fanoutMessageParse` method is triggered during the message propagation phase. This method is a strategy-based extension method. Unlike blocking extension methods, it can replace the message propagation strategy built into the IM core layer, supports redefining the message recipient list, and enables control over the message visibility range.
[0078] The routeMessageParse method is called during the message routing phase. This method is a strategy-based extension method that can replace the built-in message routing strategy in the IM core layer and dynamically select the message push channel and push priority based on the message content.
[0079] The `postPushMessage` method is called after the message push is completed. It is used to perform post-processing operations such as message push result processing and business metric statistical reporting.
[0080] In this embodiment of the invention, when the main instant messaging process reaches a preset node, a business context carrying a business identifier can be generated. For example, when the main instant messaging process reaches the stages of session creation, member joining, message sending, or session termination, a session context carrying a business identifier, a member joining context, a message context, and a session termination context can be generated respectively.
[0081] This invention sets up a session context to carry runtime information throughout the entire lifecycle of a single session. The fields included in the session context are shown in Table 4 below.
[0082] Table 4
[0083] Among them, sessionId is a string type and serves as a globally unique identifier for the session; businessCode is a string type used to carry business codes to distinguish different business scenarios. For example, the code is CS-001, which represents customer service business. tenantId, a string type, stores the tenant identifier to achieve data isolation among multiple tenants; creatorId is a string that records the user identifier of the session creator; sessionType is an enumeration type that represents the session type, supporting one-on-one chat, group chat, customer service chat, etc. mainStatus is an enumeration type that represents the main session status maintained uniformly by the system, including created, in session, and ended. `subStatus` is a string type, which is a custom session sub-state for business plugins. Examples include "Pending Assignment", "Assigning", and "Service in Progress". `createTime` is a long integer that stores the session creation timestamp. extData is a mapping structure that serves as an extended field for business plugins to store private business data. pluginContext, built upon thread-local storage (ThreadLocal), serves as a data transfer container within the plugin.
[0084] The session context is maintained uniformly by the IM core layer, in which the main session state is controlled by the core layer; private business data in the session sub-states and extended fields are read and written autonomously by the business plugins, thereby achieving the separation and management of general session information and differentiated business states.
[0085] The present invention sets up a session member context (JoinSessionContext) to carry the running information corresponding to a single member within a single session. The fields contained in the session member context are shown in Table 5 below.
[0086] Table 5
[0087] Wherein, sessionId is a string type, representing a unique identifier for the session; businessCode is a string type used to carry business codes to distinguish different business scenarios; the example code is CS-001. tenantId is a string type that stores the tenant identifier and is used to implement multi-tenant data isolation. memberId is a string that records the user identifier of the current session member; memberName is a string that records the name of the current session member; sessionType is an enumeration type that represents the session type, supporting one-on-one chat, group chat, customer service chat, etc. createTime is a long integer that stores the timestamp of the session member's creation when they joined the session; extData is a mapping structure that serves as an extended field for business plugins to store private business data at the member level. pluginContext, built upon thread-local storage (ThreadLocal), serves as a data transfer container within the plugin.
[0088] The conversation member context is uniformly maintained by the IM core layer. The common basic fields are assigned and managed by the core layer, while the private business data in the extended fields are read and written autonomously by the business plugins. This achieves the separation and management of common information and differentiated business data of conversation members.
[0089] This invention sets up a message context to carry the runtime information in the entire message processing chain. The fields contained in the message context are shown in Table 6 below.
[0090] Table 6
[0091] Among them, messageId is a string type and serves as a unique identifier for the message; businessCode is a string type that carries the business code, with an example code of CS-001, which is used to determine the target business plugin corresponding to the message. sessionId, a string type, represents the identifier of the session to which the message belongs; senderId is a string type that records the user identifier of the message sender; senderType is an enumeration type representing the sender type, supporting users, systems, robots, etc. msgType is an enumeration type that represents the message type, including text, image, voice, video, etc. content is an object type that serves as the carrier of message content. Encryption and field completion can be performed during the message storage stage. receiverIds is a list of strings, which is a strategy parameter used by the fanoutMessageParse method to fill in the list of message receiver identifiers. routeInfos is a mapping structure and a policy-type input parameter. It is used by the routeMessageParse method to fill in routing decision information. The key is the receiver identifier, and the value includes parameters such as push channel type and push priority. seqNo is a long integer representing the message sequence number within the session. It is used for message sorting and deduplication and is assigned by the IM core layer after message storage is completed. `createTime` is a long integer that stores the message creation timestamp. extData is a mapping structure that serves as a container for extended business data. Business plugins can write custom business data at each stage of message processing. pushResults is a list structure that stores message push results, including delivery status, processing time, and failure reasons for each recipient.
[0092] The message context is maintained uniformly by the IM core layer throughout the entire message processing lifecycle. Common basic fields are assigned and managed by the IM core layer, while private business data within extended fields can be read and written independently by business plugins. When message processing-related extended methods are called, the message context is passed to the corresponding business plugin, providing complete runtime parameter support for the plugin to execute business logic such as message verification and processing strategy adjustments.
[0093] The present invention sets an EndSessionContext to carry the running information during the execution of the session end request. The fields of the EndSessionContext are shown in Table 7 below.
[0094] Table 7
[0095] Wherein, sessionId is a string type, representing a unique identifier for the session to be terminated; businessCode is a string type that carries the business code and is used to match the corresponding business plugin. tenantId, a string type, stores the tenant identifier to achieve multi-tenant isolation; operatorId, a string type, records the identifier of the operator that initiated the session termination request; operatorType is an enumeration type that represents the type of the operator, supporting ordinary users, administrators, system robots, etc. endReason, a string, records the reason for the end of the session; createTime is a long integer that stores the timestamp of when the request was initiated. extData is a mapping structure that serves as an extended field for business plugins to store custom business data during the session termination process. pluginContext, built upon thread-local storage (ThreadLocal), serves as a data transfer container within the plugin.
[0096] The session termination context is created by the IM core layer upon receiving a session termination request. It maintains a unique instance throughout the entire processing chain, from pre-session termination verification to resource release, ensuring information sharing across the entire process. The lifecycle of this session termination context is uniformly managed by the IM core layer. Common basic fields are assigned and managed by the IM core layer, while private business data within extended fields can be read and written independently by business plugins. When session termination-related extended methods are called, the session termination context is passed to the corresponding business plugin, providing runtime parameters for the plugin to execute business logic such as session termination permission verification and session cleanup.
[0097] In some embodiments, the configuration information further includes the event processing mode corresponding to each business event, wherein the event processing mode is a synchronous processing mode or an asynchronous processing mode; each event bus instance is equipped with an asynchronous queue and an independent thread pool; Module 11 is also used for: Based on the configuration information of the business plugin corresponding to the business identifier, determine whether the business event adopts synchronous or asynchronous processing mode; If it is a synchronous processing mode, the event listener of the business plugin 12 is directly called to execute the second business logic; If it is an asynchronous processing mode, the business events are stored in the asynchronous queue corresponding to the event bus instance, and the business events are scheduled through the thread pool corresponding to the event bus instance so that the event listener of the business plugin 12 can consume and process them.
[0098] For example, such as Figure 3 As shown, the present invention constructs a hierarchical isolated event bus submodule architecture, which includes an event bus control layer and multiple independent event bus instances corresponding to various services.
[0099] The event bus control layer implements event bus instance registration, event bus instance decommissioning, and event routing based on business codes. The event bus control layer identifies the business to which a business event belongs based on the business code, and routes the received business event to the event bus instance corresponding to the business code, thereby achieving isolation of different business events.
[0100] Each service corresponds to an independent event bus instance. For example, the customer service service corresponds to an independent customer service event bus instance, and the chat room service corresponds to an independent chat room event bus instance. After a service event is routed to the corresponding event bus instance, the corresponding processing flow is selected according to the pre-configured processing mode of the event: if the event is configured for synchronous processing mode, the synchronous event processing logic is executed directly; if the event is configured for asynchronous processing mode, the asynchronous processing flow is entered.
[0101] The asynchronous processing flow relies on the collaboration of an asynchronous queue and a thread pool. The asynchronous queue supports configuring its capacity and can be configured with an event rejection policy in case of queue saturation. The thread pool supports configuring the number of worker threads. After business events are stored in the asynchronous queue and cached, the thread pool schedules the consumption of business events in the queue, triggering the corresponding bypass business logic. This decouples the bypass business logic from the main instant messaging process, ensuring the stable operation of the main instant messaging process.
[0102] In this embodiment of the invention, the event bus submodule undertakes the one-way interaction function from the IM core layer to the business plugins. It only supports the IM core layer to push business events to the business plugins and does not provide a communication path between business plugins, thereby avoiding cross-business data flow and ensuring the operation isolation between different businesses.
[0103] In this embodiment of the invention, the event bus submodule supports two execution modes: synchronous processing mode and asynchronous processing mode. The processing mode corresponding to an event can be configured as needed within the business plugin metadata. A single event can be configured with an independent processing mode, and different events under the same business can use different processing modes. Business events can include common fields such as event identifier (ID), business code, and event context (e.g., session context, message context). Business events are only transmitted to the single business plugin corresponding to the current business code and will not spread to other business plugins, naturally blocking the communication path between plugins and ensuring that the operation of each business plugin is isolated from each other.
[0104] In this embodiment of the invention, business events include session creation events, session termination events, member joining events, and member leaving events.
[0105] SessionCreateEvent: Used to synchronize the state of business nodes in the IM core layer and notify business plugins to perform subsequent auxiliary operations. No business plugins need to return business processing results to the IM core layer. It is used to trigger the internal business process of the plugin. The subscriber is limited to the single business plugin corresponding to the current business code. The synchronous / asynchronous processing mode is configured independently for this event in the plugin metadata.
[0106] The SessionEndEvent is used to synchronize the session end node status of the IM core layer and notify business plugins to perform auxiliary operations related to session termination. It does not require business plugins to return business processing results to the IM core layer and is used to trigger internal business processes within plugins. Subscribers are limited to the single business plugin corresponding to the current business code. The synchronous / asynchronous processing mode is configured independently for this event in the plugin metadata.
[0107] The JoinSessionEvent is used to synchronize the status of the member joining session node in the IM core layer and notify the business plugin to perform related auxiliary business operations. The business plugin does not need to return the business processing result to the IM core layer. It is used to trigger the internal business process of the plugin. The subscriber is limited to the single business plugin corresponding to the current business code. The synchronous / asynchronous processing mode is configured independently for this event in the plugin metadata.
[0108] Member Exit Session Event (LeaveSessionEvent): Used to synchronize the status of the member exit session node in the IM core layer, and notify the business plugin to execute the member's related auxiliary business operations. The business plugin does not need to return the business processing result to the IM core layer. It is used to trigger the internal business process of the plugin. The subscriber is limited to the single business plugin corresponding to the current business code. The synchronous / asynchronous processing mode is configured independently for this event in the plugin metadata.
[0109] This invention uses service codes (service identifiers) as the basis for event routing and service isolation, constructing an independent event bus instance for each type of service. This achieves full-link service isolation in event generation, distribution, and consumption, ensuring that events generated by different services do not penetrate or interfere with each other. The implementation process is as follows: (1) Business plugin registration phase: Create an independent event bus instance based on the business identifier. The system loads business plugins and parses their built-in metadata to extract a unique business identifier bound to the plugin. The event bus control layer creates a corresponding event bus instance based on this business identifier and independently allocates asynchronous queues, thread pools, and rejection policy configurations for each event bus instance. The same type of business reuses the same event bus instance, while different businesses use isolated event bus instances.
[0110] (2) Event publishing phase: Perform routing and traffic splitting based on the service identifier carried in the event context. The first module generates business events in business processes such as session creation and message sending and receiving. Each business event carries an event context, which records the business identifier corresponding to the current request. The event bus control layer extracts the business identifier and only delivers the business event to the event bus instance that matches the business identifier, without forwarding the event to the event bus instances corresponding to other businesses.
[0111] (3) Event consumption phase: The business plugin only listens to the business events corresponding to its own business identifier. Each business plugin registers an event listener only with the event bus instance that matches its own business identifier; cross-business events will not flow into this event bus instance, and business plugins cannot receive events generated by other businesses, thus naturally forming business isolation at the event consumption level.
[0112] (4) Business plugin uninstallation or offline phase: release of linked resources in isolation When a business plugin is uninstalled or taken offline, the event bus instance corresponding to that business identifier is destroyed synchronously, and the system resources occupied by the asynchronous queue and thread pool are reclaimed. This resource reclamation operation will not affect the event bus instances of other businesses that are running.
[0113] In some embodiments, the first module 11 is further configured to: When loading a business plugin, obtain the configuration information of the business plugin; Perform compatibility checks on the extension point interfaces recorded in the configuration information. If the check fails, terminate the loading of the business plugin.
[0114] In the technical solution provided by this invention, when the first module loads a business plugin, it performs a compatibility check on the extension point interface based on the plugin configuration information. If the check fails, the plugin loading is terminated. This method can intercept incompatible plugins from the extension point interface in advance, preventing incompatible plugins from interfering with the main instant messaging process after registration, and ensuring the stability of the underlying instant messaging capabilities. At the same time, it avoids invalid execution of initialization operations such as event bus instance creation and listener registration, reducing unnecessary system resource consumption and enhancing system robustness.
[0115] In some embodiments, the compatibility verification includes a first verification and a second verification. Performing compatibility verification on the extension point interfaces recorded in the configuration information, and terminating the loading of the service plugin if the verification fails, includes: Perform the first verification and the second verification on the extension point interface recorded in the configuration information; If both the first and second checks are successful, the compatibility check is deemed to have passed, and the system continues to load the service plugin. If either the first or second verification fails, the compatibility verification is deemed unsuccessful, and the system terminates the loading of the service plugin.
[0116] In some embodiments, performing the first verification on the extension point interface recorded in the configuration information includes: Verify whether the extension point interface recorded in the business plugin configuration information is the first extension point interface preset by the first module; If the expansion point interface does not belong to the first expansion point interface preset by the first module, the first verification fails; if the expansion point interface belongs to the first expansion point interface preset by the first module, the first verification succeeds. Perform the second verification on the extension point interface recorded in the configuration information, including: Obtain the target implementation class in the business plugin that declares the implementation of the extension point interface; Verify whether the target implementation class fully implements all methods defined in the extension point interface; If the target implementation class does not implement the extension point interface, or if the target implementation class implements the extension point interface but has at least one of the following situations: unimplemented methods or method signatures that are inconsistent with the definition in the extension point interface, then the second verification is determined to have failed. If the target implementation class fully implements all the methods defined in the extension point interface, and the method signatures of each implementation method are consistent with the definitions in the extension point interface, then the second verification is successful.
[0117] This invention employs a two-level progressive compatibility verification mechanism. The first verification checks whether the extension point interface declared by the plugin belongs to the preset interface of the first module. The second verification checks the completeness of the plugin implementation class's implementation of the extension point interface and the consistency of its method signature. If either level of verification fails, the plugin loading is terminated. This two-level verification can intercept illegal or defective business plugins during the plugin initialization phase, preventing plugins with interface matching defects from registering in the extension point registry. This prevents runtime exceptions when the main instant messaging process executes extension point calls, ensuring the stable execution of the underlying core instant messaging business. Simultaneously, it avoids allocating system resources such as event bus instances and class loaders to incompatible plugins, reducing resource waste and effectively improving system robustness and the reliability of the hot-swappable plugin loading process.
[0118] In some embodiments, the first module 11 is further configured to: The session master state is maintained uniformly, and the session master state includes created, in session, and ended. It also generates a session context carrying a service identifier, and stores the session sub-states that are custom-managed by the service plugin corresponding to the service identifier into the session context.
[0119] In the technical solution provided by this invention, the first module uniformly maintains the general session master state and generates a session context carrying a business identifier. Business plugins can store custom session sub-states in the session context and manage them independently. The first module only carries and transmits the session sub-states; it does not parse or process them. In other words, the first module only provides the session context as a carrier to store and forward session sub-states, without reading or parsing the internal field information of the session sub-states, and cannot identify the business semantics carried by the session sub-states. Simultaneously, the execution logic of the instant messaging main process is driven solely by the session master state. The first module does not execute any business branch logic based on the session sub-states; the definition, reading, writing, and business logic processing of the session sub-states are entirely handled by the corresponding business plugins. This solution decouples the basic session state from the private business state. The first module is only responsible for session lifecycle management and does not need to adapt to the differentiated states of various businesses. Business plugins independently maintain the session sub-states corresponding to their business scenarios without intruding on or modifying the core module code. Relying on the session context, different business state data isolation is achieved, facilitating rapid expansion into various business scenarios and improving system scalability and iteration flexibility.
[0120] In some embodiments, the first module 11 assigns an independent class loader to each business plugin 12; Module 12 is also used for: When uninstalling or updating a business plugin, the event listener of the business plugin is unregistered, the event bus instance corresponding to the business identifier and the class loader corresponding to the business plugin are destroyed, and the asynchronous queue and thread pool resources corresponding to the event bus instance are released.
[0121] In this embodiment of the invention, the first module creates an independent class loader (PluginClassLoader) for each business plugin. Through a plugin-level class loading isolation mechanism, it effectively avoids problems such as conflicts between classes with the same name and dependencies between different business plugins, achieving mutual isolation between the code of each business plugin and its runtime environment, and ensuring the stability of parallel operation of multiple business plugins. At the same time, the independent class loader can be deeply bound to the plugin lifecycle, providing basic support for the complete recycling of plugin resources.
[0122] When performing a business plugin uninstallation or online upgrade, the first module first marks the corresponding business plugin as "disabled," stops accepting new business requests for that business, and blocks new business events and extension point logic calls. Based on this, the first module completes the unregistration of extension points and event listeners, destroys the independent class loader and event bus instance corresponding to the business code, and simultaneously releases system resources such as asynchronous queues and thread pools corresponding to the event bus instance.
[0123] Through the above mechanism, this invention can achieve full-link and thorough recycling of plugin-related resources in plugin uninstallation or update scenarios, fundamentally avoiding memory leaks caused by residual plugin objects. Simultaneously, the overall resource cleanup and state change operations only target the plugin and event bus instance corresponding to the target business code, without interfering with other normally operating business plugins and event bus instances within the system. This allows for secure, non-stop uninstallation and iterative upgrades of business plugins without restarting the IM core service, effectively improving the operational reliability and business iteration flexibility of the instant messaging system.
[0124] Based on the same inventive concept, this embodiment of the invention also provides a service plugin, which has built-in configuration information, including a service identifier for uniquely identifying a single service. The business plugin is configured as follows: The configuration information is provided to the first module of the instant messaging system so that the first module can complete the loading and registration of the business plugin; By adapting to the first extension point interface of the first module, the first business logic is integrated into the main instant messaging process. An event listener is provided to the first module so that the first module can register the event listener to the event bus instance corresponding to the business identifier of the business plugin; When a business event corresponding to its own business identifier is detected by the event listener, the second business logic is executed. This second business logic runs asynchronously with respect to the main instant messaging process and does not interfere with the main instant messaging process's execution state.
[0125] The business plugin provided by this invention, by embedding configuration information containing business identifiers and providing this configuration information to the first module of the instant messaging system, enables the first module to load and register the business plugins based on the business identifiers. This achieves isolated management between business plugins using the business identifiers as a unified index, ensuring that the business logic and event handling of different businesses are independent. When adding or modifying a business, only the corresponding business plugin needs to be developed and deployed, without modifying the core code of the underlying first module of the instant messaging system. This reduces platform iteration and maintenance costs and improves system scalability. The business plugin, by adapting to the first extension point interface of the first module, integrates the first business logic into the main instant messaging process, achieving decoupling between the business logic and the underlying main instant messaging process. This allows business developers to complete plugin development simply by following a unified interface specification, lowering the development threshold in multi-business scenarios. The business plugin provides an event listener to the first module, which then transmits the event listener... By registering with the event bus instance corresponding to the business identifier, the business plugin subscribes to business events corresponding to its own business identifier through event listeners. When a business event is detected, it executes a second business logic that runs asynchronously relative to the main instant messaging process and does not interfere with the main instant messaging process's running state. This separates the first business logic that is connected to the main process from the asynchronously executed second business logic. The main instant messaging process is only affected by the controllable first business logic, and the second business logic will not cause the main process to be blocked or abnormally interrupted, ensuring the operational stability of the basic instant messaging service. At the same time, the routing isolation of the event bus instance is achieved based on the business identifier. Business events are only distributed to the corresponding business plugins, avoiding redundant pushes across business events, reducing system resource consumption, and the registration and management of event listeners are uniformly completed by the first module, simplifying the development complexity of business plugins and facilitating the standardized development of various differentiated instant messaging services such as chat rooms and customer service.
[0126] In some embodiments, the extension methods defined in the first extension point interface include blocking extension methods and policy-based extension methods; the first business logic includes business verification logic and business processing logic. The business plugin is configured as follows: In response to the call initiated by the first module through the blocking extension method, the business verification logic is executed; In response to the call initiated by the first module through the strategy-based extension method, the business processing logic is executed.
[0127] This invention categorizes the extension methods defined in the first extension point interface into blocking extension methods and strategy extension methods, and correspondingly distinguishes between business verification logic and business processing logic in the first business logic. The business plugin can respond to calls initiated by the first module via blocking extension methods to execute business verification logic, and respond to calls initiated by the first module via strategy extension methods to execute business processing logic. By classifying business logic using these two types of extension methods, standardized access for different business capabilities is achieved: the business verification logic corresponding to the blocking extension methods can implement access verification, parameter verification, and other control capabilities at key nodes in the instant messaging main process, and can determine whether to continue advancing the instant messaging main process based on business needs; the business processing logic corresponding to the strategy extension methods is used to implement additional business processing without interrupting the instant messaging main process. This layered invocation mechanism standardizes the way business plugins intervene in the main instant messaging process. On the one hand, it facilitates standardized management of the first-level module's intervention permissions for business plugins in the main instant messaging process, preventing disordered modification of business logic and blocking of the main process. On the other hand, it allows business developers to choose appropriate extension methods to develop business plugins according to business needs, clearly distinguishing between validation logic with process blocking capabilities and business logic that only performs additional processing, reducing the risk of development conflicts in scenarios where multiple business plugins coexist, and improving the controllability, scalability, and development standardization of the instant messaging system.
[0128] In some embodiments, the configuration information further includes an event processing mode corresponding to the business event, wherein the event processing mode is a synchronous processing mode or an asynchronous processing mode; The business plugin is configured as follows: When the event handling mode is synchronous processing mode, the event listener receives the business events synchronously pushed by the event bus instance and executes the second business logic. When the event handling mode is asynchronous, the event listener receives business events distributed by the event bus instance through the asynchronous queue scheduling and executes the second business logic.
[0129] This invention sets the event handling mode corresponding to the business event in the configuration information of the business plugin. The event handling mode is divided into synchronous processing mode and asynchronous processing mode. When the event handling mode is synchronous, the business plugin can receive business events synchronously pushed by the event bus instance through the event listener and execute the second business logic; when the event handling mode is asynchronous, it can receive business events distributed by the event bus instance through the asynchronous queue scheduling through the event listener and execute the second business logic. Relying on the configurable dual-mode event handling mechanism, business developers can flexibly choose the event handling method according to the real-time requirements of the second business logic: for business logic that needs to closely follow the execution of the instant messaging main process and has requirements for response timing, the synchronous processing mode can be selected; for business logic that takes a long time and does not need to block the main process, the asynchronous processing mode can be selected. Both processing modes rely on the event bus instance to realize event distribution management. The first module completes the distribution path switching according to the business plugin configuration information, eliminating the need to develop two independent event scheduling frameworks for different businesses, simplifying the underlying architecture design. In asynchronous mode, business events are scheduled and executed via asynchronous queues, further decoupling time-consuming business logic from the main instant messaging process. This prevents prolonged business processing from consuming main process resources and avoids main process blockage. Synchronous mode ensures that critical business events are triggered and processed in a timely manner. Simultaneously, all business events are pushed to specific events via event bus instances bound to business identifiers. Combined with configurable event processing modes, this approach meets diverse business timing requirements while balancing system stability and business adaptability, enhancing the instant messaging system's compatibility with different types of business scenarios.
[0130] In some embodiments, the business plugin is configured as follows: Customize session sub-states; The first module can read and write the session sub-state stored in the session context through the first extension point interface.
[0131] In this embodiment of the invention, the business plugin can customize the session sub-state; when the instant messaging main process runs to a preset node, the first module calls the first extension point interface, and the business plugin takes advantage of this call opportunity to read and write the session sub-state stored in the session context to the first module through the first extension point interface; wherein the session context is created by the first module, the first module uniformly maintains the session main state, only carries and transmits the session sub-state, and does not parse or process the session sub-state.
[0132] For example, the chat room service plugin defines custom session sub-states, which include: a room mute list, a chat enable flag, a room administrator list, and announcement information. When a user initiates a chat room session, the main instant messaging flow executes to the preset node of session creation completion, and the first module calls the corresponding extension point interface. The service plugin submits the aforementioned custom session sub-states to the first module through this extension point call, and the first module receives them and writes them into the corresponding session context for storage. Subsequently, when a user joins the chat room, the main instant messaging flow runs to the preset node of member joining, and the first module calls the extension point interface corresponding to member joining, passing the session context carrying the session sub-states to the chat room service plugin. The service plugin reads the previously saved session sub-states from the session context through the first extension point interface, obtains the room mute list, and performs mute verification on the newly joined member; if the administrator updates the mute list, the service plugin can update the session sub-states and submit them to the first module again through the extension point interface, updating the data stored in the session context. When a chat room member sends a message, the main flow reaches the preset node of message distribution, and the first module calls the message extension point method, passing in the session context. The business plugin reads the global mute flag in the session sub-state to determine whether message broadcasting is allowed. When the chat room closes, the main instant messaging process runs to the preset end node of the session. The business plugin reads the session sub-state, counts the room interaction data, and completes the business cleanup. When the main session state changes to "ended," the first module can reclaim the session context resources according to the policy.
[0133] In this invention, business plugins can customize session sub-states and read / write session sub-states stored in the session context to the first module through the first extension point interface. The first module uniformly manages the main session state, only carrying and transmitting session sub-states without parsing or processing them, thus achieving hierarchical management of session states: the general main session state is uniformly maintained by the first module at the bottom layer of instant messaging, ensuring the standardized operation of the basic instant messaging process; differentiated business-specific session information, as session sub-states, is defined and maintained independently by the business plugins, adapting to the personalized state management needs of different businesses such as chat rooms and customer service. Simultaneously, the read / write operations of business plugins on session sub-states are constrained to preset nodes in the main instant messaging process, relying on the first extension point interface to complete the interaction. This prevents business plugins from arbitrarily reading and writing session data, and the first module uniformly manages the timing of session state interactions, avoiding chaotic session state read / write sequences. By uniformly carrying session sub-states through the session context, business state information can be transmitted across process nodes within the same session lifecycle, eliminating the need for business plugins to maintain session storage resources themselves, thus simplifying the development burden of business plugins. In addition, the session sub-states of different business plugins are isolated from each other. The first module distinguishes various session sub-states based on business identifiers, effectively preventing the problem of mutual interference between business states when multiple services run concurrently. While ensuring the universality of the instant messaging infrastructure, it significantly improves the system's adaptability to diverse business scenarios.
[0134] In this embodiment of the invention, the working principle of the business plugin is generally as follows: The business plugin has built-in configuration information, which includes a business identifier used to uniquely identify a single business. It can also further configure the event handling mode corresponding to the business event, which is divided into synchronous processing mode and asynchronous processing mode. During system startup, the first module scans and identifies the business plugin. The business plugin provides its own configuration information to the first module so that the first module can complete the loading and registration of the business plugin. During the loading process, the first module can perform extension point interface compatibility verification based on the configuration information. After the verification is passed, the business plugin registration is completed. The business plugin provides an event listener to the first module, which registers the event listener to an independent event bus instance that matches the business identifier. The business plugin has built-in first business logic and second business logic. The first module runs the instant messaging main process. When the main process reaches a preset node, the first module initiates a call through the first extension point interface. The first extension point interface distinguishes between blocking extension methods and strategy extension methods. The business plugin responds to the call initiated by the first module through the blocking extension method by executing business verification logic; and responds to the call initiated by the first module through the strategy extension method by executing business processing logic. The business plugin can customize session sub-states and, when the main instant messaging process reaches a preset node, read and write the session sub-states stored in the session context to the first module through the first extension point interface. The first module uniformly manages the main session state, only carrying and transmitting session sub-states, without parsing or processing them. When a business event is generated in the main instant messaging process, the first module delivers the business event to the corresponding event bus instance based on the business identifier. If the event handling mode is synchronous, the event bus instance synchronously pushes the business event, and the business plugin receives the business event through the event listener and executes the second business logic. If the event handling mode is asynchronous, the event bus instance stores the business event in an asynchronous queue, schedules and distributes the business event via a thread pool, and the business plugin receives the business event through the event listener and executes the second business logic. The second business logic runs asynchronously relative to the main instant messaging process and does not interfere with the main instant messaging process's running state, effectively isolating the business extension logic from the underlying main instant messaging process.
[0135] In this embodiment of the invention, the business plugin can adopt a hot-swappable operation mechanism, enabling dynamic loading, unloading, and upgrading of the business plugin during continuous system operation without restarting the IM core service. The business plugin can be carried out as a Java archive (JAR file), with structured configuration files and business code organized within the plugin package, as shown in the following structure: The plugin package contains a built-in META-INF directory, which stores two types of description files: MANIFEST.MF, which records basic plugin information; and im-plugin.yml, which is a self-descriptive configuration file for the plugin, used by the IM core layer to identify and load business plugins.
[0136] The plugin package contains a root directory for the plugin's business logic, which is further divided into several subdirectories to hold different functionalities: The controller directory is used to store plugin business interface classes; The service directory is used to store plugin business service classes; The extension-point directory is used to store the business implementation code corresponding to the extension point interface; The event directory is used to store code related to event listening and event handling. The config directory is used to store plugin-level business configuration content; The meta directory is used to store plugin metadata in JSON format. The metadata records core configuration information of the plugin, such as business identifiers, extension point information, and event handling strategies.
[0137] Before a business plugin is loaded, the system automatically verifies the integrity of the plugin JAR file, the validity of its signature, and the correctness of its metadata format. During plugin loading, the first module reads the plugin metadata from `im-plugin.yml` and the `meta` directory, and automatically performs initialization operations based on this metadata, including plugin identification, extension point implementation class registration, and binding event listeners to the corresponding business identifier's event bus instance. After the business plugin is loaded, the first module marks its status as "activated." From this point on, business requests carrying the corresponding business code can trigger the plugin's custom business logic for extension points and the bypass business logic corresponding to event listeners.
[0138] In this embodiment of the invention, the plugin metadata file im-plugin.yml is organized in YAML format. This file constitutes the contract file between the first module and the business plugin, carrying all the configuration information required for the initialization and operation of the business plugin. The core configuration items are described as follows: (1) Plugin basic information configuration (plugin) It records the plugin's unique identifier, plugin name, plugin version, and the bound business code; the business code is the business identifier, used for binding and matching failed business plugins with event bus instances.
[0139] (2) Extension Point Configuration This configuration declares the extension point interfaces implemented by the business plugins and their corresponding implementation classes. Each configuration entry records the fully qualified name of the extension point interface and the path of its corresponding implementation class within the plugin. When the first module loads the plugin, it automatically registers the extension points based on this configuration, allowing custom business logic to be inserted into preset nodes in the main instant messaging workflow.
[0140] (3) Event Bus Parameter Configuration (eventBus) Runtime parameters are set for asynchronous and synchronous processing modes respectively. Asynchronous configurations include asynchronous queue capacity, queue saturation rejection policy, and the core and maximum number of threads in the thread pool. Synchronous configurations include synchronous queue capacity and queue saturation rejection policy. The first module reads these parameters and completes the initialization of the event bus instance corresponding to the current business code.
[0141] (4) Event Listener Configuration This is used to declare the type of event to be listened to, the corresponding listener implementation class, and the processing mode adopted for the event. The processing mode can be configured as synchronous or asynchronous. Based on this configuration, the first module registers the event listener with the event bus instance corresponding to the same business code. When the event bus instance receives a business event, it schedules and executes the bypass business logic according to the pre-configured processing mode.
[0142] Based on the same inventive concept, embodiments of the present invention also provide a storage medium storing a computer program thereon, which, when executed by a processor, implements the functions of the instant messaging system in any of the above possible implementations.
[0143] Optionally, the storage medium may be a non-transitory computer-readable storage medium, such as a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device.
[0144] Based on the same inventive concept, embodiments of the present invention also provide a computer program product, including a computer program that, when executed by a processor, implements the functions of the instant messaging system in any of the above possible implementations.
[0145] Based on the same inventive concept, see [link to inventive concept] Figure 4 This invention also provides an electronic device, including a memory 71 (e.g., non-volatile memory), a processor 72, and a computer program stored on the memory 71 and executable on the processor 72. When the processor 72 executes the program, it implements the functions of an instant messaging system as described in any of the possible implementations above. Of course, the processor can also be used to process other data or perform calculations. This electronic device can be a PC, server, terminal, or other similar device.
[0146] like Figure 4 As shown, the electronic device may also include: memory 73, network interface 74, and internal bus 75. Other hardware may also be included besides these components, which will not be described in detail here.
[0147] It should be noted that the above-mentioned instant messaging system can be implemented by software. As a logical system, it is formed by the processor 72 of the electronic device in which it is located reading the computer program instructions stored in the non-volatile memory into the memory 73 for execution.
[0148] The embodiments of the subject matter and functional operation described in this specification can be implemented in the following ways: digital electronic circuits, tangibly embodied computer software or firmware, computer hardware including the structures disclosed in this specification and their structural equivalents, or combinations thereof. Embodiments of the subject matter described in this specification can be implemented as one or more computer programs, i.e., one or more modules of computer program instructions encoded on a tangible, non-transitory program carrier for execution by a data processing apparatus or for controlling the operation of a data processing apparatus. Alternatively or additionally, the program instructions may be encoded on artificially generated propagation signals, such as machine-generated electrical, optical, or electromagnetic signals, which are generated to encode information and transmit it to a suitable receiving device for execution by the data processing apparatus. The computer storage medium may be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or combinations thereof.
[0149] The processing and logic flow described in this specification can be executed by one or more programmable computers that execute one or more computer programs to perform corresponding functions by operating on input data and generating output. The processing and logic flow can also be executed by dedicated logic circuitry—such as FPGAs (Field-Programmable Gate Arrays) or ASICs (Application-Specific Integrated Circuits), and the device can also be implemented as dedicated logic circuitry.
[0150] Suitable computers for executing computer programs include, for example, general-purpose and / or special-purpose microprocessors, or any other type of central processing unit. Typically, the central processing unit receives instructions and data from read-only memory and / or random access memory. The basic components of a computer include a central processing unit for implementing or executing instructions and one or more memory devices for storing instructions and data. Typically, a computer will also include one or more mass storage devices for storing data, such as disks, magneto-optical disks, or optical disks, or the computer will be operatively coupled to such mass storage devices to receive data from or transfer data to them, or both. However, a computer is not required to have such devices. Furthermore, a computer can be embedded in another device, such as a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device such as a universal serial bus (USB) flash drive, to name a few.
[0151] Computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media, and memory devices, such as semiconductor memory devices (e.g., EPROM, EEPROM, and flash memory devices), magnetic disks (e.g., internal hard disks or removable disks), magneto-optical disks, and CD-ROM and DVD-ROM disks. Processors and memory may be supplemented by or incorporated into dedicated logic circuitry.
[0152] While this specification contains numerous specific implementation details, these should not be construed as limiting the scope of any invention or the scope of the claims, but rather are primarily intended to describe features of specific embodiments of a particular invention. Certain features described in the various embodiments herein may also be implemented in combination in a single embodiment. Conversely, various features described in a single embodiment may also be implemented separately in various embodiments or in any suitable sub-combination. Furthermore, while features may function in certain combinations as described above and even initially claimed in this way, one or more features from a claimed combination may be removed from that combination in some cases, and a claimed combination may refer to a sub-combination or a variation thereof.
[0153] Similarly, although the operations are depicted in a specific order in the accompanying drawings, this should not be construed as requiring these operations to be performed in the specific order shown or sequentially, or requiring all illustrated operations to be performed to achieve the desired result. In some cases, multitasking and parallel processing may be advantageous. Furthermore, the separation of various system modules and components in the above embodiments should not be construed as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product or packaged into multiple software products.
[0154] Thus, specific embodiments of the subject matter have been described. Other embodiments are within the scope of the appended claims. In some cases, the actions recited in the claims may be performed in a different order and still achieve the desired result. Furthermore, the processes depicted in the drawings are not necessarily shown in a specific order or sequence to achieve the desired result. In some implementations, multitasking and parallel processing may be advantageous.
[0155] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0156] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. An instant messaging system, characterized in that, include: A first module and at least one business plug-in that is communicatively connected to the first module; The first module includes a first expansion point interface and an event bus submodule; Each of the aforementioned service plugins corresponds to a single service. Each service plugin has built-in configuration information, which includes a service identifier used to uniquely identify the single service. The first module is used for: Obtain and parse the configuration information of each of the aforementioned business plugins, wherein the configuration information includes a business identifier; Through the first extension point interface, the first business logic corresponding to each of the business plugins is accessed into the instant messaging main process according to the configuration information. In addition, an event bus instance corresponding to each of the service identifiers is created through the event bus submodule, and the event listener of each service plugin is registered to the event bus instance corresponding to its own service identifier, so as to distribute the service event to the corresponding event bus instance according to the service identifier; The business plugin is used for: By adapting the first extension point interface, the first business logic is integrated into the main instant messaging process. Additionally, it subscribes to business events corresponding to its own business identifier through an event listener, and triggers the execution of the second business logic when the business event is listened to; The second business logic is a post-processing logic that is executed asynchronously relative to the main instant messaging process and does not interfere with the running state of the main instant messaging process.
2. The system according to claim 1, characterized in that, The configuration information also includes the event processing mode corresponding to each business event, which is either a synchronous processing mode or an asynchronous processing mode; each event bus instance is equipped with an asynchronous queue and an independent thread pool. The first module is also used for: Based on the configuration information of the business plugin corresponding to the business identifier, determine whether the business event adopts synchronous or asynchronous processing mode; If it is a synchronous processing mode, the event listener of the business plugin is directly called to execute the second business logic; In asynchronous processing mode, business events are stored in the asynchronous queue corresponding to the event bus instance, and the business events are scheduled through the thread pool corresponding to the event bus instance so that the event listener of the business plugin can consume and process them.
3. The system according to claim 1, characterized in that, The first module is also used for: When loading a business plugin, obtain the configuration information of the business plugin; Perform compatibility checks on the extension point interfaces recorded in the configuration information. If the check fails, terminate the loading of the business plugin.
4. The system according to claim 3, characterized in that, The compatibility check includes a first check and a second check. The compatibility check is performed on the extension point interfaces recorded in the configuration information. If the check fails, loading the service plugin is terminated. This includes: Perform the first verification and the second verification on the extension point interface recorded in the configuration information; If both the first and second checks are successful, the compatibility check is deemed to have passed, and the system continues to load the service plugin. If either the first or second verification fails, the compatibility verification is deemed unsuccessful, and the system terminates the loading of the service plugin.
5. The system according to claim 4, characterized in that, Perform the first verification on the extension point interface recorded in the configuration information, including: Verify whether the extension point interface recorded in the business plugin configuration information is the first extension point interface preset by the first module; If the expansion point interface does not belong to the first expansion point interface preset by the first module, the first verification fails; if the expansion point interface belongs to the first expansion point interface preset by the first module, the first verification succeeds. Perform the second verification on the extension point interface recorded in the configuration information, including: Obtain the target implementation class in the business plugin that declares the implementation of the extension point interface; Verify whether the target implementation class fully implements all methods defined in the extension point interface; If the target implementation class does not implement the extension point interface, or if the target implementation class implements the extension point interface but has at least one of the following situations: unimplemented methods or method signatures that are inconsistent with the definition in the extension point interface, then the second verification is determined to have failed. If the target implementation class fully implements all the methods defined in the extension point interface, and the method signatures of each implementation method are consistent with the definitions in the extension point interface, then the second verification is successful.
6. The system according to claim 1, characterized in that, The first module assigns an independent class loader to each business plugin; The first module is also used for: When uninstalling or updating a business plugin, the event listener of the business plugin is unregistered, the event bus instance corresponding to the business identifier and the class loader corresponding to the business plugin are destroyed, and the asynchronous queue and thread pool resources corresponding to the event bus instance are released.
7. The system according to claim 1, characterized in that, At least one extension method is defined in the first extension point interface; The first module is also used for: When the instant messaging main process of the business corresponding to the business identifier reaches the preset node, the extension method of the first extension point interface is called to execute the first business logic in the business plugin corresponding to the business identifier.
8. The system according to claim 1, characterized in that, The first module is also used for: The session master state is maintained uniformly, and the session master state includes created, in session, and ended. It also generates a session context carrying a service identifier, and stores the session sub-states that are custom-managed by the service plugin corresponding to the service identifier into the session context.
9. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the functions of the instant messaging system according to any one of claims 1-8.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the functions of the instant messaging system according to any one of claims 1-8.
11. A business plugin, characterized in that, The service plugin has built-in configuration information, which includes a service identifier used to uniquely identify a single service. The business plugin is configured as follows: The configuration information is provided to the first module of the instant messaging system so that the first module can complete the loading and registration of the business plugin; By adapting to the first extension point interface of the first module, the first business logic is integrated into the main instant messaging process. An event listener is provided to the first module so that the first module can register the event listener to the event bus instance corresponding to the business identifier of the business plugin; When a business event corresponding to its own business identifier is detected by the event listener, the second business logic is executed.
12. The business plugin according to claim 11, characterized in that, The extension methods defined in the first extension point interface include blocking extension methods and policy-based extension methods; the first business logic includes business verification logic and business processing logic; The business plugin is configured as follows: In response to the call initiated by the first module through the blocking extension method, the business verification logic is executed; In response to the call initiated by the first module through the strategy-based extension method, the business processing logic is executed.
13. The business plugin according to claim 11, characterized in that, The configuration information also includes the event processing mode corresponding to the business event, wherein the event processing mode is either synchronous processing mode or asynchronous processing mode; The business plugin is configured as follows: When the event handling mode is synchronous processing mode, the event listener receives the business events synchronously pushed by the event bus instance and executes the second business logic. When the event handling mode is asynchronous, the event listener receives business events distributed by the event bus instance through the asynchronous queue scheduling and executes the second business logic.
14. The business plugin according to claim 11, characterized in that, The business plugin is configured as follows: Customize session sub-states; The first module can read and write the session sub-state stored in the session context through the first extension point interface.
