CN110297707A - A kind of method for message transmission and device - Google Patents
A kind of method for message transmission and device Download PDFInfo
- Publication number
- CN110297707A CN110297707A CN201810239137.0A CN201810239137A CN110297707A CN 110297707 A CN110297707 A CN 110297707A CN 201810239137 A CN201810239137 A CN 201810239137A CN 110297707 A CN110297707 A CN 110297707A
- Authority
- CN
- China
- Prior art keywords
- message
- thread
- business
- service portion
- scheduling
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 49
- 230000005540 biological transmission Effects 0.000 title claims abstract description 48
- 238000012545 processing Methods 0.000 claims abstract description 41
- 238000004891 communication Methods 0.000 claims abstract description 23
- 238000012546 transfer Methods 0.000 claims abstract description 10
- 238000002360 preparation method Methods 0.000 claims description 2
- 230000005611 electricity Effects 0.000 claims 1
- 238000005516 engineering process Methods 0.000 abstract description 3
- 230000008569 process Effects 0.000 description 7
- 238000010586 diagram Methods 0.000 description 5
- 230000006870 function Effects 0.000 description 5
- 230000009471 action Effects 0.000 description 2
- 238000010295 mobile communication Methods 0.000 description 2
- 238000004590 computer program Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 239000000203 mixture Substances 0.000 description 1
- 238000011176 pooling Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 238000013517 stratification Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- 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/50—Allocation of resources, e.g. of the central processing unit [CPU]
- G06F9/5005—Allocation of resources, e.g. of the central processing unit [CPU] to service a request
- G06F9/5027—Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
-
- 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/04—Real-time or near real-time messaging, e.g. instant messaging [IM]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L65/00—Network arrangements, protocols or services for supporting real-time applications in data packet communication
- H04L65/40—Support for services or applications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/55—Push-based network services
Abstract
The embodiment of the present invention discloses a kind of method for message transmission and device, is related to field of communication technology, can effectively improve message efficiency of transmission.The method for message transmission includes: to receive the message that source device is sent by multistage thread, and the multistage thread includes scheduling thread, worker thread, business thread pool;Wherein, the scheduling thread is used to receive the message of the source device transmission and is scheduled to the message, to distribute to different worker thread processing;The worker thread transfers to the business thread pool to handle for being handled according to the scheduling of the scheduling thread message, and by the message that estimated handling duration is greater than preset time threshold;It include at least two business threads, the message handling task given for handling the worker thread in the business thread pool;The message received is pushed to corresponding purpose equipment.The present invention can be used in the transmission of the message based on business.
Description
Technical field
The present invention relates to field of communication technology more particularly to a kind of method for message transmission and device.
Background technique
In video living transmission system, usual size of message each second reaches million or more, and single direct broadcasting room size of message is maximum close
Hundreds of thousands item.If carrying out message push simultaneously to mass users by traditional message mode, biggish delay will be generated,
It is difficult to meet the demand for the live streaming application scenarios that height is real-time, interacts by force.
Summary of the invention
In view of this, the embodiment of the present invention provides a kind of method for message transmission and device, message transmission can be effectively improved
Efficiency.
In a first aspect, the embodiment of the present invention provides a kind of method for message transmission, comprising: receive source device by multistage thread
The message of transmission, the multistage thread includes scheduling thread, worker thread, business thread pool;The scheduling thread is for receiving
The message of the source device transmission is simultaneously scheduled the message, to distribute to different worker thread processing;It is described
Worker thread is greater than preset time for handling according to the scheduling of the scheduling thread message, and by estimated handling duration
The message of threshold value transfers to the business thread pool to handle;It include at least two business threads in the business thread pool, for locating
Manage the message handling task that the worker thread is given;The message received is pushed to corresponding purpose equipment.
With reference to first aspect, in the first embodiment of first aspect, when the estimated handling duration is greater than default
Between the message of threshold value comprise at least one of the following: read and write the message of storage medium, the message for calling third party's interface, current-limiting operation
Message.
With reference to first aspect, in second of embodiment of first aspect, the message includes that single chat message, group chat disappear
At least one of breath and direct broadcasting room message.
Any embodiment with reference to first aspect or in the first to the second of first aspect, in the third of first aspect
In embodiment, described the message that source device is sent is received by multistage thread includes: the access service portion of server by more
Grade thread receives message from the source device;The business service portion of the server passes through multistage thread from the access service portion
Receive message.
The third embodiment with reference to first aspect, in the 4th kind of embodiment of first aspect, the access clothes
Business portion includes instant messaging access service portion and/or direct broadcasting room access service portion;The business service portion includes single chat business clothes
At least one of business portion, group chat service service department and direct broadcasting room business service portion.
The third embodiment with reference to first aspect, in the 5th kind of embodiment of first aspect, the server
Access service portion and business service portion between pass through the connection of at least two communication threads, wherein the type of the communication thread
Including long connection type and/or short connection type.
Any embodiment with reference to first aspect or in the first to the second of first aspect, at the 6th kind of first aspect
In embodiment, the quantity of the purpose equipment is one or more;It is described to incite somebody to action when the quantity of the purpose equipment is multiple
It includes: that the purpose equipment is divided at least two equipment groups that the message received is pushed to corresponding purpose equipment, wherein often
A equipment group pushes the message by each purpose equipment of the thread in turn into the equipment group.
Second aspect, the embodiment of the present invention also provide a kind of massage transmission device, comprising: receiving unit, for passing through
Multistage thread receives the message that source device is sent, and the multistage thread includes scheduling thread, worker thread, business thread pool;Its
In, the scheduling thread is used to receive the message that the source device is sent and is scheduled to the message, to distribute to difference
The worker thread processing;The worker thread is used to handle message according to the scheduling of the scheduling thread, and will
It is expected that the message that handling duration is greater than preset time threshold transfers to the business thread pool to handle;Include in the business thread pool
At least two business threads, the message handling task given for handling the worker thread;Push unit, for being connect described
The message that unit receives is received to push to corresponding purpose equipment.
In conjunction with second aspect, in the first embodiment of second aspect, when the estimated handling duration is greater than default
Between the message of threshold value comprise at least one of the following: read and write the message of storage medium, the message for calling third party's interface, current-limiting operation
Message.
In conjunction with second aspect, in second of embodiment of second aspect, the message includes that single chat message, group chat disappear
At least one of breath and direct broadcasting room message.
In conjunction with second aspect or second aspect the first to the second in any embodiment, in the third of second aspect
In embodiment, the receiving unit includes: the first receiving module, for being set the message from the source by multistage thread
It is standby to receive to the access service portion of server;Second receiving module, for by multistage thread by the message from the access
Service department receives to the business service portion of the server.
In conjunction with the third embodiment of second aspect, in the 4th kind of embodiment of second aspect, the access clothes
Business portion includes instant messaging access service portion and/or direct broadcasting room access service portion;The business service portion includes single chat business clothes
At least one of business portion, group chat service service department and direct broadcasting room business service portion.
In conjunction with the third embodiment of second aspect, in the 5th kind of embodiment of second aspect, the server
Access service portion and business service portion between pass through the connection of at least two communication threads, wherein the type of the communication thread
Including long connection type and/or short connection type.
In conjunction with second aspect or second aspect the first to the second in any embodiment, at the 6th kind of second aspect
In embodiment, the quantity of the purpose equipment is one or more;The push unit is specifically used for: when the purpose equipment
Quantity be it is multiple when, the purpose equipment is divided at least two equipment groups, wherein each equipment group pass through a thread wheel
Each purpose equipment flowed in the equipment group pushes the message.
The third aspect, the embodiment of the present invention also provide a kind of electronic equipment, and the electronic equipment includes: shell, processing
Device, memory, circuit board and power circuit, wherein circuit board is placed in the space interior that shell surrounds, processor and memory
Setting is on circuit boards;Power circuit, for each circuit or the device power supply for above-mentioned electronic equipment;Memory is for storing
Executable program code;Processor is run and executable program generation by reading the executable program code stored in memory
The corresponding program of code, for executing any method for message transmission of the embodiment of the present invention offer.
Fourth aspect, the embodiment of the present invention also provide a kind of computer readable storage medium, described computer-readable to deposit
Storage media is stored with one or more program, and one or more of programs can be executed by one or more processor,
To realize any method for message transmission of the embodiment of the present invention offer.
The method for message transmission and device that the embodiment of the present invention provides can receive source device by multistage thread and send
Message, these message by special scheduling thread carry out United Dispatching, distribute to different worker threads and specifically handled,
And the business that some of them take a long time is given to the processing of business thread pool, threads at different levels have the specific division of labor, disappear to be formed
The multi-stage pipeline for ceasing processing, not only substantially increases the receiving efficiency of message, also helps and quickly push message to correspondence
Purpose equipment.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below
There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this
Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with
Other attached drawings are obtained according to these attached drawings.
Fig. 1 is a kind of flow chart for the method for message transmission that the embodiment of the present invention provides;
Fig. 2 is a kind of structural schematic diagram of server in the embodiment of the present invention;
Fig. 3 is a kind of schematic diagram being grouped in the embodiment of the present invention to purpose equipment;
Fig. 4 is another flow chart of the method for message transmission provided in the embodiment of the present invention;
Fig. 5 is a kind of structural schematic diagram for the massage transmission device that the embodiment of the present invention provides;
Fig. 6 is a kind of structural schematic diagram for the electronic equipment that the embodiment of the present invention provides.
Specific embodiment
The embodiment of the present invention is described in detail with reference to the accompanying drawing.
It will be appreciated that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.Base
Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts it is all its
Its embodiment, shall fall within the protection scope of the present invention.
In a first aspect, the embodiment of the present invention provides a kind of method for message transmission, source device can be received by multistage thread
The message of transmission, threads at different levels have the specific division of labor, to form the multi-stage pipeline of Message Processing, not only substantially increase and disappear
The receiving efficiency of breath is also helped and is quickly pushed message to corresponding purpose equipment.
It should be noted that the method for message transmission that the embodiment of the present invention provides, is based primarily upon source device, intermediate equipment
With the various applications of purpose equipment and setting on them, wherein source device and purpose equipment can be user terminal, intermediate
Equipment can be various servers or other equipment between source device and purpose equipment.Optionally, source device, intermediate equipment
And the particular number of purpose equipment can be for one or multiple, the embodiment of the present invention does not limit this.Due to
Intermediate equipment plays a part of forming a connecting link in entire message process, and the embodiment of the present invention is mainly with intermediate equipment
Basis is illustrated, and the concrete operations of source device and purpose equipment are corresponding with the operation that intermediate equipment executes.
As shown in Figure 1, the method for message transmission that the embodiment of the present invention provides may include:
S11 receives the message that source device is sent by multistage thread, and the multistage thread includes scheduling thread, active line
Journey, business thread pool;Wherein, the scheduling thread is used to receive the message of the source device transmission and adjusts to the message
Degree, to distribute to different worker thread processing;The worker thread according to the scheduling of the scheduling thread for offseting
Breath is handled, and transfers to the business thread pool to handle the message that estimated handling duration is greater than preset time threshold;It is described
It include at least two business threads, the message handling task given for handling the worker thread in business thread pool;
Specifically, server can be by presetting the message that thread receives and processing is sent from source device.In view of many groups
Merely, the characteristics of live broadcast service, it is most likely that the message for receiving magnanimity from a large number of users in a short time offsets to improve
The treatment effeciency of breath avoids the occurrence of excessive message delay, and in an embodiment of the present invention, the thread for receiving message can be with
It is divided into multiple and different ranks, such as the other thread, that is, scheduling thread of scheduling level, dispatches the worker thread under rank, Yi Jigong
Make the business thread pool under thread.Wherein the particular number of thread can be one or more in each rank.For example, at this
In one embodiment of invention, scheduling thread, which is mainly responsible for, receive and to message handling task to the message that source device is sent
It is allocated, that is, different message is distributed into different worker threads and is specifically handled.Scheduling thread is adjusted specifically
When spending, message sink task can balancedly be distributed to by each worker thread according to the loading condition of each worker thread as far as possible.Cause
This, for a kind of business, the quantity of scheduling thread can be one, and the quantity of worker thread can be multiple.And industry
The quantity of business thread pool then can be more.
S12 pushes the message received to corresponding purpose equipment.
In this step, server can send the message received in step s 11 to corresponding purpose equipment respectively.
For example, in one embodiment of the invention, some user A in a group chat service is sent to a message in group, clothes
Business device the message is sent respectively to each group members in addition to user A upon receiving the message, then these groups at
The corresponding equipment of member is exactly purpose equipment.That is in the present embodiment, the quantity of the corresponding purpose equipment of the message is multiple.
It should be understood that in other embodiments of the invention, according to the difference of business, the quantity of purpose equipment is also not quite similar, both
It can be one, or multiple.The embodiment of the present invention does not limit this.
The method for message transmission that the embodiment of the present invention provides can receive disappearing for source device transmission by multistage thread
Breath, these message carry out United Dispatching by special scheduling thread, distribute to different worker threads and specifically handled, and will
The business that some of them take a long time is given to the processing of business thread pool, and threads at different levels have the specific division of labor, to be formed at message
The multi-stage pipeline of reason not only substantially increases the receiving efficiency of message, also helps and quickly pushes message to corresponding mesh
Equipment.
Specifically, in step s 11, scheduling thread can be used for receiving the message of source device transmission and carry out to message
Scheduling, to distribute to different worker thread processing, to realize the totality rule to message sink task by scheduling thread
It draws, the processing of message sink task is made more to have levels.Worker thread can be used for carrying out message according to the scheduling of scheduling thread
Processing, and transfer to business thread pool to handle the message that estimated handling duration is greater than preset time threshold, to make worker thread
The message task for needing quick response can be handled with pooling of resources, guarantee the timeliness of message sink processing.
Since server resource configuration is limited, the quantity of scheduling thread and worker thread is often fixed, such as with 1
The worker thread of a scheduling thread and CPU of 2 times number.In order to further increase Message Processing efficiency, when having than relatively time-consuming industry
Business is come when being handled, worker thread can give time-consuming business to business thread pool to handle.
It may include at least two business threads in business thread pool, appoint for handling the Message Processing that worker thread is given
Business.Due to the business number of threads in business thread pool be it is multiple, can handle a large amount of consuming task, to optimize
The received thread structure of user message in server, further improves message sink efficiency.
It should be noted that the difference of the concrete operations executed according to message, can substantially estimate the estimated processing of message
Duration.For worker thread when carrying out the transfer of message task, main foundation is whether to see the estimated handling duration of the message task
Greater than preset time threshold, so that transferring excessively time-consuming message task to business thread pool carries out special disposal.Optionally,
In one embodiment of the invention, it is contemplated that the message that handling duration is greater than preset time threshold may include following a kind of or more
Kind: it reads and writes the message of storage medium, call message, the current-limiting operation message of third party's interface.Wherein, disappearing for storage medium is read and write
Breath due to needing access storage media, it is therefore desirable to the processing time can than only in the processor carry out Message Processing more expend when
Between;The message of third party's interface is called, such as third party database is called to be filtered the sensitive word in message, due to being related to
It communicates to third party, can also consume a longer time;To judge whether to carry out the message when current-limiting operation Message Processing
It abandons, it is same time-consuming.At the message that these time-consuming message tasks can reduce worker thread if being executed by worker thread
Manage speed, the task more demanding to the time limit caused to cause larger delay, for this purpose, in an embodiment of the present invention, by by this
A little tasks are separated, and are handled by business thread pool, to effectively improve the Message Processing efficiency of server.
Server can receive the message of various businesses type.Optionally, the difference of the type of service according to belonging to message,
The embodiment of the present invention provide method for message transmission involved in message substantially may include single chat message, group chat message and
One of direct broadcasting room message is a variety of.Wherein, the fixed limitation of the estimated handling duration of each type of message, it is existing can
Preset time threshold can be greater than, it is also possible to be less than or equal to preset time threshold.And the specific value of preset time threshold can
To be configured or modify as needed.
In previous embodiment, as a whole by the process of server reception message, however, the present invention is not limited thereto.At this
May include again some micro services in server in other embodiments of invention, include multiple threads in each micro services from
And micro services is allow to execute relatively independent task.For example, in one embodiment of the invention, being responsible for message in server
Received micro services may include access service portion and business service portion again.Wherein, access service portion can be logical with each client
The message that each client is sent is accessed and is transmitted to corresponding business service portion progress business processing by letter;Business service portion with
The communication of access service portion, the message forwarded for handling access service portion.Optionally, not according to the affiliated business of message
Together, access service portion can specifically include instant messaging access service portion and/or direct broadcasting room access service portion, business service portion tool
Body may include one of single chat business service portion, group chat service service department and direct broadcasting room business service portion or a variety of.
For example, IM is the long connection access service portion of single chat as shown in Fig. 2, in one embodiment of the invention,
Live is the long connection access service portion of live streaming, and Chat is single chat business service portion, and GroupChat is group chat service service department,
Room is direct broadcasting room business service portion.Server can pass through TCP (Transmission Control Protocol, transmission control
Agreement processed) message sent by mobile terminal (user2) and/or personal computer (user1) is received, if the message belongs to i.e.
When communication information, then by instant messaging access service portion by receive, if the message belongs to direct broadcasting room message, the message by
Direct broadcasting room access service portion receives.Wherein, the message received by instant messaging access service portion can be turned by RPC connection
It issues single chat business service portion or group chat service service department carries out business processing, the message received by direct broadcasting room access service portion
It can be transmitted to direct broadcasting room business service portion by RPC connection and carry out business processing.
Include in the server by access service portion and business service portion in the case where, correspondingly, by more in step S11
It also may include some more fine processing steps that grade thread, which receives the message that source device is sent, for example, according to the present invention
A kind of embodiment, receiving the message that source device is sent by multistage thread can specifically include:
The access service portion of server passes through multistage thread and receives message from the source device;
The business service portion of the server passes through multistage thread and receives message from the access service portion.
That is, two micro services of server when carrying out respective Message Processing, can use multistage thread
Structure carry out stratification and handle various message.Access service portion and business service portion all receive message by scheduling thread and distribute
It is specifically handled to corresponding worker thread.It is less than or equal to the message of preset time threshold, work for estimated handling duration
Making thread can directly be handled, for it is expected that handling duration is more than the message of preset time threshold, worker thread can be incited somebody to action
These message are handed to business thread pool and are handled.
Further, it in order to accelerate the message transmission speed between access service portion and business service portion, can service
Pass through at least two communication thread connections between the access service portion and business service portion of device.It is responsible for the communication thread of communication connection
Quantity can according to need and be configured or modify, quantity is bigger, and communication speed is faster, and vice versa.The class of communication thread
Type both may include long connection type (such as the long connection of RPC (Remote Procedure Call, remote procedure call)) can also
To include short connection type (such as HTTP (Hyper Text Transfer Protocol, hypertext transfer protocol) connection),
It all can include that the embodiment of the present invention is not limited this with the two.
It, in step s 12 can be by the message received to corresponding purpose after step S11 completes the reception of message
Equipment push.Optionally, the quantity of the corresponding purpose equipment of a message can be one or more.When the quantity of purpose equipment
When being multiple, in order to allow message to reach each purpose equipment in time, delay is minimized, in one embodiment of the invention, when
When the quantity of the purpose equipment is multiple, step S12 pushes the message received to corresponding purpose equipment specifically can be with
Include:
The purpose equipment is divided at least two equipment groups, wherein each equipment group is set to this in turn by a thread
Each purpose equipment in standby group pushes the message.
Specifically, for generally for the smaller instant communicating system of scale, such as be for the quantity of purpose equipment
Even if for dozens to hundreds of communication system, since purpose equipment quantity is smaller, the forwarding of message will not generate too big prolong
Late, therefore message can directly be forwarded to these purpose equipments.However for the application for possessing mass users, in order to allow
Magnanimity message quickly reaches, in one embodiment of the invention, can using multithreading model to the message received to each
Purpose equipment is sent.When specific implementation, the purpose equipment of same direct broadcasting room can be divided into multiple purpose equipment groups, when need
When will be to purpose equipment PUSH message, multithreading model can be taken to carry out message transmission, per thread traverses one of mesh
Equipment group.
Optionally, purpose equipment can be grouped using a variety of methods.In order to make the number of the purpose equipment in each group
Amount is balanced as far as possible, in one embodiment of the invention, can be carried out by the ID of purpose equipment to the quantity of purpose equipment group
Remainder operates to be grouped to purpose equipment.The grouping schematic diagram of purpose equipment can be as shown in Figure 3.
For example, in one embodiment of the invention, 1000000 purpose equipments in a direct broadcasting room are divided
100 purpose equipment groups.It is divided into which equipment group specific to each purpose equipment, can be come by the User ID of its own to equipment
The number (i.e. 100) of group carries out remainder operation and each User ID is divided into corresponding purpose respectively to obtain the serial number of equipment group
Equipment group.In this way, being averagely 10000 purpose equipments in each group, 100 threads work simultaneously will start when sending message
Make, 100 general-purpose families are sent a message to and were mostly completed at 1 second or so, to effectively increase message transmitting efficiency.
Method for message transmission provided in an embodiment of the present invention is described in detail below by specific embodiment.
As shown in figure 4, method for message transmission provided in this embodiment may include following steps:
S201, instant messaging access service portion scheduling thread P from source device B receive message B1, message B2, message B3;
The scheduling thread Q in direct broadcasting room access service portion receives message C1 from source device C, receives message D1 from source device D.
Message B1 is distributed to worker thread W1 processing by S202, scheduling thread P, and message B2 is distributed at worker thread W2
Message B3 is distributed to worker thread W3 processing by reason;Message C1 is distributed to worker thread J1 processing by scheduling thread Q, by message
D1 distributes to worker thread J2 processing.
S203, worker thread W1 directly handle message B1, and worker thread W3 directly handles message B3, work
Make thread W2 discovery message B2 to need to call third-party application interface, it is contemplated that handling duration is greater than preset time threshold, by message
B2 gives business thread pool E processing;Worker thread J1 directly handles message C1, and worker thread J2 has found that message D1 needs
Read and write storage medium, it is contemplated that handling duration is greater than preset time threshold, gives message D1 to business thread pool F processing.
S204, instant messaging service department worker thread W1 treated message B1 by communication thread M1 is sent to group
Treated message B2 by communication thread M2 is sent to group chat service service department by merely business service portion, business thread pool E, work
Make thread W3 and treated message B3 by communication thread M3 is sent to single chat business service portion;After worker thread J1 will be handled
Message C1 direct broadcasting room business service portion is sent to by communication thread M4, worker thread J2 will treated that message D1 passes through is logical
Letter thread M5 is sent to direct broadcasting room business service portion.
Corresponding 100000 purpose equipments of message B1, B2 are divided into 10 groups, every group of mesh by S205, group chat service service department
Equipment pass through respectively a thread Xiang Zuzhong purpose equipment send message B1 and message B2;Single chat business service portion is by message
B3 is sent to corresponding purpose equipment;Message C1 and message D1 is sent out to corresponding purpose equipment in direct broadcasting room business service portion respectively
It send.
Second aspect, the embodiment of the present invention also provide a kind of massage transmission device, can receive source by multistage thread and set
The message that preparation is sent, threads at different levels have the specific division of labor, to form the multi-stage pipeline of Message Processing, not only substantially increase
The receiving efficiency of message is also helped and is quickly pushed message to corresponding purpose equipment.
As shown in figure 5, massage transmission device provided in an embodiment of the present invention may include:
Receiving unit 31, for receiving the message that source device is sent by multistage thread, the multistage thread includes scheduling
Thread, worker thread, business thread pool;Wherein, the scheduling thread is used to receive the message of the source device transmission and to institute
It states message to be scheduled, to distribute to different worker thread processing;The worker thread is used for according to the scheduling line
The scheduling of journey handles message, and the message that estimated handling duration is greater than preset time threshold is transferred to the business thread
Pond processing;It include at least two business threads in the business thread pool, for handling at the message that the worker thread is given
Reason task;
Push unit 32, the message for receiving receiving unit 31 are pushed to corresponding purpose equipment.
The massage transmission device that the embodiment of the present invention provides can receive disappearing for source device transmission by multistage thread
Breath, these message carry out United Dispatching by special scheduling thread, distribute to different worker threads and specifically handled, and will
The business that some of them take a long time is given to the processing of business thread pool, and threads at different levels have the specific division of labor, to be formed at message
The multi-stage pipeline of reason not only substantially increases the receiving efficiency of message, also helps and quickly pushes message to corresponding mesh
Equipment.
Optionally, the message that the estimated handling duration is greater than preset time threshold comprises at least one of the following: read-write is deposited
The message of storage media, message, the current-limiting operation message for calling third party's interface.
Optionally, the message includes at least one of single chat message, group chat message and direct broadcasting room message.
Optionally, receiving unit 31 includes:
First receiving module, for being received the message to the access of server from the source device by multistage thread
Service department;
Second receiving module, for being received the message to the service from the access service portion by multistage thread
The business service portion of device.
Optionally, the access service portion includes instant messaging access service portion and/or direct broadcasting room access service portion;It is described
Business service portion includes at least one of single chat business service portion, group chat service service department and direct broadcasting room business service portion.
Optionally, connected between the access service portion and business service portion of the server by least two communication threads
It connects, wherein the type of the communication thread includes long connection type and/or short connection type.
Optionally, the quantity of the purpose equipment is one or more;Push unit 32 is specifically used for: when the purpose is set
When standby quantity is multiple, the purpose equipment is divided at least two equipment groups, wherein each equipment group passes through a thread
Each purpose equipment into the equipment group pushes the message in turn.
The third aspect, the embodiment of the present invention provide a kind of electronic equipment, can receive source device by multistage thread and send
Message, threads at different levels have the specific division of labor, to form the multi-stage pipeline of Message Processing, not only substantially increase message
Receiving efficiency is also helped and is quickly pushed message to corresponding purpose equipment.
As shown in fig. 6, the electronic equipment that the embodiment of the present invention provides, may include: shell 51, processor 52, storage
Device 53, circuit board 54 and power circuit 55, wherein circuit board 54 is placed in the space interior that shell 51 surrounds, 52 He of processor
Memory 53 is arranged on circuit board 54;Power circuit 55, for each circuit or the device power supply for above-mentioned electronic equipment;It deposits
Reservoir 53 is for storing executable program code;Processor 52 by read in memory 53 executable program code that stores come
Program corresponding with executable program code is run, the method for message transmission provided for executing aforementioned any embodiment.
Processor 52 to the specific implementation procedures of above-mentioned steps and processor 52 by operation executable program code come
The step of further executing may refer to the description of previous embodiment, and details are not described herein.
Above-mentioned electronic equipment exists in a variety of forms, including but not limited to:
(1) mobile communication equipment: the characteristics of this kind of equipment is that have mobile communication function, and to provide speech, data
Communication is main target.This Terminal Type includes: smart phone (such as iPhone), multimedia handset, functional mobile phone and low
Hold mobile phone etc..
(2) super mobile personal computer equipment: this kind of equipment belongs to the scope of personal computer, there is calculating and processing function
Can, generally also have mobile Internet access characteristic.This Terminal Type includes: PDA, MID and UMPC equipment etc., such as iPad.
(3) portable entertainment device: this kind of equipment can show and play multimedia content.Such equipment include: audio,
Video player (such as iPod), handheld device, e-book and intelligent toy and portable car-mounted navigation equipment.
(4) server: providing the equipment of the service of calculating, and the composition of server includes that processor, hard disk, memory, system are total
Line etc., server is similar with general computer architecture, but due to needing to provide highly reliable service, in processing energy
Power, stability, reliability, safety, scalability, manageability etc. are more demanding.
(5) other electronic equipments with data interaction function.
Fourth aspect, the embodiment of the present invention also provide a kind of computer readable storage medium, described computer-readable to deposit
Storage media is stored with one or more program, and one or more of programs can be executed by one or more processor,
To realize any method for message transmission of previous embodiment offer, therefore it is also able to achieve corresponding technical effect, above
It is described in detail, details are not described herein again.
It should be noted that, in this document, relational terms such as first and second and the like are used merely to a reality
Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation
In any actual relationship or order or sequence.Moreover, the terms "include", "comprise" or its any other variant are intended to
Non-exclusive inclusion, so that the process, method, article or equipment including a series of elements is not only wanted including those
Element, but also including other elements that are not explicitly listed, or further include for this process, method, article or equipment
Intrinsic element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that
There is also other identical elements in process, method, article or equipment including the element.
Each embodiment in this specification is all made of relevant mode and describes, same and similar portion between each embodiment
Dividing may refer to each other, and each embodiment focuses on the differences from other embodiments.
For Installation practice, since it is substantially similar to the method embodiment, so the comparison of description is simple
Single, the relevent part can refer to the partial explaination of embodiments of method.
For convenience of description, description apparatus above is to be divided into various units/modules with function to describe respectively.Certainly, exist
Implement to realize each unit/module function in the same or multiple software and or hardware when the present invention.
Those of ordinary skill in the art will appreciate that realizing all or part of the process in above-described embodiment method, being can be with
Relevant hardware is instructed to complete by computer program, the program can be stored in a computer-readable storage medium
In, the program is when being executed, it may include such as the process of the embodiment of above-mentioned each method.Wherein, the storage medium can be magnetic
Dish, CD, read-only memory (Read-Only Memory, ROM) or random access memory (RandomAccess
Memory, RAM) etc..
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any
In the technical scope disclosed by the present invention, any changes or substitutions that can be easily thought of by those familiar with the art, all answers
It is included within the scope of the present invention.Therefore, protection scope of the present invention should be subject to the protection scope in claims.
Claims (10)
1. a kind of method for message transmission characterized by comprising
The message that source device is sent is received by multistage thread, the multistage thread includes scheduling thread, worker thread, service line
Cheng Chi;Wherein, the scheduling thread is used to receive the message of the source device transmission and is scheduled to the message, with distribution
It is handled to the different worker threads;The worker thread is used for according to the scheduling of the scheduling thread to message
Reason, and transfer to the business thread pool to handle the message that estimated handling duration is greater than preset time threshold;The business thread
It include at least two business threads, the message handling task given for handling the worker thread in pond;
The message received is pushed to corresponding purpose equipment.
2. the method according to claim 1, wherein the estimated handling duration is greater than disappearing for preset time threshold
Breath comprises at least one of the following: reading and writing the message of storage medium, calls message, the current-limiting operation message of third party's interface.
3. the method according to claim 1, wherein the message includes single chat message, group chat message and live streaming
Between at least one of message.
4. according to the method in any one of claims 1 to 3, which is characterized in that described to be set by multistage thread reception source
The message that preparation is sent includes:
The access service portion of server passes through multistage thread and receives message from the source device;
The business service portion of the server passes through multistage thread and receives message from the access service portion.
5. according to the method described in claim 4, it is characterized in that, the access service portion includes instant messaging access service portion
The direct broadcasting room access service portion and/or;The business service portion includes single chat business service portion, group chat service service department and direct broadcasting room
At least one of business service portion.
6. according to the method described in claim 4, it is characterized in that, the access service portion and business service portion of the server it
Between pass through the connection of at least two communication threads, wherein the type of the communication thread includes long connection type and/or short connection class
Type.
7. according to the method in any one of claims 1 to 3, which is characterized in that the quantity of the purpose equipment is one
Or it is multiple;
When the quantity of the purpose equipment is multiple, the message that will be received includes: to the push of corresponding purpose equipment
The purpose equipment is divided at least two equipment groups, wherein each equipment group is by a thread in turn to the equipment group
In each purpose equipment push the message.
8. a kind of massage transmission device characterized by comprising
Receiving unit, for receiving the message that source device is sent by multistage thread, the multistage thread includes scheduling thread, work
Make thread, business thread pool;Wherein, the scheduling thread be used to receive message that the source device is sent and to the message into
Row scheduling, to distribute to different worker thread processing;The worker thread is used for the scheduling according to the scheduling thread
Message is handled, and transfers to the business thread pool to handle the message that estimated handling duration is greater than preset time threshold;
It include at least two business threads, the message handling task given for handling the worker thread in the business thread pool;
Push unit, the message for receiving the receiving unit are pushed to corresponding purpose equipment.
9. a kind of electronic equipment, which is characterized in that the electronic equipment includes: shell, processor, memory, circuit board and electricity
Source circuit, wherein circuit board is placed in the space interior that shell surrounds, and processor and memory setting are on circuit boards;Power supply
Circuit, for each circuit or the device power supply for above-mentioned electronic equipment;Memory is for storing executable program code;Processing
Device runs program corresponding with executable program code by reading the executable program code stored in memory, for holding
Method for message transmission described in any one of row preceding claims 1 to 7.
10. a kind of computer readable storage medium, which is characterized in that the computer-readable recording medium storage have one or
Multiple programs, one or more of programs can be executed by one or more processor, with realize preceding claims 1 to
Method for message transmission described in 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810239137.0A CN110297707A (en) | 2018-03-22 | 2018-03-22 | A kind of method for message transmission and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810239137.0A CN110297707A (en) | 2018-03-22 | 2018-03-22 | A kind of method for message transmission and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110297707A true CN110297707A (en) | 2019-10-01 |
Family
ID=68025604
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810239137.0A Pending CN110297707A (en) | 2018-03-22 | 2018-03-22 | A kind of method for message transmission and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110297707A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110781128A (en) * | 2019-11-05 | 2020-02-11 | 武汉虹信通信技术有限责任公司 | Control method and control adapter device of embedded equipment |
CN110996141A (en) * | 2019-11-05 | 2020-04-10 | 北京字节跳动网络技术有限公司 | Method and device for sending information in live broadcast room and electronic equipment |
CN111352746A (en) * | 2020-02-10 | 2020-06-30 | 福建天泉教育科技有限公司 | Message flow limiting method and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20140075030A1 (en) * | 2012-09-12 | 2014-03-13 | salesforce.com,inc. | Managing allocation of thread resources for message queues in an on-demand services environment |
CN104253808A (en) * | 2013-06-29 | 2014-12-31 | 北京新媒传信科技有限公司 | Presence method and presence server for instant messaging system |
CN105991408A (en) * | 2015-02-12 | 2016-10-05 | 腾讯科技(深圳)有限公司 | Message processing method, message processing device and processing server |
CN107172182A (en) * | 2017-06-06 | 2017-09-15 | 深圳市金立通信设备有限公司 | A kind of information push method, message push server and terminal |
CN107741884A (en) * | 2017-10-09 | 2018-02-27 | 武汉斗鱼网络科技有限公司 | The method and apparatus that a kind of stratification state machine realizes message push |
-
2018
- 2018-03-22 CN CN201810239137.0A patent/CN110297707A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20140075030A1 (en) * | 2012-09-12 | 2014-03-13 | salesforce.com,inc. | Managing allocation of thread resources for message queues in an on-demand services environment |
CN104253808A (en) * | 2013-06-29 | 2014-12-31 | 北京新媒传信科技有限公司 | Presence method and presence server for instant messaging system |
CN105991408A (en) * | 2015-02-12 | 2016-10-05 | 腾讯科技(深圳)有限公司 | Message processing method, message processing device and processing server |
CN107172182A (en) * | 2017-06-06 | 2017-09-15 | 深圳市金立通信设备有限公司 | A kind of information push method, message push server and terminal |
CN107741884A (en) * | 2017-10-09 | 2018-02-27 | 武汉斗鱼网络科技有限公司 | The method and apparatus that a kind of stratification state machine realizes message push |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110781128A (en) * | 2019-11-05 | 2020-02-11 | 武汉虹信通信技术有限责任公司 | Control method and control adapter device of embedded equipment |
CN110996141A (en) * | 2019-11-05 | 2020-04-10 | 北京字节跳动网络技术有限公司 | Method and device for sending information in live broadcast room and electronic equipment |
CN110996141B (en) * | 2019-11-05 | 2022-03-25 | 北京字节跳动网络技术有限公司 | Method and device for sending information in live broadcast room and electronic equipment |
CN111352746A (en) * | 2020-02-10 | 2020-06-30 | 福建天泉教育科技有限公司 | Message flow limiting method and storage medium |
CN111352746B (en) * | 2020-02-10 | 2023-07-07 | 福建天泉教育科技有限公司 | Message flow limiting method and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20170192819A1 (en) | Method and electronic device for resource allocation | |
CN103297395B (en) | The implementation method of a kind of Internet service, system and device | |
CN103309738A (en) | User job scheduling method and device | |
CN110297707A (en) | A kind of method for message transmission and device | |
CN103634275A (en) | Multi-device management and task migration methods and management server | |
CN104063279A (en) | Task scheduling method and device and terminal | |
US20090070766A1 (en) | Dynamic workload balancing in a thread pool | |
TWI786527B (en) | User code operation method of programming platform, electronic equipment and computer-readable storage medium | |
CN108540568B (en) | Computing capacity sharing method and intelligent equipment | |
CN104253814A (en) | Streaming media processing method, server and browser | |
CN105656763A (en) | Message pushing method and message pushing device | |
CN108922524A (en) | Control method, system, device, Cloud Server and the medium of intelligent sound equipment | |
WO2021129240A1 (en) | Skill scheduling method and apparatus for voice conversation platform | |
Zhu et al. | Job scheduling for cloud computing integrated with wireless sensor network | |
CN105786909A (en) | Message queue backlog load self-adaptive application triggering method and system | |
CN112988362A (en) | Task processing method and device, electronic equipment and storage medium | |
CN104144202A (en) | Hadoop distributed file system access method, system and device | |
CN110237536A (en) | Personalized game service providing method and device, electronic equipment and storage medium | |
CN114461393A (en) | Multitask scheduling method, multitask scheduling device, electronic equipment, multitask scheduling system and automatic driving vehicle | |
CN107342929B (en) | Method, device and system for sending new message notification | |
CN103299298B (en) | The method and system of process business | |
CN110221878A (en) | Game service updating method and device, electronic equipment and storage medium | |
CN104750545A (en) | Process scheduling method and device | |
CN113326025A (en) | Single cluster remote continuous release method and device | |
US8510426B2 (en) | Communication and coordination between web services in a cloud-based computing environment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20210603 Address after: 25, 5th floor, shuangjingfang office building, 3 frisha street, 189352, Singapore Applicant after: Zhuomi Private Ltd. Address before: Room 1101, Santai Commercial Building, 139 Connaught Road, Hong Kong, China Applicant before: HONG KONG LIVE.ME Corp.,Ltd. |
|
TA01 | Transfer of patent application right | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20191001 |
|
RJ01 | Rejection of invention patent application after publication |