WO2017162059A1 - 消息管理方法及装置、消息预读方法及装置 - Google Patents

消息管理方法及装置、消息预读方法及装置 Download PDF

Info

Publication number
WO2017162059A1
WO2017162059A1 PCT/CN2017/076400 CN2017076400W WO2017162059A1 WO 2017162059 A1 WO2017162059 A1 WO 2017162059A1 CN 2017076400 W CN2017076400 W CN 2017076400W WO 2017162059 A1 WO2017162059 A1 WO 2017162059A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
number range
range
queue
messages
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.)
Ceased
Application number
PCT/CN2017/076400
Other languages
English (en)
French (fr)
Inventor
陈建锋
林强
陈舟锋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Publication of WO2017162059A1 publication Critical patent/WO2017162059A1/zh
Priority to US16/138,856 priority Critical patent/US11165740B2/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/21Monitoring or handling of messages
    • H04L51/234Monitoring or handling of messages for tracking messages
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/21Monitoring or handling of messages
    • H04L51/224Monitoring or handling of messages providing notification on incoming messages, e.g. pushed notifications of received messages
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/568Storing data temporarily at an intermediate stage, e.g. caching
    • H04L67/5682Policies or rules for updating, deleting or replacing the stored data
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/21Monitoring or handling of messages
    • H04L51/216Handling conversation history, e.g. grouping of messages in sessions or threads

Definitions

  • the present invention relates to the field of communications, and in particular, to a message management method and apparatus, and a message pre-reading method and apparatus.
  • Message queue first-in, first-out Messages that enter the queue first are consumed first.
  • Message reliability Messages are persisted to disk after entering the message queue, ensuring that messages are not lost due to power loss.
  • the message will be deleted by the user only after the purchase is successful, otherwise it can be consumed all the time.
  • Active message A message that can be consumed.
  • Inactive message A message being consumed by a user.
  • Deleted message A message that is actively marked as consumed by the user.
  • the processing of the message is, first, the message producer (also known as the client) writes the produced message to the disk; when the cache is empty, triggers a pre-read operation to pre-read the message from the disk into the cache; Consumers (also known as clients) read messages from the cache for consumption. If the message consumption fails, the message is revived to disk.
  • the message producer also known as the client
  • Consumers also known as clients
  • the reliable message system persists the read status of the message on the server side to ensure that the message is "at least once consumed.” At the same time, it needs to return the first queued message in the current message queue to ensure the first-in-first-out characteristics of the message queue.
  • Each message entering the message queue is assigned a message number (that is, the message ID), and the message number is ordered in order according to the message enqueue. If the message is not successfully consumed, it will be re-entered to ensure that it can be consumed again.
  • the current first queued message of the system is dynamically changing.
  • the first queued message is obtained by adding two attributes to the metadata information of the message, one attribute for recording whether the message has been successfully consumed, and another attribute for recording the location of the next message.
  • the consumption state of the message is set to “not consumed”, and the message state is set to “consuming consumption” after the user consumes the message, and the state of the message is actively set after the user successfully consumes the message. Set to "consumed”.
  • the server records the location of the first "not consumed” message in the current system.
  • the related technology needs to sequentially consume messages in order to ensure the first-in-first-out of messages, and cannot support concurrent consumption, which limits the processing speed of messages.
  • modifying the attributes of messages may also cause random write of disks, which seriously affects system performance.
  • the first queued message is obtained by dividing a message queue into two parts, namely "unconsumed message queue” and "message queue being consumed”. After the message is sent to the system, it enters the "unconsumed message queue”. After the user obtains the message, the message "un-consumed message queue” enters the "message queue being consumed”. After the consumption is successful, the user actively deletes the message from the "message queue being consumed”. Otherwise, after the agreed time is exceeded, the system will move the message from the "message queue being consumed" to the end of the "unconsumed message queue", so that the message can be consumed again to ensure that the message is consumed at least once. When the message consumption fails, the system needs to add the message to the end of the "unconsumed message queue” again, which will seriously affect the first-in-first-out characteristics of the message.
  • the object of the present invention is to provide a message management method and device, a message pre-reading method and device, which can improve the message read-ahead speed and improve system performance under the premise of ensuring the first-in-first-out characteristics of the message.
  • the present invention provides a message management method, including:
  • the number range and management message are adjusted according to the state change of the message in the message queue.
  • the above method may further have the following features, the number range includes at least one number interval, and any two number intervals do not overlap.
  • each of the number ranges in the number range is arranged in order from the smallest right end message number of the interval.
  • the foregoing method may further have the following feature: the adjusting the number range and the management message according to the state change of the message in the message queue, including:
  • the number range is narrowed, and the number of the retrieved message is excluded from the number range, and The fetched message is marked as a non-consumable message in the message queue.
  • the number range is expanded, so that the timeout is not returned.
  • the number of the result-based message is included in the number range, and the message that the timeout has not returned a consumption result is marked as a consumable message in the message queue.
  • the foregoing method may further have the following feature: the adjusting the number range and the management message according to the state change of the message in the message queue, including:
  • the foregoing method may further have the following feature: the adjusting the number range and the management message according to the state change of the message in the message queue, including:
  • the message management method in the embodiment of the present invention manages the number of the consumable message in the message queue by using the number range, improves the message read-ahead speed under the premise of ensuring the first-in-first-out feature of the message, and improves the performance of the message system.
  • the present invention also provides a message management apparatus, including:
  • a recording module configured to record, in the memory, a range of numbers of consumable messages in the message queue
  • an adjustment module configured to adjust the number range and the management message recorded by the recording module according to a state change of a message in the message queue.
  • the above device may further have the following features, the number range includes at least one number interval, and any two number intervals do not overlap.
  • each of the number ranges in the number range is arranged in order from the smallest right end message number of the interval.
  • the adjustment module includes:
  • a reduction unit configured to reduce the number range after the message read in the cache queue is pre-read to the cache for consumption by the client, and exclude the number of the extracted message from the number range
  • the fetched message is marked as a non-consumable message in the message queue.
  • the adjustment module includes:
  • an expansion unit configured to expand the number range when the client timeout does not return the consumption result, so that the number of the message whose timeout has not returned the consumption result is included in the number range, and in the message queue The message that the timeout has not returned the consumption result is marked as a consumable message.
  • the adjustment module includes:
  • the adjustment module includes:
  • An interval deleting unit configured to: after the pre-reading the message from the message queue to the cache, if all the consumable messages corresponding to the non-maximum numbered interval in the number range have been pre-read, from the number range Delete the non-maximum numbered interval.
  • the message management apparatus of the embodiment of the present invention manages the number of the consumable message in the message queue by using the number range, improves the message read-ahead speed under the premise of ensuring the first-in-first-out feature of the message, and improves the performance of the message system.
  • the present invention also provides a message pre-reading method, including:
  • the above method may further have the following features, the number range includes at least one number interval, and any two number intervals do not overlap.
  • the message pre-reading method of the embodiment of the present invention can quickly query the number of the set number of consumable messages with the smallest number in the message queue according to the number range of the consumable messages in the message queue recorded in the order of the message number in the memory, and It also guarantees the FIFO nature of the message, improves the message read-ahead speed, and improves the performance of the message system.
  • the present invention also provides a message pre-reading apparatus, including:
  • a querying module configured to query a number range of the consumable messages in the message queue recorded in the memory, and determine a number of the N consumable messages with the smallest number in the message queue, where N is a natural number;
  • the above device may further have the following features, the number range includes at least one number interval, and any two number intervals do not overlap.
  • the message pre-reading apparatus of the embodiment of the present invention can quickly query the number of the set number of consumable messages with the smallest number in the message queue according to the number range of the consumable messages in the message queue recorded in the order of the message number in the memory, and It also guarantees the FIFO nature of the message, improves the message read-ahead speed, and improves the performance of the message system.
  • the present invention also provides a message management device comprising the message according to any of the preceding claims. Management device.
  • the message management device of the embodiment of the invention includes a message management device, which manages the number of the consumable message in the message queue by using the number range, improves the message read-ahead speed and improves the performance of the message system under the premise of ensuring the first-in-first-out feature of the message. .
  • the present invention also provides a message pre-reading apparatus comprising the message pre-reading apparatus according to any of the preceding claims.
  • the message pre-reading device of the embodiment of the present invention includes a message pre-reading device, which can quickly query the set number of the smallest number in the message queue according to the number range of the consumable messages in the message queue recorded in the order of the message number in the memory.
  • the number of consumption messages is also guaranteed, and the FIFO feature of the message is also guaranteed, which improves the speed of message read-ahead and improves the performance of the message system.
  • FIG. 1 is a schematic diagram of a process of processing a message according to an embodiment of the present invention
  • FIG. 2 is a flowchart of a message management method according to Embodiment 1 of the present invention.
  • FIG. 3 is a schematic diagram of expanding a precursor cursor field of a message MsgID when reviving a message MsgID;
  • FIG. 4 is a structural block diagram of a message management apparatus according to Embodiment 2 of the present invention.
  • FIG. 5 is a flowchart of a message pre-reading method according to Embodiment 3 of the present invention.
  • FIG. 6 is a structural block diagram of a message pre-reading apparatus according to Embodiment 4 of the present invention.
  • FIG. 7 is a structural block diagram of a message management device according to Embodiment 5 of the present invention.
  • FIG. 8 is a structural block diagram of a message pre-reading apparatus according to Embodiment 6 of the present invention.
  • FIG. 9 is a structural block diagram of a device 900 according to Embodiment 7 of the present invention.
  • FIG. 1 is a schematic diagram of a process of processing a message according to an embodiment of the present invention. As shown in FIG. 1, in the embodiment of the present invention, the processing process of the message is:
  • the client writes the generated message to the disk, and the message enters the message queue.
  • the consumption result is returned to the server
  • the management module processes the corresponding message in the disk according to the consumption result: if the consumption is successful, the corresponding message in the message queue is deleted, and if the client does not return the message that the message consumption is successful, the message consumption is considered to be failed, the message is revived, and the message queue is queued.
  • the message in is marked as a consumable message.
  • the range of numbers of consumable messages in the message queue can be recorded in memory with a cursor.
  • FIG. 2 is a flowchart of a message management method according to Embodiment 1 of the present invention. As shown in FIG. 2, in this embodiment, the message management method may include the following steps:
  • Step S201 recording, in the memory, a number range of the consumable message in the message queue
  • the number range may include at least one number interval, and any two number intervals do not overlap.
  • the message number represents the order in which the message enters the message queue. The smaller the message number, the earlier the message enters the message queue. For example, message 10 is the 10th message entering the message queue.
  • each number interval in the number range is arranged in the order of the right end point message number from small to large.
  • a range of numbers is referred to as a set of cursor fields
  • a numbered range in such a range of numbers is referred to as a cursor field.
  • the cursor field is represented by the left closed right open interval.
  • the message numbers at the two endpoints of the numbered range of the number range are referred to as the left endpoint message number and the right endpoint message number, respectively.
  • Step S202 adjusting the number range and the management message according to the state change of the message in the message queue.
  • adjusting the number range and the management message according to the state change of the message in the message queue may include: after the message read in the message queue is pre-read to the cache for consumption by the client, the number range is reduced. The number of the fetched message is excluded from the range of numbers and the fetched message is marked as a non-consumable message in the message queue.
  • the number range ⁇ [1,101) ⁇ is reduced to ⁇ [11,101) ⁇ , so that the numbers of the 10 messages of Message 1 to Message 10 are excluded from the range of the number of consumable messages.
  • the message that the message consumer takes out from the cache enters the inactive message queue and belongs to the inactive message, that is, the message being consumed by the user. If these messages are successfully consumed, then these messages are non-consumable messages and will be excluded from the scope of consumable messages. Here, all the messages taken out of the cache are processed according to the success of the consumption. If the consumption fails, the subsequent reactivation mechanism is added to the scope of the consumable message.
  • adjusting the number range and the management message according to the state change of the message in the message queue may further include: if the client timeout does not return the consumption result, the number range is expanded, so that the timeout does not return the message of the consumption result.
  • the number is included in the range of numbers, and the message that the timeout has not returned a consumption result is marked as a consumable message in the message queue. If the client does not return the consumption result after the timeout, the message consumption may be considered as failure. Therefore, the message that the timeout does not return the consumption result is called the consumption failure message. This is the resurrection mechanism of the news of consumption failure.
  • the message can be re-consumed and consumed on a first-in-first-out basis.
  • the number range is expanded, and the number of the message that fails to be consumed is included in the number range, which can be implemented by the following steps:
  • the news of consumption failure is the news of the resurrection.
  • Step a assuming that the message ID of the revived message is MsgID, according to the MsgID, locate the upper bound cursor field of the cursor domain [MsgID, MsgID+1) in the cursor domain set, and record the upper bound cursor field as [Upper_BeginID, Upper_EndID), wherein
  • the upper bound cursor field of the MsgID refers to the cursor field whose first right endpoint message number is greater than MsgID+1 in the cursor domain set;
  • Step b if the upper bound cursor field [Upper_BeginID, Upper_EndID) already contains the MsgID, the process ends, and the cursor domain is no longer adjusted;
  • Step c if the left endpoint message number of the upper bound cursor field is Upper_BeginID>MsgID, perform subsequent operations to adjust the cursor domain set to make the cursor domain set cover the MsgID;
  • Step d obtaining a precursor cursor field [Pre_BeginID, Pre_EndID) of the message MsgID, wherein the precursor cursor field of the message MsgID refers to a cursor domain whose first right endpoint message number is smaller than MsgID+1 in the cursor domain set;
  • Step e if the precursor cursor field of the message MsgID does not exist, add [MsgID, MsgID+1) to the cursor domain set, and then end the process;
  • Step f If the predecessor cursor domain of the message MsgID exists, the cursor domain [Pre_BeginID, MsgID+1) and the cursor domain [MsgID, Upper_EndID) are added to the cursor domain set by the cursor domain with a smaller range and not exceeding MAX_RANGE_SIZE to replace the precursor.
  • Cursor field or upper bound cursor field (if the cursor field [Pre_BeginID, MsgID+1) has a small range, replace the precursor cursor field [Pre_BeginID, Pre_EndID) with [Pre_BeginID, MsgID+1), if the cursor domain is both The [MsgID, Upper_EndID) range is small, and the upper bound cursor field [Upper_BeginID, Upper_EndID) is replaced by [MsgID, Upper_EndID), where MAX_RANGE_SIZE is the maximum range of the preset cursor field;
  • Step g if the precursor cursor field of the message MsgID exists, and the range of the cursor domain [Pre_BeginID, MsgID+1) and the cursor domain [MsgID, Upper_EndID) exceeds MAX_RANGE_SIZE, then [MsgID, MsgID+1) is added to the cursor domain set. .
  • step f if the size of the set of cursor fields reaches the upper limit (the upper limit is the maximum size of the set of cursor fields, represented by MAX_COUNT), then the new cursor domain cannot be added, but the upper bound cursor field is selected. Or the precursor cursor field is expanded. In particular, if the upper bound cursor field is the largest cursor domain, only its precursor cursor domain can be expanded. That is, in the case of MsgID-Pre_BeginID ⁇ Upper_EndID-MsgID and MsgID-Pre_BeginID ⁇ MAX_RANGE_SIZE, the precursor cursor field is expanded to [Pre_BeginID, MsgID+1) as shown in FIG. FIG.
  • FIG. 3 is a schematic diagram of enlarging the precursor cursor field of the message MsgID when the message MsgID is revived.
  • PB represents Pre_BeginID
  • PE represents Pre_EndID
  • UB represents Upper_BeginID
  • UE represents Upper_EndID.
  • MAX_COUNT represents the total number of cursor fields that can be included in the set of cursor fields.
  • step f if the range of the cursor field [Pre_BeginID, MsgID+1) and the cursor field [MsgID, Upper_EndID) are the same and do not exceed MAX_RANGE_SIZE, the cursor field [Pre_BeginID, MsgID+1) may be randomly selected to replace the precursor cursor field or Select [MsgID, Upper_EndID) to replace the upper bound cursor field, or you can replace the precursor cursor field by default by selecting the cursor field [Pre_BeginID, MsgID+1).
  • Example 1 Assume that the current cursor domain set is ⁇ [5,101) ⁇ and the resurrection message number is 6. Message 6 has an upper bounding cursor field [5, 101), and message 6 is included in the upper bounding cursor field [5, 101). At this time, the cursor domain set is not adjusted. After the message 6 is revived, the cursor domain set is still ⁇ [5,101) ⁇ .
  • Example 2 Suppose the current cursor domain set is ⁇ [11,101) ⁇ , and the resurrection message number is 6. Message 6 has the upper bound cursor field [11, 101) and the left endpoint message number 11 of the upper bound cursor field [11, 101) is greater than 6, there is no precursor cursor field, and the cursor field [6, 7) is added to the cursor at this time. In the domain collection, after message 6 is revived, the cursor domain set is ⁇ [6,7), [11,101) ⁇ .
  • Example 3 Assume that the current cursor domain set is ⁇ [3,6), [11,101) ⁇ , and the resurrection message number is 6.
  • Message 6 has an upper bound cursor field [11, 101) and a precursor cursor field [3, 6).
  • the cursor field in the cursor field [3,7) and the cursor field [6,101) is smaller and the cursor field does not exceed MAX_RANGE_SIZE is [3,7).
  • the cursor field [3,7) is added to the cursor domain set replacement cursor.
  • Domain [3,6) after message 6 is revived, the cursor domain set is ⁇ [3,7), [11,101) ⁇ .
  • Example 4 Assuming that the current cursor domain set is ⁇ [1,101), [106,206) ⁇ , the resurrection message number is 103.
  • Message 103 has an upper bound cursor field [106, 206) and a precursor cursor field [1, 101). However, the range of the cursor field [1, 104) and the cursor field [103, 206) exceeds MAX_RANGE_SIZE (the above assumption is that MAX_RANGE_SIZE is 100).
  • the cursor field [3, 7) is added to the cursor domain set, and the message 103 is revived. After that, the set of cursor fields is ⁇ [1,101), [103,104), [106,206) ⁇ .
  • the number range is expanded, so that the number of the message that the consumption fails is included in the number range, and may include one of the following four cases:
  • the upper bound cursor field of the message MsgID exists in the current cursor domain set, and if the MsgID is included in the upper bound cursor field, the current cursor domain set is maintained unchanged.
  • the message number of the resurrection is MsgID
  • there is an upper bound cursor field of the message MsgID a precursor cursor field in which the message MsgID does not exist, and the start message number of the upper bound cursor field is larger than the MsgID.
  • the message number of the resurrection is MsgID
  • the upper bound cursor field [UB, UE) and the precursor cursor field [PB, PE) of the message MsgID exist in the current cursor domain set, and the extended precursor cursor domain [PB, MsgID+1)
  • the extended precursor cursor domain [PB, MsgID+1) is selected to replace the precursor cursor domain [PB, PE).
  • the message number of the resurrection is MsgID
  • the upper bound cursor field [UB, UE) and the precursor cursor field [PB, PE) of the message MsgID exist in the current cursor domain set, and the extended precursor cursor domain [PB, MsgID+1)
  • the cursor domain [MsgID, MsgID+1) is added to the current cursor domain set.
  • adjusting the number range and the management message according to the state change of the message in the message queue may include: deleting the message that the consumption is successful in the message queue if the client successfully consumes the message. Deletion here means that the message is deleted from the disk that stores the message queue, that is, deleted from the message queue.
  • adjusting the number range and the management message according to the state change of the message in the message queue may further include: after pre-reading the message from the message queue to the cache, all the non-maximum number intervals in the number range may be In the case where the consumption message has been pre-read, the non-maximum numbered interval is deleted from the number range.
  • the version number and version number update rule for the number range. For example, the initial version number of the set number range is 1; each time the number range is modified, the version number of the number range is incremented by 1; if the number range needs to be modified when the number range is modified, the version number of the modified number range is used as the number range version number.
  • the version number of the modified number range is used as the number range version number.
  • the message management method of the embodiment of the present invention manages the number of the consumable message in the message queue by using the number range, and ensures the first-in first-out feature of the message.
  • the number can be quickly queried according to the number range.
  • the number of the number of consumable messages with the lowest number in the message queue improves the message read-ahead speed and improves the performance of the message system under the premise of ensuring the first-in-first-out feature of the message.
  • the present invention also proposes a message management apparatus for implementing the above message management method.
  • the principle description in the above embodiment of the message management method is also applicable to the following embodiments of the message management apparatus.
  • FIG. 4 is a structural block diagram of a message management apparatus according to Embodiment 2 of the present invention.
  • the message management apparatus 400 may include a recording module 410 and an adjustment module 420.
  • the recording module 410 is configured to record, in the order of the message number, a range of numbers of the consumable messages in the message queue.
  • the adjustment module 420 is configured to adjust the number range and management message recorded by the recording module 410 according to the state change of the message in the message queue.
  • the number range may include at least one number interval, and any two number intervals do not overlap.
  • the FIFO nature of the message can be guaranteed.
  • the range of numbers of consumable messages can be used as the basis for querying bulk messages to be read ahead. Can be eliminated
  • the number range of the fee message not only quickly finds the batch message to be pre-read to the cache, but also guarantees the FIFO nature of the message.
  • the number range in the number range may be arranged in the order of the right end message number of the section from small to large.
  • the adjustment module 420 may include a reduction unit.
  • the reduction unit is configured to reduce the number range after excluding the cached message in the message queue from the cache for the client to consume, and exclude the number of the extracted message from the number range, and in the message queue
  • the fetched message is marked as a non-consumable message.
  • the adjustment module 420 can include an expansion unit.
  • the expansion unit is configured to expand the number range when the client timeout does not return the consumption result, so that the number of the message whose timeout has not returned the consumption result is included in the number range, and the timeout is not in the message queue. Messages that return a consumption result are marked as consumable messages.
  • the adjustment module 420 may include a message deletion unit.
  • the message deletion unit is configured to delete the message that the consumption is successful in the message queue if the client successfully consumes the message.
  • the adjustment module 420 may include an interval deletion unit.
  • the deleting unit is configured to delete the non-maximum numbering interval from the number range in the case that all the consumable messages corresponding to the non-maximum numbering interval in the number range have been pre-read after the message queue pre-reads the message to the buffer.
  • the message management apparatus of the embodiment of the present invention manages the number of the consumable message in the message queue by using the number range, and ensures the first-in-first-out feature of the message.
  • the number can be quickly queried according to the number range.
  • the number of the number of consumable messages with the lowest number in the message queue improves the message read-ahead speed and improves the performance of the message system under the premise of ensuring the first-in-first-out feature of the message.
  • FIG. 5 is a flowchart of a message pre-reading method according to Embodiment 3 of the present invention. As shown in FIG. 5, in this embodiment, the message pre-reading method may include the following steps:
  • Step S501 querying the number range of the consumable message in the message queue recorded in the memory, and determining the number of the N consumable messages with the smallest number in the message queue, where N is a natural number;
  • the number range may include at least one number interval, and any two number intervals do not overlap.
  • the number range of the consumable message in this step is the same as the number range in the foregoing message management method.
  • the number range may include at least one number interval, where the number range Each number interval may be arranged in the order of the right end message number of the interval from small to large, and any two number intervals in the number range do not overlap.
  • a range of numbers is referred to as a set of cursor fields, and a numbered range in such a range of numbers is referred to as a cursor field.
  • the cursor field is represented by the left closed right open interval.
  • Step S502 pre-reading the corresponding message from the message queue to the cache according to the determined number of the N consumable messages.
  • the N consumable messages are the N number of consumable messages in the message queue, which guarantee the FIFO characteristics of the message.
  • the message pre-reading method of the present invention is further illustrated by two specific examples.
  • the number of consumable messages in the message queue recorded in the order of the message number in memory is ⁇ [6,9), [11,101) ⁇ , and all messages in the range of the number are not identified as deleted messages.
  • the process of pre-reading five consumable messages from the message queue to the cache is: query number range ⁇ [6, 9), [11, 101) ⁇ , and determine that the number of the five consumable messages with the lowest number is 6, 7, 8, 11, 12; from the message queue, message 6, message 7, message 8, message 11, message 12 to the cache.
  • the message identified as deleted is a message that has been successfully consumed, such messages are not part of the consumable message, but the number of these messages may be included in the number range of the consumable message. This requires the number of these messages identified as deleted to be excluded when determining the pre-read message number based on the number range. See example 2 below for this situation.
  • the message pre-reading method of the embodiment of the present invention can quickly query the number of the set number of consumable messages with the smallest number in the message queue according to the number range of the consumable messages in the message queue recorded in the memory, and also ensure the message number.
  • the FIFO feature improves message read-ahead speed and improves message system performance.
  • FIG. 6 is a structural block diagram of a message pre-reading apparatus according to Embodiment 4 of the present invention.
  • the pre-reading device 600 can include a query module 610 and a pre-read module 620.
  • the query module 610 is configured to query the number range of the consumable messages in the message queue recorded in the memory, and determine the number of the N consumable messages with the smallest number in the message queue, where N is a natural number.
  • the pre-reading module 620 is configured to pre-read the corresponding message from the message queue to the cache according to the number of the N consumable messages determined by the query module 610.
  • the number range may include at least one number interval, and any two number intervals do not overlap.
  • the FIFO nature of the message can be guaranteed.
  • the range of numbers of consumable messages can be used as the basis for querying bulk messages to be read ahead.
  • the number range of consumable messages not only allows you to quickly find bulk messages to be pre-read to the cache, but also guarantees the FIFO nature of the messages.
  • the number range may include at least one number interval, and each number interval in the number range is arranged in the order of the right end end point message number from small to large, and any two numbers in the number range The intervals do not overlap.
  • a range of numbers is referred to as a set of cursor fields, and a numbered range in such a range of numbers is referred to as a cursor field.
  • the cursor field is represented by the left closed right open interval.
  • the message pre-reading device of the embodiment of the present invention can quickly query the number of the set number of consumable messages with the smallest number in the message queue according to the number range of the consumable messages in the message queue recorded in the memory, and also ensure the message number.
  • the FIFO feature improves message read-ahead speed and improves message system performance.
  • FIG. 7 is a structural block diagram of a message management device according to Embodiment 5 of the present invention.
  • the message management device 700 can include a message management device 400.
  • the message management device 400 may be any one of the foregoing message management device embodiments.
  • the message management apparatus 400 may be configured to record, in the order of the message number, the number range of the consumable message in the message queue in the memory, the number range includes at least one number interval, and any two number intervals do not overlap; and, according to the message queue The status change condition of the message is adjusted by the number range and management message.
  • the message management device in the embodiment of the present invention manages the number of the consumable message in the message queue by using the number range, and ensures the first-in-first-out feature of the message.
  • the number can be quickly queried according to the number range.
  • the number of the number of consumable messages with the lowest number in the message queue improves the message read-ahead speed and improves the performance of the message system under the premise of ensuring the first-in-first-out feature of the message.
  • FIG. 8 is a structural block diagram of a message pre-reading apparatus according to Embodiment 6 of the present invention.
  • the message pre-reading device 800 can include a message pre-reading device 600.
  • the message pre-reading device 600 can be any one of the foregoing message pre-reading device embodiments.
  • the message pre-reading device 600 can be used to query the number range of the consumable messages in the message queue recorded in the memory, and determine the number of the N consumable messages with the smallest number in the message queue, where N is a natural number; The number of the consumed message is pre-read from the message queue to the cache.
  • the number range may include at least one number interval, and any two number intervals do not overlap.
  • the message pre-reading device of the embodiment of the present invention can quickly query the number of the set number of consumable messages with the smallest number in the message queue according to the number range of the consumable messages in the message queue recorded in the memory, and also ensure the message number.
  • the FIFO feature improves message read-ahead speed and improves message system performance.
  • FIG. 9 is a structural block diagram of a device 900 according to Embodiment 7 of the present invention.
  • the device 900 can be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, and the like.
  • device 900 can include one or more of the following components: processing component 902, memory 904, power component 906, multimedia component 908, audio component 910, input/output (I/O) interface 912, sensor component 914, And a communication component 916.
  • Processing component 902 typically controls the overall operation of device 900, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations.
  • the processing component 902 can include one or more processors 920 to execute instructions to perform all or part of the steps of the above method, including: recording, in memory, a range of numbers of consumable messages in the message queue; The status change condition of the message adjusts the number range and the management message; queries the number range of the consumable message in the message queue recorded in the memory, and determines the number of the N consumable messages with the smallest number in the message queue, where N is a natural number; And pre-reading the corresponding message from the message queue to the cache according to the determined number of the N consumable messages.
  • processing component 902 can include one or more modules to facilitate interaction between component 902 and other components.
  • processing component 902 can include a multimedia module to facilitate interaction between multimedia component 908 and processing component 902.
  • Memory 904 is configured to store various types of data to support operation at device 900. Examples of such data include instructions for any application or method operating on device 900, contact data, phone book data, messages, pictures, videos, and the like.
  • the memory 904 can be implemented by any type of volatile or non-volatile storage device, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read only memory (EEPROM), erasable.
  • SRAM static random access memory
  • EEPROM electrically erasable programmable read only memory
  • EPROM Programmable Read Only Memory
  • PROM Programmable Read Only Memory
  • ROM Read Only Memory
  • Magnetic Memory Flash Memory
  • Disk Disk or Optical Disk.
  • Power component 906 provides power to various components of device 900.
  • Power component 906 can include a power management system One or more power sources, and other components associated with generating, managing, and distributing power for device 900.
  • the multimedia component 908 includes a screen between the device 900 and the user that provides an output interface.
  • the screen can include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from the user.
  • the touch panel includes one or more touch sensors to sense touches, slides, and gestures on the touch panel. The touch sensor may sense not only the boundary of the touch or sliding action, but also the duration and pressure associated with the touch or slide operation.
  • the multimedia component 908 includes a front camera and/or a rear camera. When the device 900 is in an operation mode, such as a shooting mode or a video mode, the front camera and/or the rear camera can receive external multimedia data. Each front and rear camera can be a fixed optical lens system or have focal length and optical zoom capabilities.
  • the audio component 910 is configured to output and/or input an audio signal.
  • the audio component 910 includes a microphone (MIC) that is configured to receive an external audio signal when the device 900 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode.
  • the received audio signal may be further stored in memory 904 or transmitted via communication component 916.
  • the audio component 910 also includes a speaker for outputting an audio signal.
  • the I/O interface 912 provides an interface between the processing component 902 and the peripheral interface module, which may be a keyboard, a click wheel, a button, or the like. These buttons may include, but are not limited to, a home button, a volume button, a start button, and a lock button.
  • Sensor assembly 914 includes one or more sensors for providing device 900 with a status assessment of various aspects.
  • sensor component 914 can detect an open/closed state of device 900, a relative positioning of components, such as the display and keypad of device 900, and sensor component 914 can also detect a change in position of one component of device 900 or device 900. The presence or absence of contact by the user with the device 900, the orientation or acceleration/deceleration of the device 900, and the temperature change of the device 900.
  • Sensor assembly 914 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact.
  • Sensor assembly 914 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications.
  • the sensor component 914 can also include an acceleration sensor, a gyro sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
  • Communication component 916 is configured to facilitate wired or wireless communication between device 900 and other devices.
  • Device 900 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof.
  • communication component 916 receives broadcast signals or broadcast associated information from an external broadcast management system via a broadcast channel.
  • the communication component 916 further includes a near field communication (NFC) module, To promote short-range communication.
  • NFC near field communication
  • the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
  • RFID radio frequency identification
  • IrDA infrared data association
  • UWB ultra-wideband
  • Bluetooth Bluetooth
  • device 900 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable A gate array (FPGA), controller, microcontroller, microprocessor, or other electronic component implementation for performing the above methods.
  • ASICs application specific integrated circuits
  • DSPs digital signal processors
  • DSPDs digital signal processing devices
  • PLDs programmable logic devices
  • FPGA field programmable A gate array
  • controller microcontroller, microprocessor, or other electronic component implementation for performing the above methods.
  • non-transitory computer readable storage medium comprising instructions, such as a memory 904 comprising instructions executable by processor 920 of device 900 to perform the above method.
  • the non-transitory computer readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device.
  • Embodiments of the present invention also provide a non-transitory computer readable storage medium, when instructions in the storage medium are executed by a processor of a mobile terminal, enabling the mobile terminal to perform a method, the method comprising: The number range of the consumable message in the message queue is recorded in the memory; the number range is adjusted according to the state change of the message in the message queue; the number range of the consumable message in the message queue recorded in the memory is queried, and the message queue is determined.
  • the number of the N consumable messages with the lowest number, N is a natural number; pre-read the corresponding message from the message queue to the cache according to the determined number of the N consumable messages.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)
  • Debugging And Monitoring (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本申请涉及一种消息管理方法及装置、消息预读方法及装置。其中,消息管理方法包括:在内存中记录消息队列中可消费消息的编号范围;根据所述消息队列中消息的状态变化情况调整所述编号范围和管理消息。本发明实施例通过编号范围来管理消息队列中可消费消息的编号,在保证消息先进先出特性的前提下提高了消息预读速度,提升了消息系统性能。

Description

消息管理方法及装置、消息预读方法及装置
本申请要求2016年03月23日递交的申请号为201610169460.6、发明名称为“消息管理方法及装置、消息预读方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及通信领域,尤其涉及一种消息管理方法及装置、消息预读方法及装置。
背景技术
在云计算中,消息管理是非常重要的一个环节,它影响着整个云计算系统的性能。这里首先说明一下与消息有关的术语:
消息队列先进先出:先进入队列的消息优先被消费。
消息可靠性:消息进入消息队列后被持久化到磁盘,保证消息不会因掉电丢失。
至少消费一次:消息只有在消费成功后才会被用户主动删除,否则可以一直被消费。
活跃的消息:可以被消费的消息。
不活跃的消息:正在被用户消费的消息。
删除的消息:被用户主动标志为已消费的消息。
消息的处理过程是,首先,消息生产者(也可称为客户端)将生产的消息写入磁盘;在缓存为空时,触发一次预读操作,将消息从磁盘预读到缓存中;消息消费者(也可称为客户端)从缓存中读取出消息,进行消费。如果消息消费失败,则复活消息到磁盘中。
可靠消息系统在服务端持久化消息的读取状态,来保证消息“至少消费一次”。同时需要返回当前消息队列中最先入队的消息,来保证消息队列先进先出的特性。每个进入消息队列的消息都会分配一个消息编号(也即消息ID),消息编号按照消息入队的先后有序。如果消息未能被成功消费,将会再次入队来确保能够被再次消费。这样系统当前的最先入队的消息是动态变化的。
一种相关技术中,通过如下方式获取最先入队的消息:在消息的元数据信息中增加两个属性,一个属性用来记录消息是否已经被成功消费,另一个属性记录下一个消息的位置。在消息被发送到消息系统中时将消息的消费状态设置为“未消费”,在用户消费获取消息后将消息状态设置为“正在消费”,用户成功消费消息后主动将消息的状态设 置为“已消费”。服务端记录当前系统中第一个“未消费”消息的位置。该相关技术为了保证消息的先进先出需要顺序消费消息,无法支持并发消费,限制了消息的处理速度,而且该相关技术中,修改消息的属性还会导致随机写磁盘,严重影响系统的性能。
另一种相关技术中,通过如下方式获取最先入队的消息:将一个消息队列分成两部分,即“未消费的消息队列”和“正在消费的消息队列”。消息发送至系统后进入“未消费的消息队列”。用户获取消息后,消息出“未消费的消息队列”,进入“正在消费的消息队列”。消费成功后,用户主动将消息从“正在消费的消息队列”中删除。否则,在超出约定的时间后,系统会把消息从“正在消费的消息队列”移至“未消费的消息队列”的队尾,使消息可以被再次消费,来保证消息至少被消费一次。该相关技术在消息消费失败的时候,系统需要把该消息再次加入“未消费的消息队列”的队尾,会严重影响消息先进先出的特性。
发明内容
本发明的目的在于提供一种消息管理方法及装置、消息预读方法及装置,在保证消息先进先出特性的前提下,提高消息预读速度,提升系统性能。
为实现上述目的,本发明提出了一种消息管理方法,包括:
在内存中记录消息队列中可消费消息的编号范围;
根据所述消息队列中消息的状态变化情况调整所述编号范围和管理消息。
进一步地,上述方法还可具有以下特点,所述编号范围包括至少一个编号区间,且任意两个编号区间不重叠。
进一步地,上述方法还可具有以下特点,所述编号范围中的各编号区间按照区间右端点消息编号从小到大的顺序排列。
进一步地,上述方法还可具有以下特点,所述根据所述消息队列中消息的状态变化情况调整所述编号范围和管理消息,包括:
在从缓存中取出所述消息队列中被预读到所述缓存的消息供客户端消费之后,缩小所述编号范围,将所述取出的消息的编号排除在所述编号范围之外,且在所述消息队列中将所述取出的消息标记为不可消费消息。
进一步地,上述方法还可具有以下特点,所述根据所述消息队列中消息的状态变化情况调整所述编号范围和管理消息,包括:
在客户端超时未返回消费结果的情况下,扩大所述编号范围,使所述超时未返回消 费结果的消息的编号包括在所述编号范围之内,且在所述消息队列中将所述超时未返回消费结果的消息标记为可消费消息。
进一步地,上述方法还可具有以下特点,所述根据所述消息队列中消息的状态变化情况调整所述编号范围和管理消息,包括:
在客户端成功消费消息的情况下,在所述消息队列将消费成功的消息删除。
进一步地,上述方法还可具有以下特点,所述根据所述消息队列中消息的状态变化情况调整所述编号范围和管理消息,包括:
在从所述消息队列预读消息到缓存之后,所述编号范围中的非最大编号区间对应的全部可消费消息都已被预读的情况下,从所述编号范围中删除所述非最大编号区间。
本发明实施例的消息管理方法,通过编号范围来管理消息队列中可消费消息的编号,在保证消息先进先出特性的前提下提高了消息预读速度,提升了消息系统性能。
为实现上述目的,本发明还提出了一种消息管理装置,包括:
记录模块,用于在内存中记录消息队列中可消费消息的编号范围;
调整模块,用于根据所述消息队列中消息的状态变化情况调整所述记录模块记录的所述编号范围和管理消息。
进一步地,上述装置还可具有以下特点,所述编号范围包括至少一个编号区间,且任意两个编号区间不重叠。
进一步地,上述装置还可具有以下特点,所述编号范围中的各编号区间按照区间右端点消息编号从小到大的顺序排列。
进一步地,上述装置还可具有以下特点,所述调整模块包括:
缩小单元,用于在从缓存中取出所述消息队列中被预读到所述缓存的消息供客户端消费之后,缩小所述编号范围,将所述取出的消息的编号排除在所述编号范围之外,且在所述消息队列中将所述取出的消息标记为不可消费消息。
进一步地,上述装置还可具有以下特点,所述调整模块包括:
扩大单元,用于在客户端超时未返回消费结果的情况下,扩大所述编号范围,使所述超时未返回消费结果的消息的编号包括在所述编号范围之内,且在所述消息队列中将所述超时未返回消费结果的消息标记为可消费消息。
进一步地,上述装置还可具有以下特点,所述调整模块包括:
消息删除单元,用于在客户端成功消费消息的情况下,在所述消息队列将消费成功的消息删除。
进一步地,上述装置还可具有以下特点,所述调整模块包括:
区间删除单元,用于在从所述消息队列预读消息到缓存之后,所述编号范围中的非最大编号区间对应的全部可消费消息都已被预读的情况下,从所述编号范围中删除所述非最大编号区间。
本发明实施例的消息管理装置,通过编号范围来管理消息队列中可消费消息的编号,在保证消息先进先出特性的前提下提高了消息预读速度,提升了消息系统性能。
为实现上述目的,本发明还提出了一种消息预读方法,包括:
查询内存中记录的消息队列中可消费消息的编号范围,确定所述消息队列中编号最小的N个可消费消息的编号,N为自然数;
根据确定的所述N个可消费消息的编号从所述消息队列中预读相应的消息到缓存。
进一步地,上述方法还可具有以下特点,所述编号范围包括至少一个编号区间,且任意两个编号区间不重叠。
进一步地,上述方法还可具有以下特点,所述编号范围中的各编号区间按照区间右端点消息编号从小到大的顺序排列。
本发明实施例的消息预读方法,能够根据内存中按照消息编号的顺序记录的消息队列中可消费消息的编号范围快速查询到消息队列中编号最小的设定数目个可消费消息的编号,并且还保证了消息的先进先出特性,提高了消息预读速度,提升了消息系统性能。
为实现上述目的,本发明还提出了一种消息预读装置,包括:
查询模块,用于查询内存中记录的消息队列中可消费消息的编号范围,确定所述消息队列中编号最小的N个可消费消息的编号,N为自然数;
预读模块,用于根据所述查询模块确定的所述N个可消费消息的编号从所述消息队列中预读相应的消息到缓存。
进一步地,上述装置还可具有以下特点,所述编号范围包括至少一个编号区间,且任意两个编号区间不重叠。
进一步地,上述装置还可具有以下特点,所述编号范围中的各编号区间按照区间右端点消息编号从小到大的顺序排列。
本发明实施例的消息预读装置,能够根据内存中按照消息编号的顺序记录的消息队列中可消费消息的编号范围快速查询到消息队列中编号最小的设定数目个可消费消息的编号,并且还保证了消息的先进先出特性,提高了消息预读速度,提升了消息系统性能。
为实现上述目的,本发明还提出了一种消息管理设备,包括前述任一项所述的消息 管理装置。
本发明实施例的消息管理设备中包括消息管理装置,通过编号范围来管理消息队列中可消费消息的编号,在保证消息先进先出特性的前提下提高了消息预读速度,提升了消息系统性能。
为实现上述目的,本发明还提出了一种消息预读设备,包括前述任一项所述的消息预读装置。
本发明实施例的消息预读设备中包括消息预读装置,能够根据内存中按照消息编号的顺序记录的消息队列中可消费消息的编号范围快速查询到消息队列中编号最小的设定数目个可消费消息的编号,并且还保证了消息的先进先出特性,提高了消息预读速度,提升了消息系统性能。
附图说明
图1为本发明实施例中消息的处理过程示意图;
图2为本发明实施例一中消息管理方法的流程图;
图3为在复活消息MsgID时对消息MsgID的前驱游标域进行扩大的示意图;
图4为本发明实施例二中消息管理装置的结构框图;
图5为本发明实施例三中消息预读方法的流程图;
图6为本发明实施例四中消息预读装置的结构框图;
图7为本发明实施例五中消息管理设备的结构框图;
图8为本发明实施例六中消息预读设备的结构框图;
图9为本发明实施例七中设备900的结构框图。
具体实施方式
以下结合附图对本发明的原理和特征进行描述,所举实施例只用于解释本发明,并非用于限定本发明的范围。对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,根据本发明精神所获得的所有实施例,都属于本发明的保护范围。
图1为本发明实施例中消息的处理过程示意图。如图1所示,本发明实施例中,消息的处理过程是:
客户端将生成的消息写入磁盘,消息进入消息队列;
缓存为空时,从磁盘批量获取N个最先进入消息队列的消息到缓存,此为消息预读 操作;
从缓存读取消息供客户端进行消费,并在消息队列中将被读取的消息标记为不可消费消息;
客户端消费完成后,向服务器返回消费结果;
管理模块根据消费结果处理磁盘中的相应消息:如果消费成功,则删除消息队列中的相应消息,如果客户端超时未返回消息消费成功的信息,则认为消息消费失败,复活该消息,将消息队列中的该消息标记为可消费消息。
在整个消息的处理过程中,可以在内存中用游标记录消息队列中可消费消息的编号范围。
图2为本发明实施例一中消息管理方法的流程图。如图2所示,本实施例中,消息管理方法可以包括如下步骤:
步骤S201,在内存中记录消息队列中可消费消息的编号范围;
其中,该编号范围可以包括至少一个编号区间,且任意两个编号区间不重叠。
其中,消息编号代表消息进入消息队列的顺序,消息编号越小,表明该消息进入消息队列越早。例如,消息10是第10个进入消息队列的消息。
由于可消费消息的编号范围是按照消息编号的顺序记录的,因此可以保证消息的先进先出特性。可消费消息的编号范围可以作为查询要预读的批量消息的依据。通过可消费消息的编号范围不仅可以快速查找到要预读到缓存的批量消息,而且保证了消息的先进先出特性。
在本发明实施例中,编号范围中的各编号区间按照区间右端点消息编号从小到大的顺序排列。本文中,将这样的编号范围称为游标域集合,将这样的编号范围中的编号区间称为游标域。游标域用左闭右开区间表示。
本文中,将编号范围的编号区间的两个端点处的消息编号分别称为左端点消息编号和右端点消息编号。
当然,在本发明其他实施例中,所述的编号范围可以采用其他形式表示,只要其能够表明消息队列中可消费消息的编号范围,并且能够表明这些可消费消息的编号顺序即可。这样,就可以保证通过该编号范围就能查询到消息队列中哪些消息可以消费,并保证这些可消费的消息能够按照先进先出的特性被取出消费。
以下将消息队列中可消费消息的编号范围简称为编号范围。
步骤S202,根据消息队列中消息的状态变化情况调整该编号范围和管理消息。
在本发明实施例中,根据消息队列中消息的状态变化情况调整编号范围和管理消息可以包括:在从缓存中取出消息队列中被预读到缓存的消息供客户端消费之后,缩小编号范围,将取出的消息的编号排除在该编号范围之外,且在消息队列中将该取出的消息标记为不可消费消息。
例如,假设编号范围的初始状态为{[1,101)},消息队列中被预读到缓存的消息为消息1至消息10这10个消息,在从缓存中取出这10个消息之后,将编号范围{[1,101)}缩小为{[11,101)},使得消息1至消息10这10个消息的编号被排除在了可消费消息的编号范围之外。
消息消费者从缓存中取出的消息进入到非活跃消息队列,属于不活跃的消息,也即正在被用户消费的消息。如果这些消息被消费成功,那么这些消息就属于不可消费的消息,将被排除出可消费消息的范围。这里将所有从缓存中取出的消息都先按照消费成功的情况处理,如果消费失败,再通过后续的复活机制加入到可消费消息的范围中。
在本发明实施例中,根据消息队列中消息的状态变化情况调整编号范围和管理消息还可以包括:在客户端超时未返回消费结果的情况下,扩大编号范围,使超时未返回消费结果的消息的编号包括在该编号范围之内,且在消息队列中将该超时未返回消费结果的消息标记为可消费消息。其中,如果客户端超时未返回消费结果,可以认为消息消费失败,因此,将超时未返回消费结果的消息称为消费失败的消息。这就是消费失败的消息的复活机制。通过将消费失败的消息的编号包括到编号范围之内,使得可以对该消息进行再次消费,并且可以按照先进先出的特性进行消费。
这里,以游标域集合为例,对因消息消费失败而扩大可消费消息的编号范围的情况进行说明。
具体地,在消息队列中的消息消费失败的情况下,扩大编号范围,使消费失败的消息的编号包括在该编号范围之内,可以通过如下步骤实现:
消费失败的消息也就是要复活的消息。
步骤a,假设复活的消息的消息ID为MsgID,根据MsgID,在游标域集合中定位游标域[MsgID,MsgID+1)的上界游标域,记上界游标域为[Upper_BeginID,Upper_EndID),其中,MsgID的上界游标域是指游标域集合中第一个右端点消息编号大于MsgID+1的游标域;
步骤b,如果该上界游标域[Upper_BeginID,Upper_EndID)已经包含MsgID,则结束流程,不再调整游标域;
步骤c,如果该上界游标域的左端点消息编号Upper_BeginID>MsgID,则进行后续操作来调整游标域集合以使游标域集合涵盖MsgID;
步骤d,获取消息MsgID的前驱游标域[Pre_BeginID,Pre_EndID),其中,消息MsgID的前驱游标域是指游标域集合中第一个右端点消息编号小于MsgID+1的游标域;
步骤e,如果消息MsgID的前驱游标域不存在,则将[MsgID,MsgID+1)加入游标域集合,然后结束流程;
步骤f,如果消息MsgID的前驱游标域存在,则将游标域[Pre_BeginID,MsgID+1)和游标域[MsgID,Upper_EndID)中范围较小且不超过MAX_RANGE_SIZE的游标域加入游标域集合,来替换前驱游标域或者上界游标域(如果两者中游标域[Pre_BeginID,MsgID+1)范围较小,就用[Pre_BeginID,MsgID+1)替换前驱游标域[Pre_BeginID,Pre_EndID),如果两者中游标域[MsgID,Upper_EndID)范围较小,就用[MsgID,Upper_EndID)替换上界游标域[Upper_BeginID,Upper_EndID)),其中,MAX_RANGE_SIZE为预设的游标域的最大范围;
步骤g,如果消息MsgID的前驱游标域存在,且将游标域[Pre_BeginID,MsgID+1)和游标域[MsgID,Upper_EndID)的范围都超过MAX_RANGE_SIZE,则将[MsgID,MsgID+1)加入游标域集合。
需要说明的是,在步骤f中,如果游标域集合的规模达到上限(该上限即游标域集合的最大规模,用MAX_COUNT表示),则不能再添加新的游标域,而是选择上界游标域或者前驱游标域进行扩大。特别的,如果上界游标域是最大游标域,则只能对其前驱游标域进行扩大。即在MsgID-Pre_BeginID<Upper_EndID-MsgID,并且MsgID-Pre_BeginID<MAX_RANGE_SIZE的情况下,将前驱游标域扩大为[Pre_BeginID,MsgID+1),如图3所示。图3为在复活消息MsgID时对消息MsgID的前驱游标域进行扩大的示意图,图3中,PB表示Pre_BeginID,PE表示Pre_EndID,UB表示Upper_BeginID,UE表示Upper_EndID。其中,MAX_COUNT表示游标域集合中最多可以包含的游标域的总数目。
在步骤f中,如果游标域[Pre_BeginID,MsgID+1)和游标域[MsgID,Upper_EndID)的范围相同且都不超过MAX_RANGE_SIZE,可以随机选择游标域[Pre_BeginID,MsgID+1)来替换前驱游标域或者选择[MsgID,Upper_EndID)来替换上界游标域,也可以默认选择游标域[Pre_BeginID,MsgID+1)来替换前驱游标域。
这里举例说明。以下例1至例4假设MAX_RANGE_SIZE为100,MAX_COUNT 为10。
例1、假设当前游标域集合为{[5,101)},复活的消息编号为6。消息6存在上界游标域[5,101),并且消息6包含在上界游标域[5,101)中,此时不再调整游标域集合,则消息6复活后,游标域集合仍然为{[5,101)}。
例2、假设当前游标域集合为{[11,101)},复活的消息编号为6。消息6存在上界游标域[11,101)且上界游标域[11,101)的左端点消息编号11大于6,不存在前驱游标域,此时将游标域[6,7)添加到游标域集合中,则消息6复活后,游标域集合为{[6,7),[11,101)}。
例3、假设当前游标域集合为{[3,6),[11,101)},复活的消息编号为6。消息6存在上界游标域[11,101)和前驱游标域[3,6)。游标域[3,7)和游标域[6,101)中范围较小且不超过MAX_RANGE_SIZE的游标域为[3,7),此时将游标域[3,7)添加到游标域集合替换游标域[3,6),则消息6复活后,游标域集合为{[3,7),[11,101)}。
例4、假设当前游标域集合为{[1,101),[106,206)},复活的消息编号为103。消息103存在上界游标域[106,206)和前驱游标域[1,101)。但游标域[1,104)和游标域[103,206)的范围都超过了MAX_RANGE_SIZE(上述假设MAX_RANGE_SIZE为100),此时将游标域[3,7)添加到游标域集合,则消息103复活后,游标域集合为{[1,101),[103,104),[106,206)}。
也就是说,在消息队列中的消息消费失败的情况下,扩大编号范围,使消费失败的消息的编号包括在该编号范围之内,可以包括下面四种情况之一:
一,假设复活的消息编号为MsgID,在当前游标域集合中存在消息MsgID的上界游标域,且MsgID包含在所述上界游标域的情况下,维持当前游标域集合不变。
二,假设复活的消息编号为MsgID,在当前游标域集合中存在消息MsgID的上界游标域、不存在消息MsgID的前驱游标域,且所述上界游标域的开头消息编号大于MsgID的情况下,将游标域[MsgID,MsgID+1)添加到当前游标域集合中。
三,假设复活的消息编号为MsgID,在当前游标域集合中存在消息MsgID的上界游标域[UB,UE)和前驱游标域[PB,PE),扩展前驱游标域[PB,MsgID+1)和扩展上界游标域[MsgID,UE)两者之一或全部小于预设的第二阈值的情况下,选择两者之中范围小的游标域替换相应的原游标域;在当前游标域集合的规模达到上限并且上界游标域[UB,UE)是当前游标域集合中最大游标域的情况下,选择扩展前驱游标域[PB,MsgID+1)替换前驱游标域[PB,PE)。
四,假设复活的消息编号为MsgID,在当前游标域集合中存在消息MsgID的上界游标域[UB,UE)和前驱游标域[PB,PE),扩展前驱游标域[PB,MsgID+1)和扩展上界游标域[MsgID,UE全部大于预设的第二阈值的情况下,将游标域[MsgID,MsgID+1)添加到当前游标域集合中。
在本发明实施例中,根据消息队列中消息的状态变化情况调整编号范围和管理消息可以包括:在客户端成功消费消息的情况下,在消息队列将消费成功的消息删除。此处的删除是指将消息从存储消息队列的磁盘中删除,也即从消息队列中删除。
在本发明实施例中,根据消息队列中消息的状态变化情况调整编号范围和管理消息还可以包括:在从消息队列预读消息到缓存之后,该编号范围中的非最大编号区间对应的全部可消费消息都已被预读的情况下,从该编号范围中删除该非最大编号区间。
删除这样的非最大编号区间后,编号范围中编号区间的数目减少了,对编号区间的搜索次数就减少了,因此能够缩短查询编号范围的时间,进一步提高消息的预读速度。
为了进一步对编号范围进行管理,可以为编号范围设置版本号及版本号更新规则。例如,设置编号范围的初始版本号为1;每次修改编号范围,编号范围的版本号加1;如果修改编号范围时需要修改编号区间,则将修改后的编号范围的版本号作为编号区间的版本号。在删除编号区间时需要保证编号区间未被修改,即编号区间的版本号没有变化,否则不能删除。
本发明实施例的消息管理方法,通过编号范围来管理消息队列中可消费消息的编号,并且保证了消息的先进先出特性,在需要预读批量消息到缓存时,可以根据编号范围快速查询到消息队列中编号最小的设定数目个可消费消息的编号,在保证消息先进先出特性的前提下提高了消息预读速度,提升了消息系统性能。
本发明还提出了一种消息管理装置,用以实施上述的消息管理方法。上述消息管理方法实施例中的原理说明,也同样适用于下面的消息管理装置各实施例。
图4为本发明实施例二中消息管理装置的结构框图。如图4所示,本实施例中,消息管理装置400可以包括记录模块410和调整模块420。其中,记录模块410用于按照消息编号的顺序在内存中记录消息队列中可消费消息的编号范围。调整模块420用于根据消息队列中消息的状态变化情况调整记录模块410记录的编号范围和管理消息。
其中,编号范围可以包括至少一个编号区间,且任意两个编号区间不重叠。
由于可消费消息的编号范围是按照消息编号的顺序记录的,因此可以保证消息的先进先出特性。可消费消息的编号范围可以作为查询要预读的批量消息的依据。通过可消 费消息的编号范围不仅可以快速查找到要预读到缓存的批量消息,而且保证了消息的先进先出特性。
其中,编号范围中的各编号区间可以按照区间右端点消息编号从小到大的顺序排列。
在本发明实施例中,调整模块420可以包括缩小单元。缩小单元用于在从缓存中取出消息队列中被预读到缓存的消息供客户端消费之后,缩小该编号范围,将取出的消息的编号排除在该编号范围之外,且在消息队列中将所述取出的消息标记为不可消费消息。
在本发明实施例中,调整模块420可以包括扩大单元。扩大单元用于在客户端超时未返回消费结果的情况下,扩大编号范围,使超时未返回消费结果的消息的编号包括在该编号范围之内,且在所述消息队列中将所述超时未返回消费结果的消息标记为可消费消息。
在本发明实施例中,调整模块420可以包括消息删除单元。消息删除单元用于在客户端成功消费消息的情况下,在消息队列将消费成功的消息删除。
在本发明实施例中,调整模块420可以包括区间删除单元。删除单元用于在从消息队列预读消息到缓存之后,编号范围中的非最大编号区间对应的全部可消费消息都已被预读的情况下,从编号范围中删除该非最大编号区间。
本发明实施例的消息管理装置,通过编号范围来管理消息队列中可消费消息的编号,并且保证了消息的先进先出特性,在需要预读批量消息到缓存时,可以根据编号范围快速查询到消息队列中编号最小的设定数目个可消费消息的编号,在保证消息先进先出特性的前提下提高了消息预读速度,提升了消息系统性能。
图5为本发明实施例三中消息预读方法的流程图。如图5所示,本实施例中,消息预读方法可以包括如下步骤:
步骤S501,查询内存中记录的消息队列中可消费消息的编号范围,确定消息队列中编号最小的N个可消费消息的编号,N为自然数;
其中,编号范围可以包括至少一个编号区间,且任意两个编号区间不重叠。
其中,本步骤中的可消费消息的编号范围与前述消息管理方法中的编号范围是相同的。
可消费消息的编号范围可以作为查询要预读的批量消息的依据。通过可消费消息的编号范围不仅可以快速查找到要预读到缓存的批量消息,而且保证了消息的先进先出特性。
在本发明实施例中,所述的编号范围可以包括至少一个编号区间,该编号范围中的 各编号区间可以按照区间右端点消息编号从小到大的顺序排列,且该编号范围中的任意两个编号区间不重叠。本文中,将这样的编号范围称为游标域集合,将这样的编号范围中的编号区间称为游标域。游标域用左闭右开区间表示。
步骤S502,根据确定的N个可消费消息的编号从消息队列中预读相应的消息到缓存。
该N个可消费消息是消息队列中编号最小的N个可消费消息,保证了消息的先进先出特性。
下面通过两个具体示例来对本发明的消息预读方法作进一步说明。
示例一
假设内存中按照消息编号的顺序记录的消息队列中可消费消息的编号范围为{[6,9),[11,101)},该编号范围内的所有消息都不是标识为已删除的消息。则从消息队列预读5个可消费消息到缓存的过程是:查询编号范围{[6,9),[11,101)},确定编号最小的5个可消费消息的编号为6、7、8、11、12;从消息队列中消息6、消息7、消息8、消息11、消息12到缓存。
这里说明一下,标识为已删除的消息是已经被消费成功的消息,这样的消息不属于可消费消息,但是这些消息的编号可能被包括在可消费消息的编号范围之内。这就需要在根据编号范围确定预读消息编号的时候,将这些标识为已删除的消息的编号排除掉。此种情况请参见如下的示例二。
示例二
仍然假设内存中按照消息编号的顺序记录的消息队列中可消费消息的编号范围为{[6,9),[11,101)},该编号范围内的消息7是标识为已删除的消息。则从消息队列预读5个可消费消息到缓存的过程是:查询编号范围{[6,9),[11,101)},确定编号最小的5个可消费消息的编号为6、8、11、12、13(由于消息7是标识为已删除的消息,编号7被排除掉了);从消息队列中消息6、消息8、消息11、消息12、消息13到缓存。
本发明实施例的消息预读方法,能够根据内存中记录的消息队列中可消费消息的编号范围快速查询到消息队列中编号最小的设定数目个可消费消息的编号,并且还保证了消息的先进先出特性,提高了消息预读速度,提升了消息系统性能。
本发明还提出了一种消息预读装置,用以实施上述的消息预读方法。上述消息预读方法实施例中的原理说明,也同样适用于下面的消息预读装置各实施例。
图6为本发明实施例四中消息预读装置的结构框图。如图6所示,本实施例中,消 息预读装置600可以包括查询模块610和预读模块620。其中可,查询模块610用于查询内存中记录的消息队列中可消费消息的编号范围,确定消息队列中编号最小的N个可消费消息的编号,N为自然数。预读模块620用于根据查询模块610确定的N个可消费消息的编号从消息队列中预读相应的消息到缓存。
其中,可消费消息的编号范围与前述消息管理方法中的编号范围是相同的。
其中,编号范围可以包括至少一个编号区间,且任意两个编号区间不重叠。
由于可消费消息的编号范围是按照消息编号的顺序记录的,因此可以保证消息的先进先出特性。可消费消息的编号范围可以作为查询要预读的批量消息的依据。通过可消费消息的编号范围不仅可以快速查找到要预读到缓存的批量消息,而且保证了消息的先进先出特性。
在本发明实施例中,所述的编号范围可以包括至少一个编号区间,该编号范围中的各编号区间按照区间右端点消息编号从小到大的顺序排列,且该编号范围中的任意两个编号区间不重叠。本文中,将这样的编号范围称为游标域集合,将这样的编号范围中的编号区间称为游标域。游标域用左闭右开区间表示。
本发明实施例的消息预读装置,能够根据内存中记录的消息队列中可消费消息的编号范围快速查询到消息队列中编号最小的设定数目个可消费消息的编号,并且还保证了消息的先进先出特性,提高了消息预读速度,提升了消息系统性能。
图7为本发明实施例五中消息管理设备的结构框图。如图7所示,本实施例中,消息管理设备700可以包括消息管理装置400。该消息管理装置400可以是前述消息管理装置实施例中的任意一种消息管理装置。
其中,消息管理装置400可以用于按照消息编号的顺序在内存中记录消息队列中可消费消息的编号范围,编号范围包括至少一个编号区间,且任意两个编号区间不重叠;以及,根据消息队列中消息的状态变化情况调整编号范围和管理消息。
本发明实施例的消息管理设备,通过编号范围来管理消息队列中可消费消息的编号,并且保证了消息的先进先出特性,在需要预读批量消息到缓存时,可以根据编号范围快速查询到消息队列中编号最小的设定数目个可消费消息的编号,在保证消息先进先出特性的前提下提高了消息预读速度,提升了消息系统性能。
图8为本发明实施例六中消息预读设备的结构框图。如图8所示,本实施例中,消息预读设备800可以包括消息预读装置600。该消息预读装置600可以是前述消息预读装置实施例中的任意一种消息预读装置。
其中,消息预读装置600可以用于查询内存中记录的消息队列中可消费消息的编号范围,确定消息队列中编号最小的N个可消费消息的编号,N为自然数;根据确定的N个可消费消息的编号从消息队列中预读相应的消息到缓存。其中,编号范围可以包括至少一个编号区间,且任意两个编号区间不重叠。
本发明实施例的消息预读设备,能够根据内存中记录的消息队列中可消费消息的编号范围快速查询到消息队列中编号最小的设定数目个可消费消息的编号,并且还保证了消息的先进先出特性,提高了消息预读速度,提升了消息系统性能。
图9为本发明实施例七中设备900的结构框图。如图9所示,本实施例中,设备900可以是移动电话,计算机,数字广播终端,消息收发设备,游戏控制台,平板设备,医疗设备,健身设备,个人数字助理等。
参照图9,设备900可以包括以下一个或多个组件:处理组件902,存储器904,电源组件906,多媒体组件908,音频组件910,输入/输出(I/O)的接口912,传感器组件914,以及通信组件916。
处理组件902通常控制设备900的整体操作,诸如与显示,电话呼叫,数据通信,相机操作和记录操作相关联的操作。处理元件902可以包括一个或多个处理器920来执行指令,以完成上述的方法的全部或部分步骤,具体包括:在内存中记录消息队列中可消费消息的编号范围;根据所述消息队列中消息的状态变化情况调整所述编号范围和管理消息;查询内存中记录的消息队列中可消费消息的编号范围,确定所述消息队列中编号最小的N个可消费消息的编号,N为自然数;根据确定的所述N个可消费消息的编号从所述消息队列中预读相应的消息到缓存。
此外,处理组件902可以包括一个或多个模块,便于处理组件902和其他组件之间的交互。例如,处理组件902可以包括多媒体模块,以方便多媒体组件908和处理组件902之间的交互。
存储器904被配置为存储各种类型的数据以支持在设备900的操作。这些数据的示例包括用于在设备900上操作的任何应用程序或方法的指令,联系人数据,电话簿数据,消息,图片,视频等。存储器904可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(SRAM),电可擦除可编程只读存储器(EEPROM),可擦除可编程只读存储器(EPROM),可编程只读存储器(PROM),只读存储器(ROM),磁存储器,快闪存储器,磁盘或光盘。
电源组件906为设备900的各种组件提供电力。电源组件906可以包括电源管理系 统,一个或多个电源,及其他与为设备900生成、管理和分配电力相关联的组件。
多媒体组件908包括在所述设备900和用户之间的提供一个输出接口的屏幕。在一些实施例中,屏幕可以包括液晶显示器(LCD)和触摸面板(TP)。如果屏幕包括触摸面板,屏幕可以被实现为触摸屏,以接收来自用户的输入信号。触摸面板包括一个或多个触摸传感器以感测触摸、滑动和触摸面板上的手势。所述触摸传感器可以不仅感测触摸或滑动动作的边界,而且还检测与所述触摸或滑动操作相关的持续时间和压力。在一些实施例中,多媒体组件908包括一个前置摄像头和/或后置摄像头。当设备900处于操作模式,如拍摄模式或视频模式时,前置摄像头和/或后置摄像头可以接收外部的多媒体数据。每个前置摄像头和后置摄像头可以是一个固定的光学透镜系统或具有焦距和光学变焦能力。
音频组件910被配置为输出和/或输入音频信号。例如,音频组件910包括一个麦克风(MIC),当设备900处于操作模式,如呼叫模式、记录模式和语音识别模式时,麦克风被配置为接收外部音频信号。所接收的音频信号可以被进一步存储在存储器904或经由通信组件916发送。在一些实施例中,音频组件910还包括一个扬声器,用于输出音频信号。
I/O接口912为处理组件902和外围接口模块之间提供接口,上述外围接口模块可以是键盘,点击轮,按钮等。这些按钮可包括但不限于:主页按钮、音量按钮、启动按钮和锁定按钮。
传感器组件914包括一个或多个传感器,用于为设备900提供各个方面的状态评估。例如,传感器组件914可以检测到设备900的打开/关闭状态,组件的相对定位,例如所述组件为设备900的显示器和小键盘,传感器组件914还可以检测设备900或设备900一个组件的位置改变,用户与设备900接触的存在或不存在,设备900方位或加速/减速和设备900的温度变化。传感器组件914可以包括接近传感器,被配置用来在没有任何的物理接触时检测附近物体的存在。传感器组件914还可以包括光传感器,如CMOS或CCD图像传感器,用于在成像应用中使用。在一些实施例中,该传感器组件914还可以包括加速度传感器,陀螺仪传感器,磁传感器,压力传感器或温度传感器。
通信组件916被配置为便于设备900和其他设备之间有线或无线方式的通信。设备900可以接入基于通信标准的无线网络,如WiFi,2G或3G,或它们的组合。在一个示例性实施例中,通信组件916经由广播信道接收来自外部广播管理系统的广播信号或广播相关信息。在一个示例性实施例中,所述通信组件916还包括近场通信(NFC)模块, 以促进短程通信。例如,在NFC模块可基于射频识别(RFID)技术,红外数据协会(IrDA)技术,超宽带(UWB)技术,蓝牙(BT)技术和其他技术来实现。
在示例性实施例中,设备900可以被一个或多个应用专用集成电路(ASIC)、数字信号处理器(DSP)、数字信号处理设备(DSPD)、可编程逻辑器件(PLD)、现场可编程门阵列(FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行上述方法。
在示例性实施例中,还提供了一种包括指令的非临时性计算机可读存储介质,例如包括指令的存储器904,上述指令可由设备900的处理器920执行以完成上述方法。例如,所述非临时性计算机可读存储介质可以是ROM、随机存取存储器(RAM)、CD-ROM、磁带、软盘和光数据存储设备等。
本发明实施例还提供了一种非临时性计算机可读存储介质,当所述存储介质中的指令由移动终端的处理器执行时,使得移动终端能够执行一种方法,所述方法包括:在内存中记录消息队列中可消费消息的编号范围;根据所述消息队列中消息的状态变化情况调整所述编号范围;查询内存中记录的消息队列中可消费消息的编号范围,确定所述消息队列中编号最小的N个可消费消息的编号,N为自然数;根据确定的所述N个可消费消息的编号从所述消息队列中预读相应的消息到缓存。
以上所述仅为本发明的较佳实施例,并不用以限制本发明,凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。

Claims (22)

  1. 一种消息管理方法,其特征在于,包括:
    在内存中记录消息队列中可消费消息的编号范围;
    根据所述消息队列中消息的状态变化情况调整所述编号范围和管理消息。
  2. 根据权利要求1所述的消息管理方法,其特征在于,所述编号范围包括至少一个编号区间,且任意两个编号区间不重叠。
  3. 根据权利要求1所述的消息管理方法,其特征在于,所述编号范围中的各编号区间按照区间右端点消息编号从小到大的顺序排列。
  4. 根据权利要求1所述的消息管理方法,其特征在于,所述根据所述消息队列中消息的状态变化情况调整所述编号范围和管理消息,包括:
    在从缓存中取出所述消息队列中被预读到所述缓存的消息供客户端消费之后,缩小所述编号范围,将所述取出的消息的编号排除在所述编号范围之外,且在所述消息队列中将所述取出的消息标记为不可消费消息。
  5. 根据权利要求1所述的消息管理方法,其特征在于,所述根据所述消息队列中消息的状态变化情况调整所述编号范围和管理消息,包括:
    在客户端超时未返回消费结果的情况下,扩大所述编号范围,使所述超时未返回消费结果的消息的编号包括在所述编号范围之内,且在所述消息队列中将所述超时未返回消费结果的消息标记为可消费消息。
  6. 根据权利要求1所述的消息管理方法,其特征在于,所述根据所述消息队列中消息的状态变化情况调整所述编号范围和管理消息,包括:
    在客户端成功消费消息的情况下,在所述消息队列将消费成功的消息删除。
  7. 根据权利要求1所述的消息管理方法,其特征在于,所述根据所述消息队列中消息的状态变化情况调整所述编号范围和管理消息,包括:
    在从所述消息队列预读消息到缓存之后,所述编号范围中的非最大编号区间对应的全部可消费消息都已被预读的情况下,从所述编号范围中删除所述非最大编号区间。
  8. 一种消息管理装置,其特征在于,包括:
    记录模块,用于在内存中记录消息队列中可消费消息的编号范围;
    调整模块,用于根据所述消息队列中消息的状态变化情况调整所述记录模块记录的所述编号范围和管理消息。
  9. 根据权利要求8所述的消息管理装置,其特征在于,所述编号范围包括至少一个 编号区间,且任意两个编号区间不重叠。
  10. 根据权利要求8所述的消息管理装置,其特征在于,所述编号范围中的各编号区间按照区间右端点消息编号从小到大的顺序排列。
  11. 根据权利要求8所述的消息管理装置,其特征在于,所述调整模块包括:
    缩小单元,用于在从缓存中取出所述消息队列中被预读到所述缓存的消息供客户端消费之后,缩小所述编号范围,将所述取出的消息的编号排除在所述编号范围之外,且在所述消息队列中将所述取出的消息标记为不可消费消息。
  12. 根据权利要求8所述的消息管理装置,其特征在于,所述调整模块包括:
    扩大单元,用于在客户端超时未返回消费结果的情况下,扩大所述编号范围,使所述超时未返回消费结果的消息的编号包括在所述编号范围之内,且在所述消息队列中将所述超时未返回消费结果的消息标记为可消费消息。
  13. 根据权利要求8所述的消息管理装置,其特征在于,所述调整模块包括:
    消息删除单元,用于在客户端成功消费消息的情况下,在所述消息队列将消费成功的消息删除。
  14. 根据权利要求8所述的消息管理装置,其特征在于,所述调整模块包括:
    区间删除单元,用于在从所述消息队列预读消息到缓存之后,所述编号范围中的非最大编号区间对应的全部可消费消息都已被预读的情况下,从所述编号范围中删除所述非最大编号区间。
  15. 一种消息预读方法,其特征在于,包括:
    查询内存中记录的消息队列中可消费消息的编号范围,确定所述消息队列中编号最小的N个可消费消息的编号,N为自然数;
    根据确定的所述N个可消费消息的编号从所述消息队列中预读相应的消息到缓存。
  16. 根据权利要求15所述的消息预读方法,其特征在于,所述编号范围包括至少一个编号区间,且任意两个编号区间不重叠。
  17. 根据权利要求15所述的消息预读方法,其特征在于,所述编号范围中的各编号区间按照区间右端点消息编号从小到大的顺序排列。
  18. 一种消息预读装置,其特征在于,包括:
    查询模块,用于查询内存中记录的消息队列中可消费消息的编号范围,确定所述消息队列中编号最小的N个可消费消息的编号,N为自然数;
    预读模块,用于根据所述查询模块确定的所述N个可消费消息的编号从所述消息队 列中预读相应的消息到缓存。
  19. 根据权利要求18所述的消息预读装置,其特征在于,所述编号范围包括至少一个编号区间,且任意两个编号区间不重叠。
  20. 根据权利要求18所述的消息预读装置,其特征在于,所述编号范围中的各编号区间按照区间右端点消息编号从小到大的顺序排列。
  21. 一种消息管理设备,其特征在于,包括权利要求8至14任一项所述的消息管理装置。
  22. 一种消息预读设备,其特征在于,包括权利要求18至20任一项所述的消息预读装置。
PCT/CN2017/076400 2016-03-23 2017-03-13 消息管理方法及装置、消息预读方法及装置 Ceased WO2017162059A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US16/138,856 US11165740B2 (en) 2016-03-23 2018-09-21 Message sending method and terminal device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610169460.6 2016-03-23
CN201610169460.6A CN107231283B (zh) 2016-03-23 2016-03-23 消息管理方法及装置、消息预读方法及装置

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/138,856 Continuation US11165740B2 (en) 2016-03-23 2018-09-21 Message sending method and terminal device

Publications (1)

Publication Number Publication Date
WO2017162059A1 true WO2017162059A1 (zh) 2017-09-28

Family

ID=59899358

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/076400 Ceased WO2017162059A1 (zh) 2016-03-23 2017-03-13 消息管理方法及装置、消息预读方法及装置

Country Status (4)

Country Link
US (1) US11165740B2 (zh)
CN (1) CN107231283B (zh)
TW (1) TWI735533B (zh)
WO (1) WO2017162059A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11165740B2 (en) 2016-03-23 2021-11-02 Alibaba Group Holding Limited Message sending method and terminal device

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111400056B (zh) * 2019-12-31 2023-07-28 远景智能国际私人投资有限公司 基于消息队列的消息传输方法、装置及设备
CN111669431B (zh) * 2020-05-07 2021-11-19 深圳华锐金融技术股份有限公司 消息传输方法、装置、计算机设备和存储介质
CN114979249B (zh) * 2022-03-30 2024-08-09 阿里巴巴(中国)有限公司 消息句柄的创建方法、消息推送方法及相关装置和系统

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101763289A (zh) * 2009-09-25 2010-06-30 中国人民解放军国防科学技术大学 一种基于共享内存的消息传递方法
CN102902512A (zh) * 2012-08-31 2013-01-30 浪潮电子信息产业股份有限公司 一种基于多线程编程及消息队列的多线程并行处理方法
WO2013143285A1 (zh) * 2012-03-28 2013-10-03 华为技术有限公司 流量控制方法、装置和集群系统
CN103984734A (zh) * 2014-05-20 2014-08-13 中国科学院软件研究所 一种面向高性能计算的云服务消息传递方法
CN105407152A (zh) * 2015-11-03 2016-03-16 竞技世界(杭州)网络技术有限公司 推送消息的方法

Family Cites Families (42)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5956340A (en) * 1997-08-05 1999-09-21 Ramot University Authority For Applied Research And Industrial Development Ltd. Space efficient fair queuing by stochastic Memory multiplexing
US6058389A (en) * 1997-10-31 2000-05-02 Oracle Corporation Apparatus and method for message queuing in a database system
US20030093576A1 (en) * 2001-11-13 2003-05-15 International Business Machines Corporation Method and system for message management
US7127467B2 (en) * 2002-05-10 2006-10-24 Oracle International Corporation Managing expressions in a database system
US7334019B2 (en) * 2002-07-18 2008-02-19 Ebay Inc. Delivering messages to message servers
US7203706B2 (en) * 2002-08-01 2007-04-10 Oracle International Corporation Buffered message queue architecture for database management systems with memory optimizations and “zero copy” buffered message queue
US20040230659A1 (en) * 2003-03-12 2004-11-18 Chase Michael John Systems and methods of media messaging
US7676580B2 (en) * 2003-03-27 2010-03-09 Microsoft Corporation Message delivery with configurable assurances and features between two endpoints
US7644197B1 (en) * 2003-10-15 2010-01-05 Sun Microsystems, Inc. Queue management by multiple processors
US7640357B2 (en) * 2004-04-30 2009-12-29 Sap Ag Transmitting enterprise messages based on buffer sizes
US8095598B2 (en) * 2004-04-30 2012-01-10 Sap Ag Methods and apparatus for subscribing/publishing messages in an enterprising computing environment
US7870200B2 (en) * 2004-05-29 2011-01-11 Ironport Systems, Inc. Monitoring the flow of messages received at a server
US7403945B2 (en) * 2004-11-01 2008-07-22 Sybase, Inc. Distributed database system providing data and space management methodology
US20060248145A1 (en) * 2005-04-18 2006-11-02 Srimantee Karmakar System and method for providing various levels of reliable messaging between a client and a server
US7600126B2 (en) * 2005-05-27 2009-10-06 Microsoft Corporation Efficient processing of time-bounded messages
US7366831B2 (en) * 2005-09-30 2008-04-29 Intel Corporation Lock-free bounded FIFO queue mechanism
US7609708B2 (en) * 2005-10-04 2009-10-27 Intel Corporation Dynamic buffer configuration
US20080222255A1 (en) * 2007-03-08 2008-09-11 Andrew Douglass Hall Systems and methods for providing high performance and scalable messaging
CN101094098A (zh) * 2007-07-19 2007-12-26 上海交通大学 同步数字体系网络标记交换的标记处理方法
US8200836B2 (en) * 2007-11-16 2012-06-12 Microsoft Corporation Durable exactly once message delivery at scale
EP2187580B1 (en) * 2008-11-18 2013-01-16 Alcatel Lucent Method for scheduling packets of a plurality of flows and system for carrying out the method
US9585062B2 (en) * 2010-07-15 2017-02-28 Dejero Labs Inc. System and method for implementation of dynamic encoding rates for mobile devices
US8199752B2 (en) * 2009-10-02 2012-06-12 Limelight Networks, Inc. Enhanced anycast for edge server selection
US8996563B2 (en) * 2010-04-06 2015-03-31 Tokutek, Inc. High-performance streaming dictionary
US9224111B2 (en) * 2011-02-25 2015-12-29 Red Hat, Inc. Message queue based product asset management auditing system
US9015303B2 (en) * 2011-09-12 2015-04-21 Microsoft Corporation Message queue behavior optimizations
US9436532B1 (en) * 2011-12-20 2016-09-06 Emc Corporation Method and system for implementing independent message queues by specific applications
DE112011106016T5 (de) * 2011-12-23 2014-09-11 Intel Corporation Gemeinsame Sendeschlange
US9246836B2 (en) * 2012-08-30 2016-01-26 Sybase, Inc. Single producer, single consumer lockless FIFO/LIFO queue
US9348648B2 (en) * 2012-09-12 2016-05-24 Salesforce.Com, Inc. Providing a routing framework for facilitating dynamic workload scheduling and routing of message queues for fair management of resources for application servers in an on-demand services environment
US9495296B2 (en) * 2013-06-12 2016-11-15 Oracle International Corporation Handling memory pressure in an in-database sharded queue
US9372879B1 (en) * 2013-12-20 2016-06-21 Amazon Technologies, Inc. Balanced append tree data structure
US9578120B1 (en) * 2013-12-20 2017-02-21 Amazon Technologies, Inc. Messaging with key-value persistence
US20160043981A1 (en) * 2014-08-11 2016-02-11 Facebook, Inc. Techniques for a persistent queue for message syncing
US9680761B2 (en) * 2014-08-14 2017-06-13 Dropbox, Inc. Consolidating messages in a message queue
CN104915248A (zh) * 2015-05-18 2015-09-16 北京京东尚科信息技术有限公司 计算机实现的商品提供/消费方法及系统
US20170078367A1 (en) * 2015-09-10 2017-03-16 Lightfleet Corporation Packet-flow message-distribution system
US9906480B2 (en) * 2015-12-10 2018-02-27 Facebook, Inc. Techniques for ephemeral messaging with legacy clients
US10200330B2 (en) * 2015-12-10 2019-02-05 Facebook, Inc. Techniques for ephemeral messaging with a message queue
CN107231283B (zh) 2016-03-23 2020-12-18 阿里巴巴集团控股有限公司 消息管理方法及装置、消息预读方法及装置
US9996404B2 (en) * 2016-09-01 2018-06-12 Oracle International Corporation Message cache management for message queues
US10540217B2 (en) * 2016-09-16 2020-01-21 Oracle International Corporation Message cache sizing

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101763289A (zh) * 2009-09-25 2010-06-30 中国人民解放军国防科学技术大学 一种基于共享内存的消息传递方法
WO2013143285A1 (zh) * 2012-03-28 2013-10-03 华为技术有限公司 流量控制方法、装置和集群系统
CN102902512A (zh) * 2012-08-31 2013-01-30 浪潮电子信息产业股份有限公司 一种基于多线程编程及消息队列的多线程并行处理方法
CN103984734A (zh) * 2014-05-20 2014-08-13 中国科学院软件研究所 一种面向高性能计算的云服务消息传递方法
CN105407152A (zh) * 2015-11-03 2016-03-16 竞技世界(杭州)网络技术有限公司 推送消息的方法

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11165740B2 (en) 2016-03-23 2021-11-02 Alibaba Group Holding Limited Message sending method and terminal device

Also Published As

Publication number Publication date
CN107231283A (zh) 2017-10-03
US20190028422A1 (en) 2019-01-24
US11165740B2 (en) 2021-11-02
TW201734842A (zh) 2017-10-01
TWI735533B (zh) 2021-08-11
CN107231283B (zh) 2020-12-18

Similar Documents

Publication Publication Date Title
CN114281859B (zh) 数据处理方法、设备及存储介质
WO2016161807A1 (zh) 相册显示方法及装置
WO2015143806A1 (zh) 页面回退控制方法及装置
CN106126052A (zh) 文本选择方法及装置
CN115208810A (zh) 一种转发流表加速方法及装置、电子设备和存储介质
CN105843951B (zh) 数据查询方法和装置
CN112948440A (zh) 页面数据的处理方法及装置、终端、存储介质
WO2017088247A1 (zh) 输入处理方法、装置及设备
TWI735533B (zh) 訊息管理方法及裝置、訊息預讀方法及裝置
WO2023108989A1 (zh) 数据访问方法、装置及非临时性计算机可读存储介质
CN109471596B (zh) 数据写入方法、装置、设备及存储介质
US11494117B2 (en) Method and system for data processing
CN118656351B (zh) 大文件拷贝方法、装置、电子设备及存储介质
CN107329744A (zh) 应用程序的功能模块启动方法及装置
CN114385373A (zh) 数据分享方法、数据分享装置以及计算机可读存储介质
CN111813514A (zh) 一种线程管理方法及装置、电子设备和存储介质
CN111694768A (zh) 运算方法、装置及相关产品
CN116185301A (zh) 数据存储处理方法、平台、服务器、系统、介质及产品
CN108009025A (zh) 数据存储方法及装置
CN114489733A (zh) 流控配置更新方法、装置和设备
CN106598386A (zh) 文字删除方法和装置
CN112422597B (zh) 网络内容访问方法、装置及存储介质
CN107885553A (zh) 动画加载方法、装置及电子设备
CN115963989A (zh) 静态随机存取存储器的控制方法及装置
CN107257384A (zh) 服务状态监控方法及装置

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17769336

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 17769336

Country of ref document: EP

Kind code of ref document: A1