Disclosure of Invention
The present invention provides a message push method and system with multi-port adaptation for solving the above problems in the prior art.
The technical solution for realizing the purpose of the invention is as follows: a message push method with multi-port adaptation, the method comprising the steps of:
encapsulating various messengers in a PAAS service, and recording the PAAS service as a unified message push service; the messenger is a message pushing mode or component;
the unified message push service receives a message sending request of the business application and pushes a message corresponding to the request to a receiving party of different types of terminals.
Further, the encapsulating of multiple messengers in one PAAS service includes the specific process:
constructing a plurality of messenger combinations, each combination including one or more messengers;
constructing a plurality of message channels, wherein each message channel comprises one or more messenger combinations;
and encapsulating the plurality of message channels in PAAS service.
Further, encapsulating multiple messengers in one PAAS service further includes:
constructing a plurality of uniform message templates;
constructing a mapping template between the unified message template and each messenger message template;
establishing mapping relations among all unified message templates, all mapping templates and all messenger message templates;
and encapsulating the unified message template, the mapping template, each messenger message template and the mapping relation in PAAS service.
Further, the pushing of the message corresponding to the request to the receiving sides of the different types of terminals includes the following specific processes:
the unified message pushing service acquires message parameters in the message sending request, wherein the message parameters comprise message content, an appointed message channel, a unified message template and a receiver;
the unified message pushing service starts the appointed message channel and pushes the message content to a receiving party through the appointed message channel; in the process, aiming at the messenger in the appointed message channel, the unified message pushing service converts the unified message template into each messenger message template through the mapping template according to the mapping relation.
Further, the method further comprises:
and storing the message into a message database while pushing the message corresponding to the request to the receivers of different types of terminals.
Further, the method further comprises:
judging the state of the receiver when receiving the message, if the state is the online state, marking the state of the message in the message database as online receiving; if the message is in the offline state, the state of the message in the message database is marked as offline receiving.
Further, the method further comprises:
the unified message pushing service receives a self-defined messenger registration request of the service application and adds a messenger self-defined by the service application to the unified message pushing service through a messenger interface defined by the unified message pushing service.
A message push system with multi-port adaptation, the system comprising:
the unified message pushing service construction module is used for encapsulating various messengers in one PAAS service to form unified message pushing service; the messenger is a message pushing mode or component;
and the message sending module is used for receiving a message sending request of the service application and triggering the unified message pushing service to push the message corresponding to the request to the receiving sides of different types of terminals.
Further, the system further comprises a storage module, configured to store the message in a message database while the unified message push service pushes the message corresponding to the message sending request to the recipients of different types of terminals;
the system also comprises an information marking module which is used for judging the state when the receiver receives the message, and if the state is the online state, marking the state of the message in the message database as online receiving; if the message is in the offline state, the state of the message in the message database is marked as offline receiving.
Further, the system also comprises a messenger registration module used for receiving a self-defined messenger registration request of the business application, and the unified message push service adds the messenger self-defined by the business application to the unified message push service through a messenger interface defined by the unified message push service.
A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
encapsulating various messengers in a PAAS service, and recording the service as a unified message push service; the messenger is a message pushing mode or component;
the unified message push service receives a message sending request of the business application and pushes a message corresponding to the request to a receiving party of different types of terminals.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
encapsulating various messengers in a PAAS service, and recording the PAAS service as a unified message push service; the messenger is a message pushing mode or component;
the unified message push service receives a message sending request of the business application and pushes a message corresponding to the request to a receiving party of different types of terminals.
Compared with the prior art, the invention has the remarkable advantages that: 1) The message pushing is more flexible. Compared with the traditional message pushing mode, the invention allows the application developer to add own message pushing, can establish a message channel and freely combine different messengers, and provides a flexible mode to allow the user to define the message sending mode by himself. 2) Maintainability is enhanced. In the invention, hard coding is avoided, and the message is pushed and encapsulated into a PAAS service, so that when modification or service expansion is required, an application developer defines new messenger implementation in own application project without recompiling and deploying a push service program package. 3) The compatibility is higher. The invention provides a message template, meets the requirements of an Internet short message platform such as subscription message, ali, tencent, baidu and the like of a WeChat applet, and can send messages to a plurality of different types of terminals in one message pushing process.
The present invention is described in further detail below with reference to the attached drawing figures.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
In one embodiment, in conjunction with fig. 1 and 2, there is provided a message pushing method for multi-port adaptation, the method comprising the steps of:
step S01, encapsulating various messengers in a PAAS service, and recording the service as a unified message push service; the messenger is a message pushing mode or component;
here, the messenger includes a short message, a mail, a WeChat, and socket.
And step S02, the unified message pushing service receives a message sending request of the service application and pushes the message corresponding to the request to receivers of different types of terminals.
Further, in one embodiment, the step S01 encapsulates multiple messengers into one PAAS service, and the specific process includes:
step S011, constructing a plurality of messenger combinations, wherein each combination comprises one or more messengers;
step S012, constructing a plurality of message channels, wherein each message channel comprises one or a plurality of messenger combinations;
illustratively, for example, the A channel sends messages by using a short message platform messenger and a mail platform messenger, and the B channel sends messages by using a WeChat applet messenger and socket.
Step S013, encapsulating said multiple message channels in PAAS service.
By adopting the scheme of the embodiment, different messengers can be freely combined, a plurality of message channels with different messenger combinations can be created, a plurality of different message combination sending modes can be realized, a flexible mode is provided, a user is allowed to define the sending mode of the message by himself, hard coding in a code is avoided, and the maintainability of the system is enhanced.
Further, in one embodiment, with reference to fig. 3, step S01 encapsulates multiple messengers in one PAAS service, and the specific process further includes:
step S014, constructing a plurality of unified message templates;
step S015, constructing a mapping template between the unified message template and each messenger message template;
step S016, establishing the mapping relation among all unified message templates, all mapping templates and all messenger message templates;
and S017, packaging the unified message template, the mapping template, each messenger message template and the mapping relation in PAAS service.
The scheme of the embodiment is adopted, so that the template functions of some messengers (some messengers can use the message template to limit the message sending content, such as the subscription message of the WeChat applet, the Internet short message platforms of Ali, tencent, baidu and the like) are compatible, a uniform template is provided for the message templates from different messengers, and the compatibility and the universality of the method are improved.
Further, in one embodiment, in step S02, the pushing the message corresponding to the request to the receiving party of the different types of terminals includes:
step S021, the unified message pushing service acquires message parameters in the message sending request, wherein the message parameters comprise message content, a designated message channel, a unified message template and a receiver;
here, the message parameters further include ID, title and data attribute of the message, the ID is a unique number of the message, and the data is a key-value pair list for replacing placeholders in the message template to generate final message content and link path.
Step S022, the unified message push service starts the appointed message channel and pushes the message content to a receiver through the appointed message channel; in this process, with reference to fig. 3, for the messenger in the specified message channel, the unified message push service converts the unified message template into each messenger message template through the mapping template according to the mapping relationship.
Further, in one embodiment, the method further comprises:
and S03, pushing the message corresponding to the request to the receivers of the different types of terminals, and storing the message into a message database.
By adopting the scheme of the embodiment, the historical information is convenient to trace.
Further, in one embodiment, the method further comprises:
step S04, judging the state of the receiver when receiving the message, if the state is the online state, marking the state of the message in the message database as online receiving; if the message is in the offline state, the state of the message in the message database is marked as offline receiving.
By adopting the scheme of the embodiment, the message state can be checked in real time.
Here, the steps S02, S03, and S04 are not limited to the above sequential execution, and may be executed in synchronization.
Further, in one embodiment, the method further comprises:
and step S05, the unified message pushing service receives the self-defined messenger registration request of the service application and adds the messenger self-defined by the service application to the unified message pushing service through a messenger interface defined by the unified message pushing service.
By adopting the scheme of the embodiment, an extension mechanism is provided, so that an application developer is allowed to define new messenger implementation in own application project without recompiling and deploying a platform unified service push service program package. An application developer can define messenger implementation service classes in its own application and develop its REST API interface. Extended service messengers may also be added to the message channel for use.
As a specific example, in one embodiment, the multi-port adapted message pushing of the present invention is further described:
with reference to fig. 4, the push service is built based on a socket.io open source framework (MIT open source protocol) of NodeJs, and is responsible for maintaining long connection with the client, subscribing to message events of the message queue, and forwarding messages of the message queue forward.
The message push implementation mode in the system of the B/S framework is mainly kept in long connection with a server side in a browser WebSocket mode or a LongPoll mode and the like. In an elastic computing architecture of a platform, a browser of a user is kept connected with a Pod of an API gateway, a plurality of API gateways Pod exist in a cluster, and a back-end application service cannot know which Pod the browser of the user is connected to and directly send a message, so that a message queue middleware is needed. All API gateway Pod subscribe the message on the message queue, the back-end application service sends the message to the message queue, triggers the subscription event, informs the API gateway Pod, the API gateway Pod inquires whether the long connection with the target user exists, and if so, the message is pushed to the front end.
The in-station socket and IO push service supports multi-application multi-session multi-channel message push, a Namespace (Namespace) is allocated to each application inside the socket and IO service, and different sessions from the same user are classified into the same Room (Room) under the Namespace. Messages are sent in units of namespace + room, pushed to the terminal browser connected for each session in the room, as shown in fig. 5.
In one embodiment, in conjunction with fig. 6, there is provided a multi-port adapted message pushing system, the system comprising:
the unified message pushing service construction module is used for encapsulating various messengers in one PAAS service to form unified message pushing service; the messenger is a message pushing mode or component;
and the message sending module is used for receiving a message sending request of the service application and triggering the unified message pushing service to push the message corresponding to the request to the receiving sides of different types of terminals.
Further, in one embodiment, the system further includes a storage module, configured to store the message in a message database while the unified message push service pushes the message corresponding to the message sending request to the recipients of different types of terminals.
Further, in one embodiment, the system further includes an information marking module, configured to determine a state when the receiving party receives the message, and mark the state of the message in the message database as online reception if the state is online; if the message is in the offline state, the state of the message in the message database is marked as offline receiving.
Further, in one embodiment, the system further includes a messenger registration module, configured to receive a customized messenger registration request of the service application, where the unified message push service adds a messenger customized to the service application to the unified message push service through a messenger interface defined by the unified message push service.
For specific limitations of the multi-end adapted message pushing system, reference may be made to the above limitations on the multi-end adapted message pushing method, which is not described in detail herein. All or part of the modules in the message pushing system with multi-terminal adaptation can be realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
encapsulating various messengers in a PAAS service, and recording the PAAS service as a unified message push service; the messenger is a message pushing mode or component;
the unified message push service receives a message sending request of the business application and pushes a message corresponding to the request to a receiving party of different types of terminals.
Further, in one embodiment, the processor, when executing the computer program, further performs the following steps:
and storing the message into a message database while pushing the message corresponding to the request to the receivers of the different types of terminals.
Further, in one embodiment, the processor when executing the computer program further performs the steps of:
judging the state of the receiver when receiving the message, if the state is the online state, marking the state of the message in the message database as online receiving; if the message is in the offline state, the state of the message in the message database is marked as offline receiving.
Further, in one embodiment, the processor, when executing the computer program, further performs the following steps:
the unified message pushing service receives a self-defined messenger registration request of the service application and adds a messenger self-defined by the service application to the unified message pushing service through a messenger interface defined by the unified message pushing service.
For specific definition description of each step, reference may be made to the above definition of the message pushing method for multi-port adaptation, which is not described herein again.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
encapsulating various messengers in a PAAS service, and recording the service as a unified message push service; the messenger is a message pushing mode or component;
the unified message push service receives a message sending request of the business application and pushes a message corresponding to the request to a receiving party of different types of terminals.
Further, in one embodiment, the computer program when executed by the processor further performs the steps of:
and storing the message into a message database while pushing the message corresponding to the request to the receivers of different types of terminals.
Further, in one embodiment, the computer program when executed by the processor further performs the steps of:
judging the state of the receiver when receiving the message, if the state is the online state, marking the state of the message in the message database as online receiving; if the message is in the offline state, the state of the message in the message database is marked as offline receiving.
Further, in one of the embodiments, the computer program when executed by the processor further performs the steps of:
the unified message push service receives a self-defined messenger registration request of the business application and adds a messenger self-defined by the business application to the unified message push service through a messenger interface defined by the unified message push service.
For the specific definition description of each step, reference may be made to the above definition of the message pushing method for multi-port adaptation, which is not described in detail herein.
The invention encapsulates various message pushing modes into one PAAS service according to the requirement and the current situation of application message pushing, and provides a unified instant message pushing service facing different types of terminals. The application system can push the notification message to users of different types of terminals in different modes at one time through the message push service, and meanwhile, the invention provides a message push extension mechanism to allow an application developer to add the message notification mode of the application developer without recompiling and deploying a push service program package, thereby avoiding hard coding. In conclusion, the invention has the advantages of more flexible message pushing, enhanced maintainability, higher compatibility and the like.
The foregoing illustrates and describes the principles, general features, and advantages of the present invention. It will be understood by those skilled in the art that the present invention is not limited to the embodiments described above, which are described in the specification and illustrated only to illustrate the principle of the present invention, but that various changes and modifications may be made therein without departing from the spirit and scope of the present invention, which fall within the scope of the invention as claimed. The scope of the invention is defined by the appended claims and equivalents thereof.