Specific embodiment
The present invention is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched
The specific embodiment stated is used only for explaining the present invention rather than limiting the invention.It also should be noted that in order to just
Only the parts related to the present invention are shown in description, attached drawing rather than entire infrastructure.
First embodiment
Fig. 2 shows the flow charts for the method for routing foundation based on message queue that first embodiment of the invention provides.?
In the present embodiment, is needing two application programs i.e. the first application program communicated in advance and establishing two between the second application program
A agency (agent), the agency established for the first application program is the first Application Agent, is established for the second application program
Agency is the second Application Agent.At least one queue management device of first Application Agent and the first application program local
Connection, the second Application Agent are connect at least one queue management device of the second application program local, every team's column manager
Local queue therein and remote queue are managed.
Referring to fig. 2, the present embodiment the method for routing foundation based on message queue the following steps are included:
Step 21: route exploration message is sent to the connected queue of the first Application Agent by the first Application Agent
Remote queue in manager;
In this step, the first Application Agent after actuation, to the connected queue management device of the first Application Agent
In remote queue send route exploration message, may include first using journey in the route exploration message sent to remote queue
Mark, the mark of the connected queue management device of the first Application Agent, the connected team of the first Application Agent of sequence agency
The mark of local queue in column manager and the mark of the remote queue.
The connected team of the first Application Agent is sent in the route exploration message that the first Application Agent is sent
After remote queue in column manager, the route exploration message in the remote queue is sent to second by message queue network
Local queue in the connected queue management device of Application Agent, the local queue are the remote queues in route exploration message
Pointed destination queue.
Step 22: the second Application Agent is from the local queue in the connected queue management device of the second Application Agent
After reading the route exploration message, the route exploration message is parsed, according to parsing result determination and is generated to the first application
First routing iinformation of programmatic agent, and according to first routing iinformation to the connected queue management device of the second Application Agent
In remote queue transmission reply message;
In this step, the second Application Agent handles the connected queue management device of the second Application Agent after actuation
In the route exploration message that receives of local queue.
Firstly, the second Application Agent passes through parsing route exploration message, available first Application Agent
Mark, the mark of the connected queue management device of the first Application Agent, the connected queue management device of the first Application Agent
In local queue mark and the remote queue in the connected queue management device of the first Application Agent mark.
Then, the second Application Agent determines the second Application Agent institute according to the configuration information locally pre-saved
Connect it is in queue management device, with the connect queue management device of the first Application Agent parsed and described first using journey
Sequence acts on behalf of remote queue corresponding to the local queue in connected queue management device, which is to be directed to parse
The remote queue of local queue in the connected queue management device of first Application Agent.
It is answered next, the second Application Agent generates the second Application Agent according to determining remote queue to first
With routing iinformation i.e. the first routing iinformation of programmatic agent, the first routing iinformation indicates that the second Application Agent can be by true
Fixed remote queue sends message to the first Application Agent.Second Application Agent adds the first routing iinformation of generation
Enter into the first local routing table.
Subsequent second application program is needing to send message to the first Application Agent by the second Application Agent
When, the second application program transmits the message to the second Application Agent, the second Application Agent by inquiry it is local the
One routing table acquires the routing iinformation of the first Application Agent, and sends a message to and be located at indicated by the routing iinformation
The remote queue in queue management device that second Application Agent is connected, the message are sent to by message queue network
Local queue in the connected queue management device of first Application Agent, then the first Application Agent is from the local queue
The first application program is sent to after reading message.What needs to be explained here is that if the second Application Agent is by inquiring this
First routing table on ground obtains a plurality of routing iinformation to the first Application Agent, then can select according to preset routing
It selects a good opportunity and makes to select a wherein routing iinformation and send message to the first Application Agent using the routing iinformation of selection.
Second Application Agent replies message, this is replied message after determining remote queue to remote queue transmission
In may include the first Application Agent for including in the mark and route exploration message of the second Application Agent and connected
The mark of remote queue in queue management device.The connected queue management of the second Application Agent is sent to replying message
After remote queue in device, replying message in the remote queue was sent to for the first application program generation by message queue network
Manage the local queue in connected queue management device.
Step 23: the first Application Agent is from the local in the connected queue management device of the first Application Agent
Queue receives reply message after, parse this and reply message, be generated to the second of the second Application Agent according to parsing result
Routing iinformation.
In this step, the first Application Agent is replied message by what the first Application Agent of parsing was sent, is obtained
The mark of remote queue in the mark and the connected queue management device of the first Application Agent of second Application Agent.The
One Application Agent is believed according to the routing that the information being resolved to generates the first Application Agent to the second Application Agent
Breath is secondary route information, and secondary route information indicates that the first Application Agent can be long-range by include in replying message
Queue sends message to the second Application Agent.The secondary route information of generation is added to local by the first Application Agent
Secondary route table in.
Subsequent first application program is needing to send message to the second Application Agent by the first Application Agent
When, the first application program transmits the message to the first Application Agent, the first Application Agent by inquiry it is local the
Two routing tables acquire the routing iinformation of the second Application Agent, and send a message to and be located at indicated by the routing iinformation
The remote queue in queue management device that first Application Agent is connected, the message are sent to by message queue network
Local queue in the connected queue management device of second Application Agent, then the second Application Agent is from the local queue
The second application program is sent to after reading message.What needs to be explained here is that if the first Application Agent is by inquiring this
The secondary route table on ground obtains a plurality of routing iinformation to the second Application Agent, then can be selected according to preset routing
It selects a good opportunity and makes to select a wherein routing iinformation and send message to the second Application Agent using the routing iinformation of selection.
In the present embodiment, the first Application Agent sends route exploration message to the second Application Agent, so that the
Two Application Agents establish the routing iinformation to the first Application Agent according to route exploration message, and, second answers
With programmatic agent to the first Application Agent transmission reply message so that the first Application Agent according to reply message foundation
To the routing iinformation of the second Application Agent, constructed automatically based on message queue to realize by Application Agent
Routing iinformation, do not need to obtain routing iinformation from system manager in advance before being communicated between application program, so that base
It is more easier in the exploitation of the application program of message queue, and enables routing iinformation on Application Agent according to disappearing
It ceases the variation of the topological structure between queue and carries out dynamic update therewith.
Second embodiment
Fig. 3 shows the process signal of the method for routing foundation based on message queue of second embodiment of the invention offer
Figure.In the present embodiment, the first application program (APP1) is associated with the first Application Agent (agent1), agent1 and team
Column manager 1 (QM1) is connected, and remote queue 2 (RQ2) and local queue 1 (QL1) are provided in QM1;Second application program
(APP2) associated with the second Application Agent (agent2), agent2 is connected with queue management device 2 (QM2), sets in QM2
It is equipped with remote queue 1 (RQ1) and local queue 2 (QL2);It is between Application Agent and queue management device in the present embodiment
One-to-one relationship.This gives the method for building up of the routing iinformation between agent1 and agent2 should referring to Fig. 3
Method includes the following steps:
Step 31:agent1 sends route exploration message to RQ2 after actuation, includes agent1 in the route exploration message
Mark, the mark of QM1, the mark of the mark of QL1 and RQ2, i.e., comprising such as next group information in route exploration message
(agent1, QM1, QL1, RQ2);
Step 32: after route exploration message is sent to RQ2, the route exploration message in RQ2 passes through message queue
(MQ) network is sent to QL2;
Step 33:agent2 reads route exploration message from QL2 after actuation;
Agent2 parses the route exploration message read, obtains information group (agent1, QM1, QL1, RQ2), determines QM2
In remote queue corresponding with QM1 and QL1 be RQ1;The routing iinformation of agent2 to agent1 is generated, is wrapped in the routing iinformation
Corresponding relationship containing QM2, RQ1 and agent1, i.e. (QM2, RQ1- > agent1);If in the first local routing table not with
The identical routing iinformation of the routing iinformation generated then the routing iinformation of generation is written in the first local routing table,
Otherwise the routing iinformation of generation is abandoned;
Step 34:agent2 to RQ1 transmission reply message, this reply message in comprising agent2 mark and RQ2 mark
Know, that is, reply message in comprising such as next group information (agent2, RQ2);It certainly, can also include QM2 and QL2 in replying message
Identification information.
Step 35: after replying message and being sent to RQ1, replying message in RQ1 is sent by message queue network
To QL1.
Step 36:agent1 reads from QL1 and replies message;
What agent1 parsing was read replies message, and obtains message groups (agent2, RQ2), generates agent1 to agent2
Routing iinformation, include the corresponding relationship of QM1, RQ2 and agent2 in the routing iinformation, i.e., (QM1, RQ2- > agent2);If
The identical routing iinformation of the routing iinformation for not having in the secondary route table of the local agent1 and generating, then by the road of generation
By otherwise abandoning the routing iinformation of generation in information write-in secondary route table.
The routing iinformation (QM2, RQ1- > agent1) of agent1 is established on agent2 and is established on agent1
After to the routing iinformation (QM1, RQ2- > agent2) of agent2, subsequent APP2 is needing to send by agent2 to agent1
When message, APP2 transmits the message to agent2, and agent2 acquires the road of agent1 by the first local routing table of inquiry
By information (QM2, RQ1- > agent1), the RQ1 in QM2 indicated by the routing iinformation is sent a message to, the message is by disappearing
Breath queue (MQ) network is sent to QL1 from RQ1, and then agent1 is sent to APP1 after reading message from QL1.After likewise,
For continuous APP1 when needing to send message to agent2 by agent1, APP1 transmits the message to agent1, and agent1 is by looking into
The routing iinformation (QM1, RQ2- > agent2) that local secondary route table acquires agent2 is ask, the routing is sent a message to
RQ2 in QM1 indicated by information, the message are sent to QL2 from RQ2 by message queue (MQ) network, then agent2
APP2 is sent to after reading message from QL2.
It present embodiments provides between Application Agent and queue management device when being one-to-one relationship, application program generation
The establishment process of routing iinformation between reason realizes the routing letter constructed automatically by Application Agent based on message queue
Breath.When routing iinformation, which is established, sends message to another application program with the latter application program, Application Agent is only needed
Know which agent is another application program be associated with, passes through the mark of the agent in the mark table of query and routing of agent
Then corresponding remote queue sends a message to the remote queue, which can be by message queue transmission of network to another
Application Agent.When the agent that the remote queue that an application program is locally defined is directed toward changes, corresponding routing
Route exploration message that information can be sent according to the agent after variation and automatically update, and message queue network and application program
The build process of agency all transfers to system manager to operate, so as to so that developer no longer need to concern queue variation it is more special
Infuse the development in business.
3rd embodiment
Fig. 4 shows the process signal of the method for routing foundation based on message queue of third embodiment of the invention offer
Figure.The present embodiment and embodiment two the difference is that, between the Application Agent and queue management device in the present embodiment
It is that one-to-many relationship namely Application Agent are connected with multiple queue management devices, the present embodiment is with Application Agent
It is illustrated for being connected with two queue management devices.Wherein, the first application program (APP1) and the first Application Agent
(agent1) it is associated, agent1 is connected with queue management device 1 (QM1) and queue management device 3 (QM3), is provided in QM1 remote
Journey queue 2 (RQ2) and local queue 1 (QL1) are provided with remote queue 4 (RQ4) and local queue 3 (QL3) in QM3;Second answers
It is associated with the second Application Agent (agent2) with program (APP2), agent2 and queue management device (QM2) and queue pipe
Reason device 4 (QM4) is connected, and remote queue 1 (RQ1) and local queue 2 (QL2) are provided in QM2, is provided with long-range team in QM4
Column 3 (RQ3) and local queue 4 (QL4).
In the present embodiment, routing iinformation is established by QM1 and QM2 between agent1 and agent2, method for building up can be with
Referring to the description of step 31- step 36 in embodiment two, which is not described herein again.
In the present embodiment, routing iinformation is also established by QM3 and QM4 between agent1 and agent2, referring to fig. 4, is built
Cube method includes the following steps:
Step 41:agent1 sends route exploration message to RQ4 after actuation, includes agent1 in the route exploration message
Mark, the mark of QM3, the mark of the mark of QL3 and RQ4, i.e., comprising such as next group information in route exploration message
(agent1, QM3, QL3, RQ4);
Step 42: after route exploration message is sent to RQ4, the route exploration message in RQ4 passes through message queue net
Network is sent to QL4;
Step 43:agent2 reads route exploration message from QL4 after actuation;
Agent2 parses the route exploration message read, obtains information group (agent1, QM3, QL3, RQ4), determines QM4
In remote queue corresponding with QM3 and QL3 be RQ3;The routing iinformation of agent2 to agent1 is generated, is wrapped in the routing iinformation
Corresponding relationship containing QM4, RQ3 and agent1, i.e. (QM4, RQ3- > agent1);If in the first local routing table not with
The routing iinformation of generation is then written in the first routing table, is otherwise lost by the identical routing iinformation of the routing iinformation generated
Abandon the routing iinformation generated.
Step 44:agent2 to RQ3 transmission reply message, this reply message in comprising agent2 mark and RQ4 mark
Know, that is, reply message in comprising such as next group information (agent2, RQ4);It certainly, can also include QM4 and QL4 in replying message
Identification information.
Step 45: after replying message and being sent to RQ3, replying message through message queue (MQ) network quilt in RQ3
It is sent to QL3.
Step 46:agent1 reads from QL3 and replies message;
What agent1 parsing was read replies message, and obtains message groups (agent2, RQ4), generates agent1 to agent2
Routing iinformation, include the corresponding relationship of QM3, RQ4 and agent2 in the routing iinformation, i.e., (QM3, RQ4- > agent2);If
The identical routing iinformation of the routing iinformation for not having in local secondary route table and generating, then by the routing iinformation of generation
It is written in secondary route table, otherwise abandons the routing iinformation of generation.
By the above process, two routing iinformations (QM2, RQ1- > agent1) of agent1 are established on agent2
(QM4, RQ3- > agent1), and establish on agent1 agent2 two routing iinformations (QM1, RQ2- >
Agent2) and (QM3, RQ4- > agent2), for subsequent APP2 when needing to send message to agent1 by agent2, APP2 will
Message is sent to agent2, and agent2 acquires two routing iinformations of agent1 by the first local routing table of inquiry
(QM2, RQ1- > agent1) and (QM4, RQ3- > agent1) selects a wherein road according to preset routing mechanism
By information, RQ1 indicated by the routing iinformation of selection or RQ3 is sent a message to, which passes through message queue network (MQ)
It is sent to QL1 or QL3 from RQ1 or RQ3, then agent1 is sent to APP1 after reading message from QL1 or QL3.After likewise,
For continuous APP1 when needing to send message to agent2 by agent1, APP1 transmits the message to agent1, and agent1 is by looking into
Ask local secondary route table acquire agent2 two routing iinformations (QM1, RQ2- > agent2) and (QM3, RQ4- >
Agent2), a wherein routing iinformation is selected according to preset routing mechanism, sends a message to the routing of selection
RQ2 indicated by information or RQ4, the message are sent to QL2 or QL4 from RQ2 or RQ4 by message queue (MQ) network, so
Agent2 is sent to APP2 after reading message from QL2 or QL4 afterwards.
As it can be seen that the first via that the second Application Agent generates in the embodiment of the present invention includes determining long-range team by information
The mark of queue management device and the mark of the first Application Agent where the mark of column, the remote queue of determination;By the first via
After in the first local routing table of information write-in, when receiving the message for needing to be sent to the first Application Agent,
The routing iinformation of mark of the inquiry comprising the first Application Agent in the first local routing table, if inquiry obtains a routing
Information then sends a message to the remote queue in queue management device indicated by the routing iinformation that inquiry obtains;If inquiring
To a plurality of routing iinformation, then a routing iinformation is selected from a plurality of routing iinformation according to setting routing mechanism, will disappeared
Cease the remote queue being sent in queue management device indicated by the routing iinformation of selection.
Likewise, the secondary route information that the first Application Agent generates includes the connected team of the first Application Agent
Team where remote queue in the mark of remote queue in column manager, the connected queue management device of the first Application Agent
The mark of column manager and the mark of the second Application Agent;First Application Agent secondary route information is written local
Secondary route table in after, when receiving the message for needing to be sent to the second Application Agent, in local secondary route
The routing iinformation of mark of the inquiry comprising the second Application Agent in table, if inquiry obtains a routing iinformation, by message
The remote queue being sent in queue management device indicated by the routing iinformation that inquiry obtains;If inquiry obtains a plurality of routing letter
Breath then selects a routing iinformation according to setting routing mechanism from a plurality of routing iinformation, sends a message to selection
Routing iinformation indicated by remote queue in queue management device.
Routing mechanism therein can include but is not limited to following two:
First, select routing iinformation, such as the first Application Agent according to the according to the instruction of corresponding application program
The instruction of one application program selects routing iinformation, and the second Application Agent selects routing letter according to the instruction of the second application program
Breath;
Second, for Application Agent when carrying out the transmission of message using every routing iinformation, record is from sending a message to
The time interval of the message replied message is received, and Application Agent will record the current state of every routing iinformation
Whether occupied, the following table 1 gives agent2 when carrying out the transmission of message using routing iinformation (QM4, RQ3- > agent1),
One example of the content of record.When there are a plurality of routing iinformation between two Application Agents, according to the more of record
The corresponding time interval of routing iinformation and whether occupied information, a road is selected from a plurality of routing iinformation
By information, for example the smallest routing iinformation of unappropriated and time interval is selected to carry out the transmission of message.
Table 1
It present embodiments provides when being one-to-many relationship between Application Agent and queue management device, application program generation
The establishment process of routing iinformation between reason realizes the routing letter constructed automatically by Application Agent based on message queue
Breath.When routing iinformation, which is established, sends message to another application program with the latter application program, Application Agent is only needed
Know which agent is another application program be associated with, passes through the mark of the agent in the mark table of query and routing of agent
Corresponding remote queue selects a remote queue according to certain routing mechanism when inquiring multiple remote queues,
Then the remote queue is sent a message to, which can be by message queue transmission of network to another application programmatic agent.When
When the agent that the remote queue that one application program is locally defined is directed toward changes, corresponding routing iinformation can be according to variation
Route exploration message that agent afterwards is sent and automatically update, and the build process of message queue network and agency are all transferred to
System manager's operation, so as to so that developer no longer needs to the development that concern queue variation focuses more on business.
Fourth embodiment
Fig. 5 shows the network of the Route establishment system based on message queue of fourth embodiment of the invention offer.Ginseng
See Fig. 5, should Route establishment system based on message queue include: the first Application Agent 51, the second Application Agent 52,
The queue management device that first Application Agent is connected i.e. first queue manager 53 and the second Application Agent are connected
Queue management device, that is, second queue manager 54, in which:
First Application Agent 51, for route exploration message to be sent to the connected team of the first Application Agent 51
Remote queue in column manager 53;
Second Application Agent 52, for from the local in the connected queue management device 54 of the second Application Agent 52
After queue receives the route exploration message, the route exploration message is parsed, according to parsing result determination and is generated to first
First routing iinformation of Application Agent 51, and will be replied message according to first routing iinformation and be sent to the second application program
Act on behalf of the remote queue in 52 connected queue management devices 54;
Wherein, first Application Agent 51 is from the connected queue management device 53 of first Application Agent 51
In local queue read described reply message after, parse this and reply message, be generated to described second according to parsing result and answer
With the secondary route information of programmatic agent 52.
Further, the mark in the route exploration message comprising first Application Agent 51, described first
The mark of the connected queue management device 53 of Application Agent 51, the connected queue management device of first Application Agent 51
The mark of the mark of local queue in 53, remote queue in the connected queue management device 53 of first Application Agent 51
Know;
Correspondingly, second Application Agent 52 is determining according to parsing result and is generated to the first Application Agent
51 the first routing iinformation, and according to first routing iinformation into the connected queue management device 54 of the second Application Agent 52
Remote queue send and reply message method particularly includes:
The connected queue pipe of second Application Agent 52 is determined according to the parsing result of the route exploration message
Manage device 54 in, with the connect queue management device 53 of first Application Agent 51 and first Application Agent 51
Remote queue corresponding to local queue in connected queue management device 53 generates described second according to determining remote queue
Application Agent and sends to reply and disappear to the first routing iinformation of the first Application Agent 51 to determining remote queue
Breath.
Further, it is described reply message in include the second Application Agent 52 mark and first application program
Act on behalf of the mark of the remote queue in 51 connected queue management devices 53;
Correspondingly, first Application Agent 51 is generated to the of the second Application Agent 52 according to parsing result
The specific method is as follows for two routing iinformations:
In the connected queue management device 53 of first Application Agent 51 replied message according to parsing
The mark of remote queue and the mark of second Application Agent 52 generate first Application Agent 51 and arrive institute
State the secondary route information of the second Application Agent 52.
Further, second Application Agent 52 is connect with one or more queue management devices, the first via
It include the mark of queue management device and institute where the mark of the remote queue of the determination, the remote queue of the determination by information
State the mark of the first Application Agent 51;
Second Application Agent 52 is also used to: after generating the first routing iinformation, by the first via by believing
In the first local routing table of breath write-in;When receiving the message for needing to be sent to the first Application Agent 51, in local
The first routing table in inquiry comprising first Application Agent mark routing iinformation, if inquiry obtain one routing
Information then sends the message to the remote queue in queue management device indicated by the routing iinformation that inquiry obtains;If looking into
Inquiry obtains a plurality of routing iinformation, then a routing iinformation is selected from a plurality of routing iinformation according to setting routing mechanism,
Send the message to the remote queue in queue management device indicated by the routing iinformation of selection.
Further, first Application Agent 51 is connect with one or more queue management devices, second tunnel
Include the mark of the remote queue in the connected queue management device 53 of first Application Agent by information, described first answer
The mark of queue management device and described second applies journey where the remote queue in the connected queue management device 53 of programmatic agent
The mark of sequence agency 52;
First Application Agent 51 is also used to: after generating secondary route information, the secondary route being believed
In the local secondary route table of breath write-in;When receiving the message for needing to be sent to the second Application Agent 52, in local
Secondary route table in inquiry comprising second Application Agent mark routing iinformation, if inquiry obtain one routing
Information then sends the message to the remote queue in queue management device indicated by the routing iinformation that inquiry obtains;If looking into
Inquiry obtains a plurality of routing iinformation, then a routing iinformation is selected from a plurality of routing iinformation according to setting routing mechanism,
Send the message to the remote queue in queue management device indicated by the routing iinformation of selection.
Application Agent and its queue management device connected in the present embodiment can be set in same terminal or clothes
It is engaged on device, also can be set on different terminals or server.
The present invention has carried out the automatic foundation of routing iinformation using the reply mechanism of message queue, while to application program screen
The details of queue is covered, so that the application and development based on message queue becomes to be more easier, application program no longer needs to pay close attention to team
The information of column, it is only necessary to be associated with local Application Agent, Application Agent can send a message to opposite end application program
Agency, this scheme is but also application program is not necessarily to pay close attention to the modification of bottom message queue network.
The above description is only a preferred embodiment of the present invention, is not intended to restrict the invention, for those skilled in the art
For, the invention can have various changes and changes.All any modifications made within the spirit and principles of the present invention are equal
Replacement, improvement etc., should all be included in the protection scope of the present invention.