Detailed Description
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used may be interchanged under appropriate circumstances in order to facilitate the description of the embodiments of the application herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
According to an embodiment of the application, a message pushing method is provided.
Fig. 1 is a flowchart of a message pushing method according to an embodiment of the present application. As shown in fig. 1, the method comprises the steps of:
step S101, a plurality of instances deployed by a server are adopted to poll messages in a message library respectively, and the message start time of the target message and the message end time of the target message are obtained.
It should be noted that polling refers to that an instance of a server periodically queries a target object according to a time period. The server is a message push server deployed with multiple instances, each of which can push messages in a message library for users accessing the instance. The polling behaviors of the instances are independent, and the instances periodically query the messages in the message library according to the polling time periods of the instances.
For example, after an instance in the message server pushes the announcement, the announcement is broadcasted within the start and stop time period of the announcement, and the user can view the announcement content within the start and stop time period of the announcement.
Step S102, when the current polling time of the target instance is in a closed interval formed by the message start time of the target message and the message end time of the target message, judging whether the target message is polled by the target instance.
It should be noted that, when the current query time of the target instance is later than the end time of the target message, the message is indicated as a history message and does not need to be pushed again; when the current query time of the target instance is earlier than the end time of the target message, the message is a message to be pushed in the future and does not need to be pushed currently; when the current query time of the target instance falls between the message start time and the message end time of the target message, it is indicated that the message may be a message to be currently pushed, if the current query time of the target instance is the same as the message start time, a user can view the content broadcasted by the message within the duration of the message after pushing, and if the current query time of the target instance is close to the message end time, the user can view the message content within a short time after pushing.
In addition, when the polling time interval of the target instance is shorter than the length of the closed interval formed by the message start time and the message end time, for example, the polling interval is 10 minutes, the message start time is 10:30, the message end time is 11:00, the current polling time is 10:45, and the last polling time is 10:35, there is a case that the message queried by the target instance has already been pushed by the instance, and therefore, whether the target instance pushes the message needs to determine whether the message has already been queried by the target instance and pushed.
In order to prevent the target server from repeatedly pushing the same message, optionally, in the message pushing method provided in the embodiment of the present application, the determining whether the target message is polled by the target instance includes: judging whether the starting time of the target message is later than the last polling ending time of the target instance or not; and in the case that the starting time of the target message is later than the last polling ending time of the target instance, determining that the target message is not polled by the target instance.
For example, when the target instance queries the message in the message library each time, the last query time is recorded, and if the message start time of the target message is earlier than the last polling end time of the target instance, it indicates that the duration of the message is longer, and the message is queried and pushed by the target instance and does not need to be pushed again; if the message start time of the target message is later than the last polling end time of the target instance, the message is a message to be pushed in the future for the last polling, and the message is not pushed.
Step S103, under the condition that the target message is not polled by the target instance, determining that the target message is a message to be pushed of the target instance.
It should be noted that, in the case that the target message is not polled by the target instance, the target message is not pushed by the target instance, and the target message is determined to be the current message to be pushed of the target instance.
By the embodiment, whether one message is the message to be pushed of the target instance is marked by the polling time of the target instance, the message start time of the target message and the message end time, so that repeated pushing of the same instance cannot be caused.
Optionally, in the message pushing method provided in the embodiment of the present application, after determining that the target message is a to-be-pushed message of the target instance, the method further includes: and the target instance pushes the message to be pushed to the user.
Specifically, the target instance pushes a marked message to be pushed, and a user accessing the target instance will view the message during the existence period of the message to acquire the content of the message.
According to the message pushing method provided by the embodiment of the application, the messages in the message library are respectively polled by adopting a plurality of instances deployed by the server, and the message starting time of the target message and the message ending time of the target message are obtained; when the current polling time of the target instance is in a closed interval formed by the message starting time of the target message and the message ending time of the target message, judging whether the target message is polled by the target instance; the method and the device for the server instance to push the message solve the problem that in the prior art, the server instance pushes the message, namely modifies the field of the message, and identify whether the message is pushed or not by the field of the message, so that message pushing omission easily occurs for a server deployed by multiple instances. Whether each message is pushed is respectively judged by judging the relation among the polling time of each instance, the message starting time of the message and the message ending time of the message, so that the effects of multi-instance polling deployed by a server and pushing the message in a message library can be achieved without pushing omission.
Optionally, in the message pushing method provided in this embodiment of the present application, before the multiple instances deployed by the server respectively poll the messages in the message library, the method further includes: setting a message start time and a message end time for a plurality of messages; and storing the message with the message starting time and the message ending time into a message library.
It should be noted that the message start time and the message end time of each message may be preset, and different messages have different contents, different importance, different timeliness, different audience groups, and different message start time and message end time settings.
For example, for a planned message, the message content is stable, and a longer duration time can be set, for a monthly plan, the message start time can be set to the beginning of the month, and the message end time can be set to the end of the month; for messages with stronger timeliness, the duration is shorter, for example, the weather forecast of the day, and the ending time of the message is the end of the day.
And storing the message with the message starting time and the message ending time into a message library, and pushing the message when the server polls.
In order to prevent missing a message to be pushed when a server instance pushes a message, optionally, in the message pushing method provided in the embodiment of the present application, before a plurality of instances deployed by the server respectively poll messages in a message library, the method further includes: and respectively setting a polling interval time for a plurality of instances, wherein the polling interval time is an interval time between the end time of one polling and the start time of the next polling, the maximum value of the polling intervals of the plurality of instances is less than the minimum value of the duration of the messages in the message library, and the duration of the messages is the difference between the end time of the messages and the start time of the messages.
It should be noted that, if the duration of the message is short and the polling time interval is long, and there is a situation that the message start time and the message end time of the message are located in the same polling interval, it is easy to cause missing of the example to query the message, and thus missing of pushing the message, so after the message with the set message start time and message end time is stored in the message library, the polling interval of each example is set according to the duration of the message in the message library, the polling interval is set to be at least shorter than the minimum of the duration of the message, for the timely pushing of the message, the polling time can be set to be as short as possible, and at the same time, resources occupied by polling are considered, and a proper polling time is set.
For example, the minimum value of the duration of the message is 5 minutes, for the example with large user access, the polling interval may be set to be every minute, the example queries the message in the message library every minute, and for the example with small user access, the polling interval may be set to be two minutes for reasonable configuration of resources.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowcharts, in some cases, the steps illustrated or described may be performed in an order different than here.
The embodiment of the present application further provides a message pushing apparatus, and it should be noted that the message pushing apparatus in the embodiment of the present application may be used to execute the method for pushing a message provided in the embodiment of the present application. The following describes a message pushing apparatus according to an embodiment of the present application.
Fig. 2 is a schematic diagram of a message pushing apparatus according to an embodiment of the present application. As shown in fig. 2, the apparatus includes: an acquisition unit 10, a judgment unit 20 and a determination unit 30.
Specifically, the obtaining unit 10 is configured to separately poll messages in a message library by using multiple instances deployed by a server, and obtain a message start time of a target message and a message end time of the target message;
a judging unit 20, configured to judge whether the target message has been polled by the target instance when the current polling time of the target instance falls within a closed interval formed by the message start time of the target message and the message end time of the target message;
the determining unit 30 is configured to determine that the target message is a to-be-pushed message of the target instance when the target message is not polled by the target instance.
Optionally, in the message pushing apparatus provided in the embodiment of the present application, the determining unit 20 includes: the judging module is used for judging whether the starting time of the target message is later than the last polling ending time of the target instance; and the determining module is used for determining that the target message is not polled by the target instance under the condition that the starting time of the target message is later than the last polling ending time of the target instance.
Optionally, in the message pushing apparatus provided in the embodiment of the present application, the apparatus further includes: a first setting unit, configured to set a message start time and a message end time for a plurality of messages before the plurality of instances deployed by the server poll messages in the message library, respectively; and the storage unit is used for storing the message with the set message starting time and the set message ending time into the message library.
Optionally, in the message pushing apparatus provided in the embodiment of the present application, the apparatus further includes: the first setting unit is used for respectively setting polling interval time for a plurality of instances before the plurality of instances deployed by the server respectively poll the messages in the message base, wherein the polling interval time is the interval time between the end time of one polling and the start time of the next polling, the maximum value of the polling intervals of the plurality of instances is smaller than the minimum value of the duration of the messages in the message base, and the duration of the messages is the difference value between the end time of the messages and the start time of the messages.
Optionally, in the message pushing apparatus provided in the embodiment of the present application, the apparatus further includes: and the pushing unit is used for pushing the message to be pushed to the user by the target instance after the target message is determined to be the message to be pushed of the target instance.
In the message pushing apparatus provided in the embodiment of the present application, the obtaining unit 10 uses multiple instances deployed by a server to respectively poll messages in a message library, and obtains a message start time of a target message and a message end time of the target message; when the current polling time of the target instance falls within a closed interval formed by the message start time of the target message and the message end time of the target message, the judging unit 20 judges whether the target message is polled by the target instance; the determining unit 30 determines that the target message is a to-be-pushed message of the target instance when the target message is not polled by the target instance, so that a problem that a server instance in the related art pushes the message, that is, modifies a field of the message, and determines whether the message is pushed or not by using the field of the message, for a server deployed in multiple instances, message pushing omission easily occurs, and determines whether each message is pushed or not by determining relationships among polling time of each instance, message start time of the message, and message end time of the message, so that an effect that the pushing omission is not generated when the server deployed polls the multiple instances and pushes the message in the message library is achieved.
The message pushing device comprises a processor and a memory, wherein the acquiring unit 10, the judging unit 20, the determining unit 30 and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can set one or more than one, the problem that in the related technology, the server instance pushes the message, namely, the field of the message is modified, is solved by adjusting the kernel parameters, and the problem that the message pushing omission easily occurs for the server deployed by multiple instances is solved by identifying whether the message is pushed or not by the field of the message.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
An embodiment of the present invention provides a storage medium on which a program is stored, and the program implements the message push method when executed by a processor.
The embodiment of the invention provides a processor, which is used for running a program, wherein the message pushing method is executed when the program runs.
The embodiment of the invention provides equipment, which comprises a processor, a memory and a program which is stored on the memory and can run on the processor, wherein the processor executes the program and realizes the following steps: polling messages in a message library respectively by adopting a plurality of instances deployed by a server to acquire message start time of a target message and message end time of the target message; when the current polling time of the target instance is in a closed interval formed by the message starting time of the target message and the message ending time of the target message, judging whether the target message is polled by the target instance; and under the condition that the target message is not polled by the target instance, determining that the target message is a message to be pushed of the target instance.
Determining whether the target message was polled by the target instance comprises: judging whether the starting time of the target message is later than the last polling ending time of the target instance or not; and in the case that the starting time of the target message is later than the last polling ending time of the target instance, determining that the target message is not polled by the target instance.
Before the plurality of instances of the server deployment individually poll the messages within the message library, the method further comprises: setting a message start time and a message end time for a plurality of messages; and storing the message with the message starting time and the message ending time into a message library.
Before the plurality of instances of the server deployment individually poll the messages within the message library, the method further comprises: and respectively setting a polling interval time for a plurality of instances, wherein the polling interval time is an interval time between the end time of one polling and the start time of the next polling, the maximum value of the polling intervals of the plurality of instances is less than the minimum value of the duration of the messages in the message library, and the duration of the messages is the difference between the end time of the messages and the start time of the messages.
After determining that the target message is a message to be pushed of the target instance, the method further includes: and the target instance pushes the message to be pushed to the user. The device herein may be a server, a PC, a PAD, a mobile phone, etc.
The present application further provides a computer program product adapted to perform a program for initializing the following method steps when executed on a data processing device: polling messages in a message library respectively by adopting a plurality of instances deployed by a server to acquire message start time of a target message and message end time of the target message; when the current polling time of the target instance is in a closed interval formed by the message starting time of the target message and the message ending time of the target message, judging whether the target message is polled by the target instance; and under the condition that the target message is not polled by the target instance, determining that the target message is a message to be pushed of the target instance.
Determining whether the target message was polled by the target instance comprises: judging whether the starting time of the target message is later than the last polling ending time of the target instance or not; and in the case that the starting time of the target message is later than the last polling ending time of the target instance, determining that the target message is not polled by the target instance.
Before the plurality of instances of the server deployment individually poll the messages within the message library, the method further comprises: setting a message start time and a message end time for a plurality of messages; and storing the message with the message starting time and the message ending time into a message library.
Before the plurality of instances of the server deployment individually poll the messages within the message library, the method further comprises: and respectively setting a polling interval time for a plurality of instances, wherein the polling interval time is an interval time between the end time of one polling and the start time of the next polling, the maximum value of the polling intervals of the plurality of instances is less than the minimum value of the duration of the messages in the message library, and the duration of the messages is the difference between the end time of the messages and the start time of the messages.
After determining that the target message is a message to be pushed of the target instance, the method further includes: and the target instance pushes the message to be pushed to the user.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.