本發明關於網路技術領域,特別是關於一種訊息處理方法及系統。The present invention relates to the field of network technologies, and more particularly to a message processing method and system.
在實際應用中,存在這樣一種業務系統:系統包括訊息發佈端、訊息訂閱端和訊息中間件,訊息發佈端和訊息訂閱端之間通過訊息中間件傳送訊息資料。其中,該訊息發佈端可以發佈各種主題或各種類型的訊息資料,該訊息訂閱端可以訂閱自己感興趣的訊息,該訊息中間件要將訊息發佈端發佈的訊息非同步地傳送給該訊息主題的訂閱端。所以,針對同一主題下的訊息,可以有多個訂閱端同時訂閱。而訂閱端不同,每個訂閱端收到自己訂閱的訊息後也會進行不同的處理。假設有兩個訂閱端分別(SubscriberA和SubscriberB)訂閱了TopicA這個主題,兩個訂閱端收到訊息後分別進行各自的處理。In practical applications, there is a business system in which the system includes a message publishing end, a message subscribing end, and a message middleware, and the message publishing end and the message subscribing end transmit the message data through the message middleware. The message publisher can publish various topics or various types of message materials, and the message subscriber can subscribe to the message of interest to the message, and the message middleware needs to transmit the message posted by the message publisher to the message subject asynchronously. Subscriber. Therefore, for messages under the same topic, multiple subscribers can subscribe at the same time. Different subscribing sites, each subscribing will receive different processing after receiving the message that it subscribes to. Suppose two sub-subscribers (SubscriberA and SubscriberB) subscribe to the topic TopicA, and the two sub-subscribers receive their own messages after receiving the message.
舉例說明,在電子交易過程中,當創建交易成功後,交易處理系統(即訊息發佈端)會發出交易創建成功的通知訊息。交易日誌伺服器(即訊息訂閱端)會訂閱該訊息,用於記錄交易日誌;而賣家通知伺服器(即另一訊息訂閱端)也會訂閱該訊息,用於通知賣家有商品被購買。因此,這兩種伺服器對同一個訊息有不同的處理。For example, in the electronic transaction process, when the transaction is successfully created, the transaction processing system (ie, the message issuing end) will issue a notification message that the transaction is successfully created. The transaction log server (ie, the message subscriber) subscribes to the message to record the transaction log; the seller notification server (ie, another message subscriber) also subscribes to the message to notify the seller that the item has been purchased. Therefore, these two servers have different processing for the same message.
類似的應用還有很多,這些業務系統中都存在多個訂閱端訂閱同一訊息主題的情況,此時就需要訊息中間件將同一主題的訊息傳送給不同的訂閱端。目前,這類系統的實現方式是:每個訊息訂閱端都由一個節點構成,即只有一台機器提供服務。但隨著業務的發展,系統處理的資料量不斷增加,這種系統結構已不能滿足大資料量的處理,常常存在以下問題:There are many similar applications. In these business systems, there are multiple subscribing sites that subscribe to the same message subject. In this case, the message middleware needs to transmit the message of the same topic to different subscribing terminals. Currently, such systems are implemented in such a way that each message subscription end consists of one node, that is, only one machine provides services. However, with the development of the business, the amount of data processed by the system is increasing. This system structure can no longer meet the processing of large data volume, and often has the following problems:
第一,如果訊息訂閱端的節點出現故障,就可能無法從訊息中間件接收自己訂閱的訊息;或者接收到訊息但無法進行處理,即訂閱端的訊息處理過程會被中斷,從而影響與之關聯的其他系統的處理;First, if the node at the message subscriber fails, it may not be able to receive the message subscribed to by the message middleware; or if the message is received but cannot be processed, the message processing of the subscriber will be interrupted, thereby affecting other associated with it. System processing;
第二,如果訊息流量非常大,一個節點的處理能力可能達不到處理要求;而當訊息量超過一個節點的處理能力後,只能通過升級硬體來解決,並且如果達到硬體的極限,則可能導致整個應用系統結構的修改。Second, if the message traffic is very large, the processing power of a node may not meet the processing requirements; and when the amount of information exceeds the processing power of a node, it can only be solved by upgrading the hardware, and if the hardware limit is reached, This may result in modifications to the entire application system structure.
本發明所要解決的技術問題是提供一種訊息處理方法及系統,以解決現有的訊息處理系統中訊息訂閱端由單節點實現所存在的問題。The technical problem to be solved by the present invention is to provide a message processing method and system for solving the problem that the message subscribing end of the existing message processing system is implemented by a single node.
為解決上述技術問題,根據本發明提供的具體實施例,本發明公開了以下技術方案:一種訊息處理系統,包括:訊息發佈端、訊息訂閱端和訊息中間件,其中,該訊息訂閱端包括一個或多個分組,每組具有唯一標識;每組訊息訂閱端又包括一個或多個節點,每個節點通過本組的唯一標識連接到該訊息中間件;該訊息發佈端用於將訊息發佈到訊息中間件;該訊息中間件用於根據接收到的訊息的類型,查找對應該訊息類型的訂閱端分組標識;如果查找到,則根據查找到的訂閱端分組標識,將該訊息發送到相應訂閱端分組中的一個節點上。In order to solve the above technical problem, according to a specific embodiment of the present invention, the present invention discloses the following technical solution: a message processing system, comprising: a message publishing end, a message subscribing end and a message middleware, wherein the message subscribing end includes a Or multiple groups, each group having a unique identifier; each group of message subscribing ends includes one or more nodes, each node is connected to the message middleware by the unique identifier of the group; the message issuing end is used to post the message to a message middleware; the message middleware is configured to search for a subscribing group identifier corresponding to the type of the message according to the type of the received message; if found, send the message to the corresponding subscription according to the found subscribing group identifier On one of the nodes in the end group.
較佳的,該訊息訂閱端中的每個節點採用長連接方式與訊息中間件連接,即每個訂閱端節點與訊息中間件在建立連接後保持該連接。Preferably, each node in the message subscriber end is connected to the message middleware by using a long connection manner, that is, each subscriber end node maintains the connection with the message middleware after establishing a connection.
其中,該訊息中間件從當前的連接中查找對應該訂閱端分組標識的連接,如果查找到多個連接,則從中選擇一個連接,並通過該連接將該訊息發送到該連接對應的節點上。The message middleware searches for a connection corresponding to the subscribing group identifier from the current connection. If multiple connections are found, a connection is selected from the connection, and the message is sent to the node corresponding to the connection through the connection.
其中,該訊息訂閱端節點用於對接收到的訊息進行相應處理。The message subscribing node is configured to process the received message accordingly.
其中,新增加的訊息訂閱端節點使用與本組其他節點相同的標識連接到該訊息中間件。The newly added message subscribing node connects to the message middleware using the same identifier as the other nodes of the group.
較佳的,該系統還包括:資料庫,用於與該訊息中間件連接,儲存訊息中間件接收到的訊息,以及訊息類型與訂閱端分組標識的對應關係,以及每個訂閱端分組標識對應的節點資訊。Preferably, the system further comprises: a database for connecting with the message middleware, storing the message received by the message middleware, and the correspondence between the message type and the subscribing group identifier, and corresponding to each subscribing group identifier Node information.
較佳的,該訊息發佈端也包括一個或多個分組,每組具有唯一標識;每組訊息分佈端又包括一個或多個節點,每個節點通過本組的唯一標識連接到該訊息中間件。Preferably, the message publishing end also includes one or more packets, each group having a unique identifier; each group of message distribution ends includes one or more nodes, and each node is connected to the message middleware by the unique identifier of the group. .
本發明還提供了一種訊息處理方法,包括:發佈端將訊息發佈到訊息中間件;訊息中間件根據該訊息的類型,查找對應該訊息類型的訂閱端分組標識;如果查找到,則訊息中間件根據查找到的訂閱端分組標識,將該訊息發送到相應訂閱端分組中的一個節點上。The invention also provides a message processing method, comprising: the publishing end publishing the message to the message middleware; the message middleware searching for the subscribing end group identifier corresponding to the message type according to the type of the message; if found, the message middleware The message is sent to a node in the corresponding subscribing group packet based on the found subscribing packet identifier.
較佳的,該訊息中間件根據查找到的訂閱端分組標識,將該訊息發送到相應訂閱端分組中的一個節點上,具體包括:採用長連接方式,每個訂閱端節點與訊息中間件在建立連接後保持該連接;從當前連接到訊息中間件的連接中查找對應該訂閱端分組標識的連接,如果查找到多個連接,則從中選擇一個連接;訊息中間件通過該連接將該訊息發送到該連接對應的節點上。Preferably, the message middleware sends the message to a node in the corresponding subscribing group according to the found subscribing group identifier, which comprises: using a long connection mode, each subscribing node and the message middleware are The connection is maintained after the connection is established; the connection corresponding to the subscribing group identifier is found in the connection currently connected to the message middleware, and if multiple connections are found, one connection is selected; the message middleware sends the message through the connection Go to the node corresponding to the connection.
其中,如果查找到多個連接,則從中隨機選擇一個連接,或者輪詢每個連接。Among them, if multiple connections are found, one connection is randomly selected from them, or each connection is polled.
其中,如果查找到多個訂閱端分組標識,則依次將該訊息發送到每個訂閱端分組中的一個節點上。Wherein, if multiple subscribing group identifiers are found, the message is sent to one node in each subscribing group in turn.
較佳的,該發佈端將訊息發佈到訊息中間件之後,還包括:訊息中間件將該訊息存入資料庫,並向該發佈端返回發佈成功的訊息。Preferably, after the publishing end posts the message to the message middleware, the message middleware stores the message in the database and returns a successful message to the publishing terminal.
其中,該訊息中間件根據查找到的訂閱端分組標識,將該訊息發送到相應訂閱端分組中的一個節點上之後,還包括:收到訊息的訂閱端節點對該訊息進行相應處理。The message middleware sends the message to a node in the corresponding subscribing group packet according to the found subscribing group identifier, and further includes: the subscribing end node that receives the message processes the message accordingly.
較佳的,該發佈端將訊息發佈到訊息中間件,具體包括:該發佈端包括一個或多個分組,每組包括一個或多個節點;每組發佈端選擇其中一個節點將該組的訊息發佈到訊息中間件。Preferably, the publishing end publishes the message to the message middleware, and specifically includes: the publishing end includes one or more groups, each group includes one or more nodes; each group of publishing ends selects one of the nodes to select the group of messages. Post to message middleware.
根據本發明提供的具體實施例,本發明具有以下技術效果:首先,本發明通過將訊息訂閱端分組,每組再部署多個節點的系統架構方式,由多個節點共同承擔一個訊息訂閱端的工作。這樣,在訊息到達訊息中間件後,會從每個分組標識下的節點中選擇一個節點,主動將訊息推送給訂閱端節點。該方案能夠避免現有技術存在的兩個問題:According to the specific embodiment provided by the present invention, the present invention has the following technical effects: First, the present invention shares the work of a message subscriber by grouping the message subscribing groups, and the system architecture mode of deploying multiple nodes in each group. . In this way, after the message arrives at the message middleware, a node is selected from each node under the group identifier, and the message is actively pushed to the subscribing node. This solution can avoid two problems existing in the prior art:
第一,如果訊息訂閱端的一個或幾個節點出現故障,則可以由該組中的其他節點繼續接收訊息進行處理,因此避免了處理被中斷的問題;First, if one or several nodes of the message subscribing fail, the other nodes in the group can continue to receive messages for processing, thus avoiding the problem of interrupted processing;
第二,如果訊息流量非常大,則可以由一組中的多個節點來處理,或者通過增加訂閱端節點的方式來均衡處理壓力。Second, if the message traffic is very large, it can be handled by multiple nodes in a group, or the processing pressure can be balanced by increasing the number of subscribing nodes.
其次,本發明採用長連接方式,即每個訂閱端節點與訊息中間件在建立連接後保持該連接。這樣,在訊息中間件收到訊息後,可以從當前建立的連接中查找訂閱端節點的連接,主動將訊息推動給訂閱端節點。該連接方式由於避免了建立、斷開連接的消耗,因此即時性很高,訊息能夠以最快的速度發送給訂閱端。Secondly, the present invention adopts a long connection mode, that is, each subscribing node maintains the connection with the message middleware after establishing a connection. In this way, after the message middleware receives the message, it can find the connection of the subscribing node from the currently established connection, and actively push the message to the subscribing node. This connection method avoids the consumption of establishing and disconnecting, so the immediacy is very high, and the message can be sent to the subscribing end as quickly as possible.
再次,上述針對訊息訂閱端的方案同樣適用於訊息發佈端。該訊息發佈端也可以分組,每組部署多個節點,發佈訊息時選擇組內的一個節點進行發送。這樣,訊息發佈端可以避免一個節點出故障而影響訊息的發佈;並且,如果需要發佈的訊息流量非常大,可以通過一組內的多個節點進行發佈,從而緩解了發佈端的處理壓力。Again, the above scheme for the message subscriber also applies to the message publishing side. The message publishing end can also be grouped, each node is deployed with multiple nodes, and one node in the group is selected for sending when the message is published. In this way, the message issuing end can avoid the failure of one node and affect the release of the message; and if the traffic to be published is very large, it can be distributed through multiple nodes in a group, thereby alleviating the processing pressure on the publishing end.
為使本發明的上述目的、特徵和優點能夠更加明顯易懂,下面結合附圖和具體實施方式對本發明作進一步詳細的說明。The present invention will be further described in detail with reference to the accompanying drawings and specific embodiments.
本發明實施例提供了一種訊息處理系統,是對現有技術中的訊息處理系統的改進。參照圖1,是實施例該系統的結構圖。The embodiment of the invention provides a message processing system, which is an improvement of the prior art message processing system. Referring to Figure 1, there is shown a block diagram of the system of the embodiment.
該系統主要包括訊息發佈端U11、訊息中間件U12和訊息訂閱端U13,其中,該訊息發佈端U11和訊息訂閱端U13分別與訊息中間件U12的伺服器連接,訊息發佈端U11和訊息訂閱端U13之間通過訊息中間件U12傳送訊息資料。The system mainly includes a message publishing terminal U11, a message middleware U12 and a message subscribing terminal U13, wherein the message publishing terminal U11 and the message subscribing terminal U13 are respectively connected with the server of the message middleware U12, and the message publishing terminal U11 and the message subscribing end Message data is transmitted between U13 through message middleware U12.
與現有技術不同的是,該訊息訂閱端U13按照用戶端功能進行了分組,如圖中的分組A、分組B……,每組有一個分組ID作為該組的唯一標識;而每組訊息訂閱端又可以包括一個或多個節點,屬於同一個分組的訂閱端節點具有相同的分組ID,所以每個訂閱端節點通過本組的ID連接到該訊息中間件U12。Different from the prior art, the message subscribing terminal U13 is grouped according to the function of the client, such as group A, group B, ... in the figure, each group has a group ID as a unique identifier of the group; and each group of messages is subscribed. The terminal may in turn include one or more nodes, and the subscribing nodes belonging to the same group have the same packet ID, so each subscribing node is connected to the message middleware U12 by the ID of the group.
該訊息發佈端U11將訊息發佈到訊息中間件U12的伺服器上,訊息中間件U12根據接收到的訊息的類型,查找對應該訊息類型的訂閱端分組ID;如果查找到,則根據查找到的訂閱端分組ID,從分組中選擇一個節點,主動將訊息推送給該節點。由於同一主題的訊息可以被多組訊息訂閱端訂閱,所以一個訊息可能會發送給多組訊息訂閱端,並且每組訊息訂閱端中只會有一個節點收到該訊息。The message issuing end U11 posts the message to the server of the message middleware U12, and the message middleware U12 searches for the subscribing end group ID corresponding to the message type according to the type of the received message; if found, according to the found The subscribing group ID, select a node from the group, and actively push the message to the node. Since messages of the same topic can be subscribed to by multiple groups of message subscribers, a message may be sent to multiple groups of message subscribers, and only one node in each group of message recipients will receive the message.
訂閱端節點收到訊息後,會進行相應的處理。相同分組的訂閱端節點對訊息進行相同的處理,不同分組的訂閱端節點對訊息進行各自的處理,而同一條訊息在一個分組內只會由一個節點處理。例如,在電子交易過程中,交易日誌伺服器組的每台機器(即訊息訂閱端節點)收到交易創建成功的訊息,都用於記錄交易日誌;而賣家通知伺服器組的每台機器(即另一訊息訂閱端節點)收到交易創建成功的訊息,都用於通知賣家有商品被購買。After the subscribing node receives the message, it will process it accordingly. The same node's subscribing node performs the same processing on the message, and the subscribing nodes of different groups process the messages individually, and the same message is processed by only one node in one packet. For example, in an electronic transaction process, each machine of the transaction log server group (ie, the message subscribing node) receives a message that the transaction was successfully created, and is used to record the transaction log; and the seller notifies each machine of the server group ( That is, another message subscribing node) receives a message that the transaction is successfully created, and is used to notify the seller that the item has been purchased.
較佳的,該系統還可以包括資料庫U14,該資料庫U14與該訊息中間件U12相連接,用於儲存訊息中間件U12接收到的訊息,以及訊息類型與訂閱端分組標識的對應關係,以及每個訂閱端分組標識對應的節點資訊。當然,這些資訊也可以儲存在訊息中間件U12伺服器設置的內部儲存結構中,本實施例在此不作限定。Preferably, the system further includes a database U14, and the database U14 is connected to the message middleware U12 for storing the message received by the message middleware U12 and the correspondence between the message type and the subscription group identifier. And the node information corresponding to each subscribing group identifier. Of course, the information may be stored in the internal storage structure of the message middleware U12 server. The embodiment is not limited herein.
由上可知,該系統由於在訊息訂閱端部署了多個節點,由多個節點共同承擔一個訊息訂閱端的工作,所以具有容錯和處理大流量訊息的功能。具體分析如下:It can be seen from the above that the system has the function of fault tolerance and processing large traffic messages because multiple nodes are deployed at the message subscription end, and multiple nodes share the work of a message subscription end. The specific analysis is as follows:
第一,如果訊息訂閱端的一個或幾個節點出現故障,則可以由該組中的其他節點繼續接收訊息進行處理,因此避免了處理被中斷的問題,該系統具有良好的容錯功能;第二,如果訊息流量非常大,則可以由一組中的多個節點來處理,或者通過增加訂閱端節點的方式來均衡處理壓力。First, if one or several nodes of the message subscriber end fails, the other nodes in the group can continue to receive messages for processing, thereby avoiding the problem of interrupted processing, and the system has good fault tolerance; second, If the message traffic is very large, it can be handled by multiple nodes in a group, or the processing pressure can be balanced by increasing the number of subscribing nodes.
其中,上述的“共同”是指:某種訊息每秒鐘可能會產生500條,假設一個分組有5個訂閱端節點,則是該的5個節點去處理500條訊息,每個訂閱端節點處理100條。如果有一個節點出現故障,則是其他4個訂閱端節點去處理這500條訊息。這樣,整個系統就不會因為一個訂閱端節點的問題而影響到訊息的處理。The above-mentioned "common" means that a certain message may generate 500 messages per second, assuming that one packet has 5 subscribing nodes, then the 5 nodes process 500 messages, and each subscribing node Process 100 items. If one node fails, the other four subscribing nodes process the 500 messages. In this way, the entire system will not affect the processing of the message due to the problem of a subscribing node.
基於圖1系統實施例的說明,在本發明的另一系統實施例中,還提供了如下的較佳功能:每個訂閱端節點與訊息中間件的伺服器之間採用長連接的方式,如果通信協定是TCP協定(Transmission Control Protocol,傳輸控制協定),則為TCP長連接。該長連接是相對於短連接來說的,短連接是指用戶端和伺服器端建立連接後,處理完畢就斷開了連接,而長連接是指建立了連接後就保持連接。採用長連接方式,在有訊息的時候,訊息中間件的伺服器可以從當前建立的連接中查找訂閱端節點的連接,主動將訊息推送給訂閱端節點。由於建立、斷開連接本身是有消耗的,所以長連接的即時性很高,訊息能夠以最快的速度發送給訂閱端節點。Based on the description of the system embodiment of FIG. 1, in another system embodiment of the present invention, a preferred function is also provided: a long connection is used between each subscribing node and the server of the message middleware, if The communication protocol is a TCP (Transmission Control Protocol), which is a TCP long connection. The long connection is relative to the short connection. The short connection means that after the connection between the client and the server is completed, the connection is disconnected after processing, and the long connection means that the connection is maintained after the connection is established. With the long connection method, when there is a message, the server of the message middleware can find the connection of the subscribing node from the currently established connection, and actively push the message to the subscribing node. Since the establishment and disconnection itself is consumable, the long connection is very immediacy and the message can be sent to the subscribing node at the fastest speed.
基於圖1系統實施例的說明,在本發明的另一系統實施例中,還提供了如下的較佳功能:該系統還可以動態調整每組訊息訂閱端中的節點數量,靈活地增加或刪除某個分組下的節點。在訊息流量增大的時候,現有的節點可能滿足不了處理需求,就可以增加新的節點,使用和本組中當前工作的節點相同的分組Id來連接到訊息中間件的伺服器,就完成了節點的增加。如果是節點數量過多,需要去掉一些節點,則直接停掉這些要去除的節點上的應用就可以了。Based on the description of the system embodiment of FIG. 1, in another system embodiment of the present invention, the following preferred functions are also provided: the system can also dynamically adjust the number of nodes in each group of message subscriptions, and flexibly add or delete A node under a group. When the message traffic increases, the existing node may not be able to meet the processing requirements, and then a new node can be added, and the same packet Id as the currently working node in the group is used to connect to the server of the message middleware, and the task is completed. The addition of nodes. If there are too many nodes and need to remove some nodes, just stop the applications on the nodes to be removed.
基於圖1系統實施例的說明,在本發明的另一系統實施例中,還提供了如下的較佳功能:該訊息發佈端也可以進行分組,每組有一個分組ID作為該組的唯一標識;而每組訊息發佈端又可以包括一個或多個節點,屬於同一個分組的發佈端節點具有相同的分組ID,所以每個發佈端節點通過本組的ID連接到該訊息中間件。訊息發佈端發佈訊息時可以選擇組內的一個節點進行發送,這樣,訊息發佈端可以避免一個節點出故障而影響訊息的發佈;並且,如果需要發佈的訊息流量非常大,可以通過一組內的多個節點進行發佈,緩解發佈端的處理壓力。參照圖2所示,訊息訂閱端包括分組A和分組B,每個分組下包括2個節點;訊息發佈端包括分組C和分組D,每個分組下也包括2個節點。Based on the description of the system embodiment of FIG. 1, in another system embodiment of the present invention, a preferred function is also provided: the message issuing end can also perform grouping, and each group has a group ID as a unique identifier of the group. And each group of message publishing ends may include one or more nodes, and the publishing end nodes belonging to the same group have the same group ID, so each publishing end node is connected to the message middleware by the ID of the group. When the message publishing end publishes the message, it can select a node in the group to send, so that the message issuing end can avoid the failure of one node and affect the release of the message; and if the traffic to be published is very large, it can pass through a group. Multiple nodes are released to ease the processing pressure on the publishing end. Referring to FIG. 2, the message subscribing includes a packet A and a packet B, each of which includes 2 nodes; the message issuing end includes a packet C and a packet D, and each packet also includes 2 nodes.
針對上述系統實施例的說明,本發明還提供了相應的訊息處理方法實施例。該方法包括兩部分處理,一部分是訂閱者註冊流程,一部分是訊息的處理流程,下面分別說明。For the description of the above system embodiment, the present invention also provides a corresponding embodiment of the message processing method. The method includes two parts processing, one part is the subscriber registration process, and the other part is the processing flow of the message, which are respectively described below.
參照圖3,是實施例該訂閱者註冊訂閱訊息的流程圖。Referring to Figure 3, there is shown a flow diagram of the subscriber registering a subscription message in an embodiment.
S301,訊息訂閱端進行註冊,訂閱自己需要或感興趣的訊息主題;該訊息訂閱端代表一個訂閱端分組,註冊的過程即把該分組的ID發送給訊息中間件伺服器,並把該分組訂閱的訊息類型也發送給訊息中間件伺服器。S301: The message subscriber registers to subscribe to a message subject that is needed or of interest; the message subscriber represents a subscribing group, and the registration process sends the ID of the packet to the message middleware server, and subscribes the packet. The message type is also sent to the message middleware server.
S302,訊息中間件伺服器根據訂閱端訂閱的訊息類型,將該訂閱端的分組ID記錄下來,即將訂閱端分組ID與所訂閱的訊息類型的映射關係記錄到資料庫中;S303,訊息中間件伺服器向訂閱端返回訂閱成功的訊息。S302. The message middleware server records the packet ID of the subscribing end according to the type of the message subscribed by the subscribing party, and records the mapping relationship between the subscribing end packet ID and the subscribed message type in the database; S303, the message middleware servo The device returns a message of successful subscription to the subscriber.
訂閱端按照上述流程進行註冊後,訊息中間件會把訊息主動推送給訂閱該訊息的訂閱端,推送時會選擇訂閱端分組中的一個節點進行推送。After the subscriber registers according to the above process, the message middleware will actively push the message to the subscribing party that subscribes to the message, and pushes a node in the subscribing group to push.
參照圖4,是實施例該訊息的處理流程圖。Referring to Figure 4, there is shown a process flow diagram of the message in the embodiment.
S401,訊息發佈端發送訊息到訊息中間件伺服器;S402,訊息中間件伺服器把訊息存入資料庫,並在任務佇列中放入一個推送訊息任務,並返回“成功”給訊息發送端;S403,訊息中間件伺服器從任務佇列中取出任務,根據訊息的類型找到相應的訂閱端分組ID(可能是一個也可能是多個);S404,依次處理每個訂閱者分組,處理過程是:根據分組ID與訂閱端節點連接的映射關係,從當前連接到訊息中間件伺服器上的連接中找到是屬於該訂閱者分組的連接;S405,如果連接大於一個則隨機選擇一個,否則就直接選擇這一個連接;此外,除了隨機選擇的方式,也可以採用輪詢分組中每個節點的方式,將訊息方式給空閒的節點。S401, the message issuing end sends a message to the message middleware server; S402, the message middleware server stores the message in the database, and puts a push message task in the task queue, and returns "success" to the message sending end. S403, the message middleware server extracts the task from the task queue, and finds the corresponding subscribing group ID (may be one or more) according to the type of the message; S404, processing each subscriber group in turn, processing Yes: according to the mapping relationship between the group ID and the subscribing node connection, find the connection belonging to the subscriber group from the connection currently connected to the message middleware server; S405, if the connection is greater than one, randomly select one, otherwise Directly select this connection; in addition, in addition to the random selection method, you can also poll the idle node by polling each node in the packet.
S406,訊息中間件伺服器將訊息通過該連接推送給訂閱端節點;S407,收到訊息的訂閱端節點對該訊息進行相應處理。S406: The message middleware server pushes the message to the subscribing node through the connection; S407, the subscribing end node that receives the message processes the message accordingly.
上述處理過程中,訂閱端節點與訊息中間件伺服器是長連接方式,所以訊息中間件伺服器在收到訊息的時候,就可以從當前建立的連接中查找訂閱端節點的連接,主動將訊息推送給訂閱端節點。In the above process, the subscribing node and the message middleware server are connected in a long way, so when the message middleware server receives the message, it can find the connection of the subscribing node from the currently established connection, and actively send the message. Push to the subscribing node.
而且,該訊息發佈端也可以包括多個分組,每組包括一個或多個節點,每組發佈端選擇其中一個節點將該組的訊息發佈到訊息中間件,從而避免一個節點出故障而影響訊息的發佈;並且,如果需要發佈的訊息流量非常大,可以通過一組內的多個節點進行發佈,均衡發佈端的處理壓力。Moreover, the message issuing end may also include multiple groups, each group includes one or more nodes, and each group of publishing terminals selects one of the nodes to post the message of the group to the message middleware, thereby preventing one node from malfunctioning and affecting the message. The release; and, if the traffic to be published is very large, it can be distributed through multiple nodes in a group to balance the processing pressure of the publisher.
圖3所示流程中未詳述的部分可以參見圖1、圖2所示系統的相關部分,為了篇幅考慮,在此不再詳述。The parts not detailed in the flow shown in FIG. 3 can be referred to the relevant parts of the system shown in FIG. 1 and FIG. 2, and will not be described in detail herein for the sake of space.
以上對本發明所提供的一種訊息處理方法及系統,進行了詳細介紹,本文中應用了具體個例對本發明的原理及實施方式進行了闡述,以上實施例的說明只是用於幫助理解本發明的方法及其核心思想;同時,對於本領域的一般技術人員,依據本發明的思想,在具體實施方式及應用範圍上均會有改變之處。綜上該,本說明書內容不應理解為對本發明的限制。The method and system for processing a message provided by the present invention are described in detail. The principles and embodiments of the present invention are described herein by using specific examples. The description of the above embodiments is only for helping to understand the method of the present invention. And its core idea; at the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific embodiments and application scope. In conclusion, the content of the present specification should not be construed as limiting the invention.
U11...訊息發佈端U11. . . Message publishing end
U12...訊息中間件U12. . . Message middleware
U13...訊息訂閱端U13. . . Message subscription
U14...資料庫U14. . . database
圖1是本發明實施例所述一種訊息處理系統的結構圖;1 is a structural diagram of a message processing system according to an embodiment of the present invention;
圖2是本發明另一實施例所述的一種訊息處理系統的結構圖;2 is a structural diagram of a message processing system according to another embodiment of the present invention;
圖3是本發明實施例所述訂閱者註冊訂閱訊息的流程圖;3 is a flowchart of a subscriber registration subscription message according to an embodiment of the present invention;
圖4是本發明實施例所述訊息的處理流程圖。FIG. 4 is a flowchart of processing a message according to an embodiment of the present invention.
U11...訊息發佈端U11. . . Message publishing end
U12...訊息中間件U12. . . Message middleware
U13...訊息訂閱端U13. . . Message subscription
U14...資料庫U14. . . database
A...訂閱端分組A. . . Subscriber grouping
B...訂閱端分組B. . . Subscriber grouping
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| TW098110902ATWI477113B (en) | 2009-04-01 | 2009-04-01 | Information processing methods and systems |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| TW098110902ATWI477113B (en) | 2009-04-01 | 2009-04-01 | Information processing methods and systems |
| Publication Number | Publication Date |
|---|---|
| TW201038019A TW201038019A (en) | 2010-10-16 |
| TWI477113Btrue TWI477113B (en) | 2015-03-11 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| TW098110902ATWI477113B (en) | 2009-04-01 | 2009-04-01 | Information processing methods and systems |
| Country | Link |
|---|---|
| TW (1) | TWI477113B (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102467408B (en)* | 2010-11-12 | 2014-03-19 | 阿里巴巴集团控股有限公司 | Method and device for accessing data of virtual machine |
| CN104468339B (en)* | 2014-12-30 | 2018-03-27 | 合一网络技术(北京)有限公司 | Subscribe to information management method and system |
| CN110457141B (en)* | 2019-07-04 | 2023-12-05 | 创新先进技术有限公司 | Service message processing method, system, device and equipment |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US5920562A (en)* | 1996-11-22 | 1999-07-06 | Sprint Communications Co. L.P. | Systems and methods for providing enhanced services for telecommunication call |
| US7319857B2 (en)* | 2004-09-13 | 2008-01-15 | Tekelec | Methods, systems, and computer program products for delivering messaging service messages |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US5920562A (en)* | 1996-11-22 | 1999-07-06 | Sprint Communications Co. L.P. | Systems and methods for providing enhanced services for telecommunication call |
| US7319857B2 (en)* | 2004-09-13 | 2008-01-15 | Tekelec | Methods, systems, and computer program products for delivering messaging service messages |
| Publication number | Publication date |
|---|---|
| TW201038019A (en) | 2010-10-16 |
| Publication | Publication Date | Title |
|---|---|---|
| CN101668031B (en) | Message processing method and message processing system | |
| JP4415773B2 (en) | Multicast packet relay device for virtual router | |
| CA2770138C (en) | Cluster server of an instant messaging system and messaging method between clusters | |
| CN110661871B (en) | Data transmission method and MQTT server | |
| CN106713084B (en) | Multi-gateway system of Internet of things | |
| KR20170037818A (en) | Information-centric networking with small multi-path or single-path forwarding state | |
| CN114629953A (en) | Service cross-domain calling method and system based on proxy | |
| TWI477113B (en) | Information processing methods and systems | |
| CN108289055B (en) | Distributed real-time chat system and method based on Redis subscription service | |
| CN1487706B (en) | Method, system and control process for enterprise to communicate timely | |
| JP2017027499A (en) | Relay system, relay method, and program | |
| CN106790609B (en) | Data transmission method and device | |
| WO2013159492A1 (en) | Method and system for reporting and downloading information | |
| CN111294358B (en) | Message processing method and device | |
| US9042265B1 (en) | Workload balancing technique for a telephone communication system | |
| CN115037785B (en) | Instant communication system and method | |
| Banno et al. | Acceleration of MQTT-SN protocol using P4 | |
| EP1936876A1 (en) | Method and system for ensuring data exchange between a server system and a client system | |
| Kim et al. | A scalable pub/sub system for ndn | |
| CN106330744B (en) | Network-based theme ordering system | |
| CN110474781B (en) | Method and device for forwarding multicast data | |
| HK1141171B (en) | A message processing method and system | |
| WO2009056448A1 (en) | Method and apparatus for last message notification | |
| CN108093147B (en) | Distributed multi-stage scheduling method and equipment | |
| JP5713499B2 (en) | Multi-point distribution method and multi-point distribution system |
| Date | Code | Title | Description |
|---|---|---|---|
| MM4A | Annulment or lapse of patent due to non-payment of fees |