I ran into the following problem in dynamically creating topics for our ActiveMQ system:
I have a number of processes (M_1, …, M_n), where n is not large, typically 5-10. Some of the processes will listen to the output of others, through a message queue; these edges are specified in an XML file, e.g.
<link from="M1" to="M3"</link>
<link from="M2" to="M4"</link>
<link from="M3" to="M4"</link>
etc. The edges are sparse, so there won’t be many of them. I will parse this XML and store this information in an SQL DB, one table for nodes and another for edges.
Now, I need to dynamically create strings of the form
M1.exe --output_topic=T1
M2.exe --output_topic=T2
M3.exe --input_topic=T1 --output_topic=T3
M4.exe --input_topic=T2 --input_topic=T3
where the tags are sequentially generated. What is the best way to go about querying SQL to obtain these relationships? Are there any tools or other tutorials you can point me to? I’ve never done graps with SQL.
Using SQL is imperative, because we use it for other stuff, too.
Thanks!
Ok, here’s my stab at the problem.
Here’s a sketch of the nodes and edges tables:
Assuming your db has support for CTEs, then a query structured like this will bring together the relationships and concatenate results:
I’m doing this off the bat, so surely a few syntax errors in there. I hope the comments explain the intent.