CN106201705B - Handle the method and device of message - Google Patents
Handle the method and device of message Download PDFInfo
- Publication number
- CN106201705B CN106201705B CN201610589516.3A CN201610589516A CN106201705B CN 106201705 B CN106201705 B CN 106201705B CN 201610589516 A CN201610589516 A CN 201610589516A CN 106201705 B CN106201705 B CN 106201705B
- Authority
- CN
- China
- Prior art keywords
- message
- queue
- added
- message queue
- receiving
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L51/00—User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
- H04L51/21—Monitoring or handling of messages
- H04L51/214—Monitoring or handling of messages using selective forwarding
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Telephonic Communication Services (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
The invention discloses a kind of method and devices for handling message.The method is applied to mobile client, which comprises when receiving the first message of server transmission, the first message is added in first message queue, corresponding first single thread of the first message queue;When receiving the second message that the server is sent, the second message is added in second message queue, the second message queue is different from the first message queue, corresponding second single thread of the second message queue;Utilize first message and the second message described in first single thread and the second single thread parallel processing.Using this method, the processing capacity of CPU can be maximally utilized, improves the efficiency of processing message.
Description
Technical field
The present invention relates to fields of communication technology, and in particular, to a kind of method and device for handling message.
Background technique
With the development of communication technology, the interacting message between mobile client and server is more and more frequent.Related skill
In art, server pushes each message to mobile client, and mobile client is successively located according to the sequencing for receiving message
Each message is managed, finally reports processing result to server.
Since mobile client is successively handled the message received according to the sequencing for receiving message, so
Treatment effeciency is lower, cannot maximally utilize CPU (Chinese: central processing unit;English: Central Process Unit) place
Reason ability.
Summary of the invention
The object of the present invention is to provide a kind of method and devices for handling message, to maximally utilize the processing capacity of CPU.
To achieve the goals above, the present invention provides a kind of method for handling message, which is characterized in that is applied to mobile visitor
Family end, which comprises
When receiving the first message of server transmission, the first message is added in first message queue, institute
State corresponding first single thread of first message queue;
When receiving the second message that the server is sent, the second message is added to second message queue
In, the second message queue is different from the first message queue, corresponding second single thread of the second message queue;
Utilize first message and the second message described in first single thread and the second single thread parallel processing.
Optionally, described when receiving the second message that the server is sent, the second message is added to the
In two message queues, comprising:
When receiving the second message that the server is sent, determine between the second message and the first message
Processing sequence demand be random sequence;
The second message is added in the second message queue.
Optionally, the method also includes:
When receiving the second message that the server is sent, determine between the second message and the first message
Processing sequence demand be preset order, the preset order be the first message handled prior to the second message;
The second message is added in the first message queue.
Optionally, it is described the first message is added in first message queue after, the method also includes:
The mapping relations between the first message and the first message queue are established, the mapping relations include described
Preset order.
Optionally, it is described the second message is added in the first message queue after, the method is also wrapped
It includes:
By the mapping relations by being updated to the second message between the first message and the first message queue
Between the first message queue.
The present invention also provides a kind of devices for handling message, are configured at mobile client, described device includes:
First adding module, for when receiving the first message of server transmission, the first message to be added to
In first message queue, corresponding first single thread of the first message queue;
Second adding module, for when receiving the second message that the server is sent, the second message to be added
It is added in second message queue, the second message queue is different from the first message queue, the second message queue pair
Answer the second single thread;
Processing module, for using first message described in the first thread pond and the second thread pool parallel processing and
The second message.
Optionally, second adding module includes:
Determine submodule, for when receiving the second message that the server is sent, determine the second message with
Processing sequence demand between the first message is random sequence;
Submodule is added, for the second message to be added in the second message queue.
Optionally, described device further include:
Determining module, for determining the second message and institute when receiving the second message that the server is sent
Stating the processing sequence demand between first message is preset order, and the preset order is the first message prior to described second
Message Processing;
Third adding module, for the second message to be added in the first message queue.
Optionally, described device further include:
Establish module, for it is described the first message is added in first message queue after, establish described
Mapping relations between one message and the first message queue, the mapping relations include the preset order.
Optionally, described device further include:
Update module, for it is described the second message is added in the first message queue after, will be described
Mapping relations are by being updated to the second message and the first message between the first message and the first message queue
Between queue.
Through the above technical solutions, be respectively stored into message is received in different message queues, then each message
A corresponding single thread, using multiple multiple message of single thread parallel processing, therefore, multiple message are processed simultaneously, realize
The processing capacity for maximally utilizing CPU improves the efficiency of processing message.
Other features and advantages of the present invention will the following detailed description will be given in the detailed implementation section.
Detailed description of the invention
The drawings are intended to provide a further understanding of the invention, and constitutes part of specification, with following tool
Body embodiment is used to explain the present invention together, but is not construed as limiting the invention.In the accompanying drawings:
Fig. 1 is a kind of flow chart of method for handling message provided in an embodiment of the present invention;
Fig. 2 is the relation schematic diagram in the embodiment of the present invention between message queue and single thread;
Fig. 3 is the flow chart of step S12 in a kind of method for handling message provided in an embodiment of the present invention;
Fig. 4 is a kind of block diagram of device for handling message provided in an embodiment of the present invention.
Specific embodiment
Below in conjunction with attached drawing, detailed description of the preferred embodiments.It should be understood that this place is retouched
The specific embodiment stated is merely to illustrate and explain the present invention, and is not intended to restrict the invention.
Referring to FIG. 1, Fig. 1 is a kind of flow chart of method for handling message provided in an embodiment of the present invention.Such as Fig. 1 institute
Show, method includes the following steps:
Step S11: when receiving the first message of server transmission, the first message is added to first message team
In column, corresponding first single thread of the first message queue;
Step S12: when receiving the second message that the server is sent, the second message is added to second and is disappeared
It ceases in queue, the second message queue is different from the first message queue, corresponding second single line of the second message queue
Journey;
Step S13: first message described in first single thread and the second single thread parallel processing and described is utilized
Second message.
In the embodiment of the present invention, mobile client is respectively added to difference after receiving multiple message, by each message
Message queue in, the corresponding single thread of each message queue, in this way, can use, multiple single thread parallel processings are multiple to disappear
Breath.And then reach the processing capacity for maximally utilizing CPU, improve the purpose of the efficiency of processing message.
For example, as shown in Fig. 2, mobile client receives first message and second message, then first message is added
It is added to first message queue, second message is added to second message queue, wherein corresponding first single line of first message queue
Journey, corresponding second single thread of second message queue.Finally utilize the first single thread and the second single thread parallel processing first message
And second message.
It is illustrated by taking first message and second message as an example above.In practical applications, mobile client receives
The possible more than first message of message and second message, it is also possible to third message, the 4th message etc. can be received, then can be used more
A message queue and multiple single threads, specific implementation process is similar with first message queue and the first single thread, herein just no longer
It repeats.
Through the above technical solutions, be respectively stored into message is received in different message queues, then each message
A corresponding single thread, using multiple multiple message of single thread parallel processing, therefore, multiple message are processed simultaneously, realize
The processing capacity for maximally utilizing CPU improves the efficiency of processing message.
Optionally, as shown in figure 3, step S12 includes:
Step S121: when receiving the second message that the server is sent, the second message and described the are determined
Processing sequence demand between one message is random sequence;
Step S122: the second message is added in the second message queue.
Optionally, method provided in an embodiment of the present invention further include:
When receiving the second message that the server is sent, determine between the second message and the first message
Processing sequence demand be preset order, the preset order be the first message handled prior to the second message;
The second message is added in the first message queue.
In the embodiment of the present invention, the message for not needing sequential processes is respectively added to different message queues, will be needed
The message of sequential processes is added to same message queue, to avoid the processing sequence upset to the message for needing sequential processes, makes
It is abnormal at processing.Therefore, when receiving a message every time, the processing sequence between the message and other message will be determined
Demand, if processing sequence demand be it is random, which can be respectively added to different message queues from other message
In, if processing sequence demand is other message prior to the Message Processing, the message and other message are added to same disappear
It ceases in queue.
For example, first backward mobile client pushes two message to server: lock and unlock works as mobile client
When first receiving lock, which is added in message queue i, when mobile client receives unlock, due to unlock with
Processing sequence demand between lock is first to handle lock, then handles unlock, disappears so unlock message is also added to
It ceases in queue i.When mobile client receives another message rest, due to the processing sequence between rest and lock, unlock
Demand is random, so rest is added in message queue j.
By adopting the above technical scheme, it is multiple message of preset order for processing sequence demand, is added to same message
In queue, to avoid the processing sequence upset to the message for needing sequential processes, cause processing abnormal.For processing sequence demand
For random multiple message, it is added in different message queues, to utilize different single thread parallel processings, raising processing disappears
The efficiency of breath.
Optionally, after step s 11, the method also includes:
The mapping relations between the first message and the first message queue are established, the mapping relations include described
Preset order.
Optionally, it is described the second message is added in the first message queue after, the method is also wrapped
It includes:
By the mapping relations by being updated to the second message between the first message and the first message queue
Between the first message queue.
In the embodiment of the present invention, as soon as after a message is added in a message queue every time, establish the message with
Mapping relations between the message queue.In this way, mapping relations can reflect which message team is each message be added to respectively
In column.For the processing sequence demand between some message and other message be preset order, that is, need the message it is processed it
After reprocess other message, then include preset order in the mapping relations of the message and a certain message queue.In this way, from mapping
You can learn that the processing sequence demand between the message and other message is preset order, when mobile client receives in relationship
Other message can be also added to after other message in the message queue where the message.If Non-precondition in mapping relations
Relationship, then can know the processing sequence demand between the message and other message be it is random, when mobile client receives it
Other message can be added to other message to be added in another message queue after his message.
For example, first backward mobile client pushes two message to server: lock and unlock works as mobile client
When first receiving lock, which is added in message queue i, and establishes the mapping relations of lock Yu message queue i, the mapping
Relationship further includes preset order, i.e. reprocesses unlock after lock is processed.When mobile client receives unlock, from reflecting
Penetrating in relationship can know that the processing sequence demand between unlock and lock is first to handle lock, then handle unlock, institute
Unlock message to be also added in message queue i.Then by mapping relations be updated to unlock and Message queue i it
Between.Since the processing sequence demand between unlock and other message is random, so updated mapping relations do not include pre-
If sequence.When mobile client receives another message rest, due to not including preset order in mapping relations, it is possible to obtain
Know that the processing sequence demand between rest and lock, unlock is random, so rest is added in message queue j, then
Establish the mapping relations between rest and message queue j.
By adopting the above technical scheme, by establish mapping relations realize to the message in message queue and message queue it
Between correspondence, be convenient for managing message queues and each message.Also, it whether include preset order from mapping relations, it can be true
It is fixed whether a message to be added in new message queue, it is convenient and efficient.
Based on the same inventive concept, the embodiment of the present invention also provides a kind of device for handling message.It is configured at mobile client
End, as shown in figure 4, the device 100 includes:
First adding module 110, for when receiving the first message of server transmission, the first message to be added
Into first message queue, corresponding first single thread of the first message queue;
Second adding module 120, for when receiving the second message that the server is sent, by the second message
It is added in second message queue, the second message queue is different from the first message queue, the second message queue
Corresponding second single thread;
Processing module 130, for disappearing using described in first single thread and the second single thread parallel processing first
Breath and the second message.
Optionally, second adding module 120 includes:
Determine submodule, for when receiving the second message that the server is sent, determine the second message with
Processing sequence demand between the first message is random sequence;
Submodule is added, for the second message to be added in the second message queue.
Optionally, described device further include:
Determining module, for determining the second message and institute when receiving the second message that the server is sent
Stating the processing sequence demand between first message is preset order, and the preset order is the first message prior to described second
Message Processing;
Third adding module, for the second message to be added in the first message queue.
Optionally, described device further include:
Establish module, for it is described the first message is added in first message queue after, establish described
Mapping relations between one message and the first message queue, the mapping relations include the preset order.
Optionally, described device further include:
Update module, for it is described the second message is added in the first message queue after, will be described
Mapping relations are by being updated to the second message and the first message between the first message and the first message queue
Between queue.
It is described the prefered embodiments of the present invention in detail above in conjunction with attached drawing, still, the present invention is not limited to above-mentioned realities
The detail in mode is applied, within the scope of the technical concept of the present invention, a variety of letters can be carried out to technical solution of the present invention
Monotropic type, these simple variants all belong to the scope of protection of the present invention.
It is further to note that specific technical features described in the above specific embodiments, in not lance
In the case where shield, can be combined in any appropriate way, in order to avoid unnecessary repetition, the present invention to it is various can
No further explanation will be given for the combination of energy.
In addition, various embodiments of the present invention can be combined randomly, as long as it is without prejudice to originally
The thought of invention, it should also be regarded as the disclosure of the present invention.
Claims (10)
1. a kind of method for handling message, which is characterized in that be applied to mobile client, which comprises
When receiving the first message of server transmission, the first message is added in first message queue, described the
One message queue corresponds to the first single thread;
When receiving the second message that the server is sent, the second message is added in second message queue, institute
It is different from the first message queue to state second message queue, corresponding second single thread of the second message queue;
Utilize first message and the second message described in first single thread and the second single thread parallel processing;
Wherein, the message being added in same message queue needs sequential processes, is added to message in different messages queue not
Sequential processes are needed, the processing sequence demand between a message and other message is from the message and the affiliated message team of the message
Know in mapping relations between column, which is that the message is being added to the message queue by the mobile client
It establishes later, to determine whether other described message being added to new message queue after receiving other described message.
2. the method according to claim 1, wherein described in the second message for receiving the server transmission
When, the second message is added in second message queue, comprising:
When receiving the second message that the server is sent, the place between the second message and the first message is determined
Reason sequencing requirement is random sequence;
The second message is added in the second message queue.
3. the method according to claim 1, wherein the method also includes:
When receiving the second message that the server is sent, the place between the second message and the first message is determined
Reason sequencing requirement is preset order, and the preset order is that the first message is handled prior to the second message;
The second message is added in the first message queue.
4. according to the method described in claim 3, it is characterized in that, the first message is added to first message team described
After in column, the method also includes: the mapping relations between the first message and the first message queue are established, it is described
Mapping relations include the preset order.
5. according to the method described in claim 4, it is characterized in that, the second message be added to described first disappearing described
After ceasing in queue, the method also includes: by the mapping relations by the first message and the first message queue it
Between be updated between the second message and the first message queue.
6. a kind of device for handling message, which is characterized in that be configured at mobile client, described device includes:
First adding module, for when receiving the first message of server transmission, the first message to be added to first
In message queue, corresponding first single thread of the first message queue;
Second adding module, for when receiving the second message that the server is sent, the second message to be added to
In second message queue, the second message queue is different from the first message queue, the second message queue corresponding the
Two single threads;
Processing module, for utilizing first message described in first single thread and the second single thread parallel processing and described
Second message;
Wherein, the message being added in same message queue needs sequential processes, is added to message in different messages queue not
Sequential processes are needed, the processing sequence demand between a message and other message is from the message and the affiliated message team of the message
Know in mapping relations between column, which is that the message is being added to the message queue by the mobile client
It establishes later, to determine whether other described message being added to new message queue after receiving other described message.
7. device according to claim 6, which is characterized in that second adding module includes:
Determine submodule, for when receiving the second message that the server is sent, determine the second message with it is described
Processing sequence demand between first message is random sequence;
Submodule is added, for the second message to be added in the second message queue.
8. device according to claim 6, which is characterized in that described device further include:
Determining module, for when receiving the second message that the server is sent, determining the second message and described the
Processing sequence demand between one message is preset order, and the preset order is the first message prior to the second message
Processing;
Third adding module, for the second message to be added in the first message queue.
9. device according to claim 8, which is characterized in that described device further include:
Establish module, for it is described the first message is added in first message queue after, establish described first and disappear
Mapping relations between breath and the first message queue, the mapping relations include the preset order.
10. device according to claim 9, which is characterized in that described device further include:
Update module, for it is described the second message is added in the first message queue after, by the mapping
Relationship is by being updated to the second message and the first message queue between the first message and the first message queue
Between.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610589516.3A CN106201705B (en) | 2016-07-25 | 2016-07-25 | Handle the method and device of message |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610589516.3A CN106201705B (en) | 2016-07-25 | 2016-07-25 | Handle the method and device of message |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106201705A CN106201705A (en) | 2016-12-07 |
CN106201705B true CN106201705B (en) | 2019-10-08 |
Family
ID=57494878
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610589516.3A Active CN106201705B (en) | 2016-07-25 | 2016-07-25 | Handle the method and device of message |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106201705B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106850402B (en) * | 2017-01-16 | 2020-11-03 | 腾讯科技(深圳)有限公司 | Message transmission method and device |
CN108052400A (en) * | 2017-12-21 | 2018-05-18 | 深圳Tcl新技术有限公司 | Message immediate processing method, intelligent terminal and computer readable storage medium |
CN111327511B (en) * | 2018-12-14 | 2022-04-12 | 北京京东尚科信息技术有限公司 | Instant messaging method, system, terminal equipment and storage medium |
JP2021117747A (en) * | 2020-01-27 | 2021-08-10 | 株式会社デンソー | Electronic control apparatus |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1794185A (en) * | 2005-12-30 | 2006-06-28 | 北京金山软件有限公司 | Resources calling method in multiline range process |
CN101826003A (en) * | 2010-04-16 | 2010-09-08 | 中兴通讯股份有限公司 | Multithread processing method and device |
CN102025649A (en) * | 2010-06-04 | 2011-04-20 | 西本新干线股份有限公司 | Message processing method of enterprise service bus |
CN102087615A (en) * | 2009-12-03 | 2011-06-08 | 国际商业机器公司 | Automated merger of logically associated messages in a message queue |
CN102841810A (en) * | 2011-05-14 | 2012-12-26 | 国际商业机器公司 | Techniques for executing threads in a computing environment |
CN103164267A (en) * | 2013-03-29 | 2013-06-19 | 汉柏科技有限公司 | Lock-free message queue implementation method |
CN103631665A (en) * | 2013-12-12 | 2014-03-12 | 北京奇虎科技有限公司 | Method and system for cross-thread communication based on message queue |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105471703A (en) * | 2014-08-27 | 2016-04-06 | 北京奇虎科技有限公司 | Message sending method and device |
-
2016
- 2016-07-25 CN CN201610589516.3A patent/CN106201705B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1794185A (en) * | 2005-12-30 | 2006-06-28 | 北京金山软件有限公司 | Resources calling method in multiline range process |
CN102087615A (en) * | 2009-12-03 | 2011-06-08 | 国际商业机器公司 | Automated merger of logically associated messages in a message queue |
CN101826003A (en) * | 2010-04-16 | 2010-09-08 | 中兴通讯股份有限公司 | Multithread processing method and device |
CN102025649A (en) * | 2010-06-04 | 2011-04-20 | 西本新干线股份有限公司 | Message processing method of enterprise service bus |
CN102841810A (en) * | 2011-05-14 | 2012-12-26 | 国际商业机器公司 | Techniques for executing threads in a computing environment |
CN103164267A (en) * | 2013-03-29 | 2013-06-19 | 汉柏科技有限公司 | Lock-free message queue implementation method |
CN103631665A (en) * | 2013-12-12 | 2014-03-12 | 北京奇虎科技有限公司 | Method and system for cross-thread communication based on message queue |
Also Published As
Publication number | Publication date |
---|---|
CN106201705A (en) | 2016-12-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106201705B (en) | Handle the method and device of message | |
US11736433B2 (en) | Watermark-based message queue | |
CN103532797A (en) | Abnormity monitoring method and device for user registration | |
Fong et al. | Change point testing in logistic regression models with interaction term | |
CN110868276A (en) | Data transmission method and system for Internet of things equipment and electronic equipment | |
CN112434620B (en) | Scene text recognition method, device, equipment and computer readable medium | |
JP2015033038A5 (en) | ||
WO2017182888A3 (en) | System and method for assisting user communications using bots | |
EP1601160A3 (en) | Efficient routing of real-time multimedia information | |
CN106789069A (en) | A kind of zero-knowledge status authentication method | |
CN106341285A (en) | Traffic identification method and device | |
RU2703980C1 (en) | Question-and-answer interface based on contextual information | |
CN109286553A (en) | The means of communication and device | |
CN103731424B (en) | A kind of transmission method of network data, apparatus and system | |
CN108696568B (en) | Request batch processing method and terminal | |
CN110324302B (en) | IOT equipment communication method | |
US20210141843A1 (en) | Automated web page accessing | |
CN105471927B (en) | The method and service node that a kind of pair of business routing message is handled | |
CN112434619B (en) | Case information extraction method, apparatus, device and computer readable medium | |
CN103297401A (en) | Error code returning method and device | |
CN109286665A (en) | The real-time long link processing method and processing device of moving game | |
WO2004092916A3 (en) | Universal personal information connector architecture | |
Goh | Stability of some multispecies population models | |
CN105812266B (en) | A kind of hardware configuration processing method and processing device of request message | |
CN105871917A (en) | Transmission control protocol TCP connection scheduling method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |