The content of the invention
Present specification describes a kind of control method and device of message traffic, flow control to message and right is realized
The traffic shaping of multipart, so as to improve the treatment effeciency of consumer.
First aspect, there is provided a kind of control method of message traffic, including:
Receive at least two of producer's transmission the first service message for belonging to different service types;
First service message is stored in buffer pool;
In each time slot, the second service message that quantity is the first numerical value is extracted from the buffer pool, described the
Two service messages are the message for belonging to the different service types, and each type of service message in second service message
Quantity has the first ratio value;
Second service message is sent to consumer.
In a kind of possible embodiment, at least two of the reception producer transmission belongs to different service types
Before first service message, in addition to:
The configuration message of user's input is received, the configuration message is used to set at least one time slot and first ratio
Example value;
Wherein, each time slot at least one time slot has identical duration.
In a kind of possible embodiment, second business that the first quantitative value is extracted from the buffer pool disappears
Breath, including:
According to first ratio value, second service message is extracted at random from the buffer pool.
In a kind of possible embodiment, second business that the first quantitative value is extracted from the buffer pool disappears
Breath, including:
Obtain the reception time for receiving first service message;
According to first ratio value and the reception time, second business is extracted from the buffer pool and is disappeared
Breath.
In a kind of possible embodiment, the buffer pool includes multiple storage regions;In the multiple storage region
Each storage region storage the first service message belong to same type of service.
Second aspect, there is provided a kind of control device of message traffic, including:
Receiving unit, for receiving at least two of producer's transmission the first service messages for belonging to different service types;
Memory cell, for first service message to be stored in buffer pool;
Extraction unit, in each time slot, the second industry that quantity is the first numerical value to be extracted from the buffer pool
Business message, second service message is the message for belonging to the different service types, and each in second service message
The quantity of type of service message has the first ratio value;
Transmitting element, for sending second service message to consumer.
In a possible design, the receiving unit is additionally operable to:
The configuration message of user's input is received, the configuration message is used to set at least one time slot and first ratio
Example value;
Wherein, each time slot at least one time slot has identical duration.
In a possible design, the extraction unit is specifically used for, according to first ratio value, from the buffering
Second service message is extracted in pond at random.
In a possible design, the extraction unit is specifically used for, and obtains and receives connecing for first service message
Between time receiving;
According to first ratio value and the reception time, second business is extracted from the buffer pool and is disappeared
Breath.
In a possible design, the buffer pool includes multiple storage regions;It is every in the multiple storage region
First service message of one storage region storage belongs to same type of service.
The control method and device for the message traffic that this specification provides, at least two category sent by receiving the producer
In the first service message of different service types, the first service message is stored in buffer pool, in each time slot, postponed
Rush in pond and extract the second service message of the first quantitative value, and be sent to consumer.Realize when the producer sends the speed of message
When degree handles the speed of message much larger than consumer, to sending to the control of the message traffic of consumer.Wherein, buffer pool is drawn
It is divided into multiple storage regions, each storage region is used for the first service message for storing identical services type, helps speed up the
The extraction rate of two service messages.Meanwhile second service message include the message of different service types, and wherein different business class
The quantity of each type of service message in type message has the first ratio value, and first ratio value is with consumer to all types of message
Disposal ability matches, and realizes and carries out traffic shaping to the message sent to consumer according to type of message.Generally speaking, carry
The high treatment effeciency of consumer and the handling capacity of message center.
Embodiment
Below in conjunction with the accompanying drawings, the multiple embodiments disclosed this specification are described.
Mismatched as previously described, because producers and consumers be present and processing message capability be present, and consumer receives
Multipart be situation about being delivered at random by message center, i.e., message center is uncontrollable is sent in the message of consumer
The ratio of all types of message.
In one example, as shown in Fig. 2 (a), it is Class1, type 2, type 3 and class that the producer, which sends type of service,
The message total amount of type 4 is 8000, and the message ratio of four types is 3:1:4:2.Message center is receiving all types of disappear
After breath, the ability (e.g., consumer can handle the ability of message be up to 3000) of message, Cong Zhongsui can be handled according to consumer
Machine extraction message is sent to consumer.Consumer receives 3000 message that message center is sent, but the message ratio of four types
Example may be then uncertain.Such as, can be 3:2:2:3, it is also possible to be 5:1:1:3, or other ratios.
In another example, as shown in Fig. 2 (b), and when the message total amount that the producer sends four types is 7500
Bar, the message ratio of four types is 2:1:2:5.The total amount that consumer handles message is still 3000, but through message center
After random extraction is sent, the message ratio for four types that consumer receives still may be uncertain.Such as, can be 2:1:
5:5, it is also possible to be 1:5:3:1, or other ratios.
Because consumer is when handling all types of message, it is sometimes desirable to can a certain type of multiprocessing message, but according to preceding
Example is stated, message center is that the ratio of all types of message can not be controlled.Therefore, multiple implementations that this specification discloses
Example provides a kind of message control method and device, and ratio all types of in the message of consumer can be sent to control message center
Example, so that the ratio of all types of message can match the disposal ability of consumer, and then the throughput for improving message center is (single
The speed of data is successfully delivered in the time of position, generally with BPS (bits per second, bps) for unit) and consumption
The treatment effeciency of person.
It is understood that the control method for the message traffic that multiple embodiments that this specification discloses provide can also be applied
In application scenarios as shown in Figure 1, in Fig. 1, producer's (e.g., cashier etc.) can create message, and (e.g., Alipay pays and ordered
List, wechat pay invoice, Web bank's pay invoice, apple pay (Apple Pay) pay invoice etc.), and the message is sent out
Deliver to message center (e.g., Taobao, day cat store, Jingdone district etc.).Message center the message is handled (e.g., flow control and
Traffic shaping etc.) after, the message extracted in processing procedure is sent to consumer (e.g., Alipay, wechat, Unionpay's system etc.).
Consumer is handled the message received from message center and (e.g., audits sequence information and complete order and pay).
The producer, consumer and message center (also referred to as message system) can be a kind of component.The component i.e., one
Individual module units, it has interface of about fixed pattern specification, and clear and definite use environment, can be by independent deployment, by the 3rd
Side assembles to each component, and may operate in server.The producer can be the group that message is sent using message center
Part, it can such as create the website of message.Consumer can be using the component of message system reception message, its processing to message
Ability is limited.Consumer is before message is received, it will usually is different types of according to itself disposal ability to message
Message arrangement resource is (such as:Server count, Thread Count etc.).The quantity of these usual resources is just fixed up after configuration is complete,
That is for consumer within the unit interval, treatable all types of message number is substantially fixed.Message center can be independent
Dispose among a producer and a consumer, for coordinating the disposal ability of producers and consumers.Message center can pass through stream
Amount control and traffic shaping, to coordinate the disposal ability of producers and consumers.Wherein, the purpose of flow control is that solve production
The speed that person and the unmatched problem of consumers ability, the i.e. producer create message is far longer than the speed that consumer handles message
Degree.Specifically, after message center receives the message of the producer, message is buffered in buffer pool first, then according to restriction
Speed is delivered to consumer.The purpose of traffic shaping is message center is sent into the message of consumer, the ratio of various types of messages
Example can match the disposal ability of consumer.
It should be noted that the above-mentioned producer, consumer and message center can be at least one.As the producer and consumption
When person is multiple, multiple producers and consumers can share a message center.In addition, a producer can be correspondingly multiple
Consumer, and a consumer can also correspond to multiple producers.When message center is multiple, what some producer created disappears
Breath, which can be sent to one or more message centers, consumer, can receive the message from multiple message centers.
Fig. 3 is the control method flow chart for the message traffic that one embodiment that this specification discloses provides.Methods described
Executive agent can be the equipment with disposal ability:Server either system or device, e.g., the message center in Fig. 1,
As shown in figure 3, methods described specifically includes:
Step S310, receive at least two of producer's transmission the first service message for belonging to different service types.
The producer in this step is by taking website as an example, such as Taobao or day cat store.The foreground website of the producer can lead to
Cross terminal and be shown to user, the component of back-office support may operate in server.
Specifically, user can browse information by the producer displayed on the terminals, and perform certain operations, e.g., pay
Money operates.When receiving the operational order of user's execution payment operation, the producer can eject the means of payment selection page, example
Such as, as shown in figure 4, the means of payment for being available for user to select have flower in Alipay, Yuebao, account balance, and support
The deposit card of quick payment, including Bank of China, China Construction Bank, China Merchants Bank, the Industrial and Commercial Bank of China, Bank of China, friendship
Logical bank and Bank of Beijing.Multiple pay invoices can produce a variety of payment informations, for example, user selection using flower enter
Row is paid, then produces flower payment information, and another user selection remaining sum that accesses to your account is paid, then produces account balance branch
Pay information etc..Now, the first service message of different service types can be that the means of payment is flower order messages and payment
Mode is order messages that account balance is paid etc..
Step S320, the first service message is stored in buffer pool.
In this step, the speed that message is created because of the producer is far longer than the speed of consumer's processing message, it is necessary to will connect
The first service message received is stored in buffer pool, is then delivered to consumer with certain speed, so as to realize to message
The control of flow.First service message, which is stored in buffer pool, can numerous embodiments.
For example, by the first service message random storage in buffer pool.In another example buffer pool is divided into multiple memory blocks
Domain, according to the type of service of the first service message, the first service message for belonging to same type of service is stored in depositing for division
In storage area domain, i.e., the first service message of each storage region storage in multiple storage regions belongs to same type of service.
In this way, it is possible to reduce the time of same type of first service message of extraction.
In one example, as shown in figure 5, buffer pool 500 is divided into N number of region, by type A the first service message
In zone 1, the first service message of type B is stored in region 2 and 3 for storage, and the first service message of Type C is stored
In region 4.Remaining region can also be stored with other service messages of same type, and same type can be type A, class
Type B or Type C, or the other types different from type A, type B and Type C.
Step S330, in each time slot, the second service message that quantity is the first numerical value, institute are extracted from buffer pool
It is the message for belonging to different service types to state the second service message, and the quantity of each type of service message in the second service message
With the first ratio value.
In this step, time slot (slot) and the first quantitative value can be pre-set.Installation warrants include consumption
The quantity of processing message in the disposal ability of person, i.e. unit interval (for example, 1s, 1min or 1h etc.).
Specifically, multiple time slots are set, and each time slot has identical duration.For example, when pre-setting 100
Between groove, the duration of each time slot is 10ms.Because the maximum speed that consumer handles message is 3000 per second.Therefore,
In order to ensure in this 100 time slots, the message number that consumer receives is in the range of disposal ability (when in the unit interval
Between the extraction of slot number amount * each time slots the treatable size of message of message count≤consumer), the first quantitative value is (namely each
Time slot extraction message count) maximum occurrences be 3000/100=30 bars.So the value of the first quantitative value should be little
In 30, for example, presetting the first quantitative value as 30.It should be noted that the first quantitative value can also be determined first, then determine
The number and duration of time slot, multiple embodiments that this specification discloses are not construed as limiting to this.
In this step, it can also be pre-set for the first ratio value.It should be noted that in the first service message
The message of different service types, it is different in the processing energy of consumer.For example, consumer is the component in Alipay, it is used for
Handle pay invoice.The type of service of its manageable message has:Flower pay invoice, bank card pay invoice, more than account
Volume pay invoice and Yuebao pay invoice.
Wherein, account balance is the remaining sum of Alipay account, and consumer is fastest to such order processing;Flower be
The means of payment that Alipay is picking, consumer take second place to such order processing speed;Yuebao is a kind of reason in Alipay
The remaining sum of property product, consumer to such order processing speed third;And bank card payment needs to detain in bank card
Money, consumer are most slow to such order processing speed.For these four different service types, consume this and handle every message consumption
When (millisecond) data it is as shown in table 1 below.
Table 1
Type of message |
Consumer handles every message and takes (millisecond) |
Yuebao pay invoice |
30 |
Account balance pay invoice |
5 |
Flower pay invoice |
10 |
Bank card pay invoice |
50 |
Consumer is limited to the disposal ability of message, and consumer would generally be according to the disposal ability of itself, for difference
The message arrangement resource of type is (such as:Server count, Thread Count etc.).The quantity of these usual resources is just fixed after configuration is complete
Get off, i.e. consumer is within the unit interval, and the ratio of all types of message of processing and quantity are fixed in consumer's unit interval.
Consuming this according to these four different types of service, can configure the resource of varying number.It is for example, single with consumption consumer is postponed
The quantity of four class message of processing is as shown in table 2 in the time of position.
Table 2
Type of message |
Consumer's unit interval (1s) treatable quantity |
Yuebao pay invoice |
300 |
Account balance pay invoice |
400 |
Flower pay invoice |
600 |
Bank card pay invoice |
200 |
Total amount |
1500 |
First ratio value of four types is 3 in table 2:4:6:2.Therefore, all types of service messages in the second service message
The first ratio value, can be configured according to all types of ratios is handled in consumer's unit interval.
In this step, the second service message that quantity is the first numerical value is extracted from buffer pool.
Specifically, in each time slot, the second industry of the first quantitative value is extracted from buffer pool according to the first ratio value
Business message.In one example, as shown in fig. 6, being stored with the message of four kinds of types of service in message format pond.Wherein, type
1st, the message number of type 2, type 3 and type 4 is respectively 1500,1000,3000 and 2000.Class set in advance
Type 1, type 2, the first ratio value of type 3 and type 4 are 3:1:4:2.Time slot set in advance is 100, each time
The length of groove is 10ms, and the first quantitative value set in advance is 30.That is, in each time slot, message center from
The message 9,3,12 and 6 of Class1, type 2, type 3 and type 4, each time are extracted in message format pond respectively
The size of message of extraction is 30 in groove, and the message total amount of extraction is 3000 in 100 time slots.In another example, root
According to first ratio value, message center extracts the second service message of the first quantitative value at random from buffer pool.In another example
In son, before the second service message is extracted, message center obtains the reception time of the first service message, then according to the first ratio
Example value and reception time, the second service message is extracted from buffer pool.In another example, according to the first ratio value, message
The second service message is extracted respectively in multiple storage regions that center divides from buffer pool.
Step S340, the second service message is sent to consumer.
In this step, consumer receives the second service message that message center is sent, and the is obtained from the second service message
The all types of message of one ratio.Because the second service message includes all types of message of the first ratio, with consumer to all types of
The disposal ability of message matches, and can increase substantially treatment effeciency of the consumer to message.
Alternatively, before step S310, step can also be included:The configuration message of user's input is received, configures message
For setting at least one time slot and the first ratio value in message center, and each time slot at least one time slot
With identical duration.Wherein, user can be the technical staff for determining configuration message., can be to step by performing this step
The time slot and the first ratio value used in S330 is preset or adjusted.
In a word, the control method for the message traffic that one embodiment that this specification discloses provides, by receiving the producer
At least two sent belong to the first service message of different service types, and the first service message is stored in buffer pool,
In each time slot, the second service message of the first quantitative value is extracted out of buffer pool, and be sent to consumer.Realize when life
When the speed that production person sends message handles the speed of message much larger than consumer, to sending to the control of the message traffic of consumer
System.Wherein, buffer pool is divided into multiple storage regions, each storage region is used for the first business for storing identical services type
Message, help speed up the extraction rate of the second service message.Meanwhile second service message include different service types and disappearing
Breath, and the quantity of each type of service message wherein in different service types message has the first ratio value, first ratio value
All types of message handling abilities are matched with consumer, realizes and the message sent to consumer is carried out according to type of message
Traffic shaping.Generally speaking, the treatment effeciency of consumer and the handling capacity of message center are improved.
With the control method of above-mentioned message traffic accordingly, multiple embodiments that this specification discloses also provide a kind of message
The control device of flow, as shown in fig. 7, the device includes:
Receiving unit 701, at least two the first business for belonging to different service types for receiving producer's transmission disappear
Breath.
Alternatively, receiving unit 701 is additionally operable to, and receives the configuration message of user's input, and configuration message is used to set at least
One time slot and the first ratio value.Wherein, each time slot has identical duration, the first ratio value at least one time slot
For extracting the second service message from buffer pool.
Memory cell 702, for the first service message to be stored in buffer pool.
Extraction unit 703, in each time slot, the second business that quantity is the first numerical value to be extracted from buffer pool
Message, the second service message are the message for belonging to different service types, and each type of service message in the second service message
Quantity has the first ratio value.
Optionally, extraction unit 703 is specifically used for, and according to the first ratio value, extracts the second business at random from buffer pool
Message.
Optionally, extraction unit 703 is specifically used for, and obtains the reception time for receiving the first service message.And according to
One ratio value and reception time, the second service message is extracted from buffer pool.
Transmitting element 704, for sending the second service message to consumer.
Optionally, buffer pool includes multiple storage regions.Memory cell 702 is specifically used for, and according to type of service, will belong to
First service message of same type of service is stored in storage region, i.e., each storage region in multiple storage regions is deposited
First service message of storage belongs to same type of service.
Extraction unit 703 is specifically used for, and according to the first ratio value, the second service message is extracted from multiple storage regions.
The function of each functional module for one embodiment device that this specification discloses, can pass through above method embodiment
Each step realize that therefore, the specific work process for the device that one embodiment that this specification discloses provides is not multiple herein
Repeat.
The control device for the message traffic that one embodiment that this specification discloses provides, receiving unit receive producer's hair
At least two sent belong to the first service message of different service types, and the first service message is stored in buffer pool by memory cell
In, extraction unit extracts the second service message of the first quantitative value in each time slot out of buffer pool, and transmitting element is sent
To consumer.Realize when the speed that the producer sends message handles the speed of message much larger than consumer, to sending to disappearing
The control of the message traffic of the person of expense.Wherein, buffer pool is divided into multiple storage regions, each storage region is identical for storing
First service message of type of service, help speed up the extraction rate of the second service message.Meanwhile second service message include
The message of different service types, and the quantity of each type of service message wherein in different service types message has the first ratio
Value, first ratio value match with consumer to all types of message handling abilities, realize according to type of message to sending extremely
The message of consumer carries out traffic shaping.Generally speaking, the treatment effeciency of consumer and the handling capacity of message center are improved.
It will be appreciated that in said one or multiple examples, this specification discloses more those skilled in the art
Function described by individual embodiment can be realized with hardware, software, firmware or their any combination.Realized when using software
When, these functions can be stored in computer-readable medium or referred to as the one or more on computer-readable medium
Order or code are transmitted.
Above-described embodiment, to the purpose of multiple embodiments of this specification disclosure, technical scheme and have
Beneficial effect is further described, and should be understood that the multiple embodiments that the foregoing is only this specification disclosure
Embodiment, be not used to limit this specification disclose multiple embodiments protection domain, it is all in this explanation
On the basis of the technical scheme for multiple embodiments that book discloses, any modification, equivalent substitution and improvements done etc., it all should wrap
Within the protection domain for including the multiple embodiments disclosed in this specification.