fmq 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/fmq +37 -0
- data/default-server/admin-interface/images/logo.png +0 -0
- data/default-server/admin-interface/index.html +240 -0
- data/default-server/admin-interface/prototype.js +4221 -0
- data/default-server/config.yml +66 -0
- data/default-server/queues/my_test.rb +20 -0
- data/lib/fmq/boot.rb +99 -0
- data/lib/fmq/client.rb +43 -0
- data/lib/fmq/mongrel_server.rb +142 -0
- data/lib/fmq/queue_manager.rb +206 -0
- data/lib/fmq/queues/admin.rb +88 -0
- data/lib/fmq/queues/file.rb +54 -0
- data/lib/fmq/queues/linked.rb +92 -0
- data/lib/fmq/queues/load_balanced.rb +87 -0
- data/lib/fmq/queues/syncronized.rb +43 -0
- data/lib/fmq/version.rb +27 -0
- data/lib/fmq.rb +33 -0
- data/setup.rb +1585 -0
- data/test/test_fmq_client.rb +26 -0
- data/test/test_fmq_queue.rb +47 -0
- data/test/test_helper.rb +2 -0
- metadata +77 -0
data/bin/fmq
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby -wKU
|
2
|
+
#
|
3
|
+
# Copyright (c) 2008 Vincent Landgraf
|
4
|
+
#
|
5
|
+
# This file is part of the Free Message Queue.
|
6
|
+
#
|
7
|
+
# Foobar is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# Foobar is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
begin
|
22
|
+
require "fmq"
|
23
|
+
rescue LoadError
|
24
|
+
require "rubygems"
|
25
|
+
require "fmq"
|
26
|
+
end
|
27
|
+
|
28
|
+
if File.basename($0) == "fmq" then
|
29
|
+
if ARGV.size == 0 then
|
30
|
+
FreeMessageQueue::Boot.start_server
|
31
|
+
elsif ARGV.size == 2 && ARGV[0] == "create" then
|
32
|
+
FreeMessageQueue::Boot.create_project(ARGV[1])
|
33
|
+
else
|
34
|
+
puts "usage: #{$0} [create <project_name>]"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
Binary file
|
@@ -0,0 +1,240 @@
|
|
1
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
2
|
+
<head>
|
3
|
+
<title>Free Message Queue</title>
|
4
|
+
<LINK REL="SHORTCUT ICON" HREF="images/logo.png">
|
5
|
+
<script type="text/javascript" src="prototype.js"></script>
|
6
|
+
<script type="text/javascript">
|
7
|
+
var ADMIN_QUEUE_PATH = '/admin/queue';
|
8
|
+
|
9
|
+
function toggle_element (element_id) {
|
10
|
+
$(element_id).disabled = !$(element_id).disabled;
|
11
|
+
}
|
12
|
+
|
13
|
+
function updateSelects() {
|
14
|
+
new Ajax.Request(ADMIN_QUEUE_PATH, {
|
15
|
+
method:'GET',
|
16
|
+
onSuccess: function(transport) {
|
17
|
+
queues = transport.responseText.evalJSON();
|
18
|
+
fillSelectWithQueuePaths("select-message-receive", queues);
|
19
|
+
fillSelectWithQueuePaths("select-message-send", queues);
|
20
|
+
fillTableSpaceWithQueues("queue-table-space", queues);
|
21
|
+
},
|
22
|
+
onFailure: function(transport){ alert(transport.getHeader("Error")) }
|
23
|
+
});
|
24
|
+
}
|
25
|
+
|
26
|
+
function updateTable() {
|
27
|
+
new Ajax.Request(ADMIN_QUEUE_PATH, {
|
28
|
+
method:'GET',
|
29
|
+
onSuccess: function(transport) {
|
30
|
+
queues = transport.responseText.evalJSON();
|
31
|
+
fillTableSpaceWithQueues("queue-table-space", queues);
|
32
|
+
},
|
33
|
+
onFailure: function(transport){ alert(transport.getHeader("Error")) }
|
34
|
+
});
|
35
|
+
}
|
36
|
+
|
37
|
+
function fillTableSpaceWithQueues(table_space, queues) {
|
38
|
+
var table = '<table style="width: 100%; border: 1px solid #292C44">' +
|
39
|
+
'<tr><th>Queue name</th><th>queue size</th><th>messages in queue</th><th>options</th></tr>';
|
40
|
+
|
41
|
+
queues.each ( function (queue) {
|
42
|
+
table += "<tr><td>" + queue[0] + "</td><td>" + queue[1] + "/" + queue[2] +"</td><td>" + queue[3] + "/" +
|
43
|
+
queue[4] +'</td><td><input type="button" value="delete" onClick="deleteQueue(\'' + queue[0] + '\');"/></td></tr>';
|
44
|
+
});
|
45
|
+
|
46
|
+
table += '</table>';
|
47
|
+
|
48
|
+
$(table_space).innerHTML = table;
|
49
|
+
}
|
50
|
+
|
51
|
+
function fillSelectWithQueuePaths(select_id, queues) {
|
52
|
+
// remove all current
|
53
|
+
while ($(select_id).hasChildNodes()) {
|
54
|
+
$(select_id).removeChild($(select_id).lastChild);
|
55
|
+
}
|
56
|
+
|
57
|
+
queues.each ( function (queue) {
|
58
|
+
elem = document.createElement("option");
|
59
|
+
elem.label = elem.value = elem.text = queue[0];
|
60
|
+
$(select_id).appendChild(elem);
|
61
|
+
});
|
62
|
+
}
|
63
|
+
|
64
|
+
function getMessageFromQueue(button_id, select_id, output_id) {
|
65
|
+
new Ajax.Request($(select_id).value, {
|
66
|
+
method:'GET',
|
67
|
+
onLoading: function(transport) {
|
68
|
+
toggle_element(button_id);
|
69
|
+
},
|
70
|
+
onSuccess: function(transport) {
|
71
|
+
if (transport.status == 200) {
|
72
|
+
$(output_id).innerHTML = transport.responseText;
|
73
|
+
updateTable();
|
74
|
+
} else {
|
75
|
+
alert("There is no message in the queue");
|
76
|
+
$(output_id).innerHTML = " == NO MESSAGE IN THE QUEUE ==";
|
77
|
+
}
|
78
|
+
toggle_element(button_id);
|
79
|
+
},
|
80
|
+
onFailure: function(transport){
|
81
|
+
alert(transport.getHeader("Error"));
|
82
|
+
toggle_element(button_id);
|
83
|
+
}
|
84
|
+
});
|
85
|
+
}
|
86
|
+
|
87
|
+
function sendMessageToQueue(button_id, select_id, input_id) {
|
88
|
+
new Ajax.Request($(select_id).value, {
|
89
|
+
method:'POST',
|
90
|
+
postBody: $(input_id).value,
|
91
|
+
onLoading: function(transport) {
|
92
|
+
toggle_element(button_id);
|
93
|
+
},
|
94
|
+
onSuccess: function(transport) {
|
95
|
+
updateTable();
|
96
|
+
toggle_element(button_id);
|
97
|
+
},
|
98
|
+
onFailure: function(transport){
|
99
|
+
alert(transport.getHeader("Error"));
|
100
|
+
toggle_element(button_id);
|
101
|
+
}
|
102
|
+
});
|
103
|
+
}
|
104
|
+
|
105
|
+
function createQueue() {
|
106
|
+
var config = {
|
107
|
+
"path": "/" + $("queue-create-path").value,
|
108
|
+
"max-messages": parseInt($("queue-create-max-messages").value),
|
109
|
+
"max-size": $("queue-create-size").value
|
110
|
+
}
|
111
|
+
|
112
|
+
new Ajax.Request(ADMIN_QUEUE_PATH, {
|
113
|
+
method: 'POST',
|
114
|
+
postBody: "_method=create&data=" + Object.toJSON(config),
|
115
|
+
onSuccess: function(transport) {
|
116
|
+
updateSelects();
|
117
|
+
updateTable();
|
118
|
+
alert("Queue /" + $("queue-create-path").value + " created successfully");
|
119
|
+
},
|
120
|
+
onFailure: function(transport){ alert(transport.getHeader("Error")) }
|
121
|
+
});
|
122
|
+
}
|
123
|
+
|
124
|
+
function deleteQueue(path) {
|
125
|
+
new Ajax.Request(ADMIN_QUEUE_PATH, {
|
126
|
+
method: 'POST',
|
127
|
+
postBody: "_method=delete&path=" + path,
|
128
|
+
onSuccess: function(transport) {
|
129
|
+
updateSelects();
|
130
|
+
updateTable();
|
131
|
+
alert("Queue " + path + " successfully deleted");
|
132
|
+
},
|
133
|
+
onFailure: function(transport){ alert(transport.getHeader("Error")) }
|
134
|
+
});
|
135
|
+
}
|
136
|
+
</script>
|
137
|
+
<style type="text/css" id="test">
|
138
|
+
body {
|
139
|
+
background-color: #687486;
|
140
|
+
font-family: arial;
|
141
|
+
font-size: 1em;
|
142
|
+
}
|
143
|
+
img {
|
144
|
+
border: 0px;
|
145
|
+
}
|
146
|
+
a {
|
147
|
+
color: #C7DAD1;
|
148
|
+
}
|
149
|
+
#container {
|
150
|
+
margin: 10px auto;
|
151
|
+
background-color: #C7DAD1;
|
152
|
+
width: 800px;
|
153
|
+
border: 1px solid #292C44;
|
154
|
+
}
|
155
|
+
#header {
|
156
|
+
background-color: #2F3B4E;
|
157
|
+
padding: 20px 20px 20px 30px;
|
158
|
+
color: #C7DAD1;
|
159
|
+
}
|
160
|
+
#logo {
|
161
|
+
width: 64px;
|
162
|
+
height: 64px;
|
163
|
+
float: right;
|
164
|
+
margin-top: 20px;
|
165
|
+
margin-right: 20px;
|
166
|
+
background-image: url(images/logo.png);
|
167
|
+
}
|
168
|
+
#content {
|
169
|
+
padding: 10px;
|
170
|
+
}
|
171
|
+
#content h1 {
|
172
|
+
font-size: 1.4em;
|
173
|
+
}
|
174
|
+
#footer {
|
175
|
+
color: #C7DAD1;
|
176
|
+
background-color: #2F3B4E;
|
177
|
+
text-align: center;
|
178
|
+
padding: 10px;
|
179
|
+
font-weight: bold;
|
180
|
+
}
|
181
|
+
.block-text {
|
182
|
+
font-family:"Courier New", Courier, monospace;
|
183
|
+
border: 1px dashed #C7DAD1;
|
184
|
+
background-color: #000;
|
185
|
+
color: #C7DAD1;
|
186
|
+
padding: 5px;
|
187
|
+
font-size: 0.8em;
|
188
|
+
}
|
189
|
+
th {
|
190
|
+
text-align: left;
|
191
|
+
background-color: #2F3B4E;
|
192
|
+
color: #C7DAD1;
|
193
|
+
padding: 5px;
|
194
|
+
}
|
195
|
+
td {
|
196
|
+
text-align: center;
|
197
|
+
padding: 5px;
|
198
|
+
}
|
199
|
+
</style>
|
200
|
+
</head>
|
201
|
+
<body onLoad="updateSelects(); updateTable();">
|
202
|
+
<div id="container">
|
203
|
+
<div id="header">
|
204
|
+
<div id="logo"></div>
|
205
|
+
<h1>Free Message Queue - Admin Interface</h1>
|
206
|
+
<h3>the easy http queue system for ruby and all others ...</h3>
|
207
|
+
</div>
|
208
|
+
<div id="content">
|
209
|
+
<!-- LIST QUEUE -->
|
210
|
+
<h1>Queues</h1>
|
211
|
+
<p><div id="queue-table-space"></div></p>
|
212
|
+
<input type="button" value="update" onClick="updateTable();" />
|
213
|
+
|
214
|
+
<!-- CREATE QUEUE -->
|
215
|
+
<h1>Create queue</h1>
|
216
|
+
<p>Queue path: /<input id="queue-create-path" /></p>
|
217
|
+
<p>Maximum messages: <input id="queue-create-max-messages" value="1000000" /></p>
|
218
|
+
<p>Maximum queue size in kb, mb, gb: <input id="queue-create-size" value="100mb" /></p>
|
219
|
+
<input type="button" value="create" onClick="createQueue()" />
|
220
|
+
|
221
|
+
<!-- SEND MESSAGE TO QUEUE -->
|
222
|
+
<h1>Send message to queue</h1>
|
223
|
+
<p>Queue path: <select id="select-message-send"></select></p>
|
224
|
+
<p><textarea id="queue-message-send" class="block-text" style="width: 780px; height: 100px;"></textarea></p>
|
225
|
+
<input id="send-message-queue-button" type="button" value="send"
|
226
|
+
onClick="sendMessageToQueue('send-message-queue-button', 'select-message-send', 'queue-message-send');"/>
|
227
|
+
|
228
|
+
<!-- GET MESSAGE FROM QUEUE -->
|
229
|
+
<h1>Get a message from queue</h1>
|
230
|
+
<p>Queue path: <select id="select-message-receive"></select></p>
|
231
|
+
<pre id="queue-message-get" class="block-text"></pre>
|
232
|
+
<input id="get-message-queue-button" type="button" value="get one"
|
233
|
+
onClick="getMessageFromQueue('get-message-queue-button', 'select-message-receive', 'queue-message-get');"/>
|
234
|
+
</div>
|
235
|
+
<div id="footer">
|
236
|
+
This interface is based on <a href="http://www.prototypejs.org/">prototype</a>
|
237
|
+
</div>
|
238
|
+
</div>
|
239
|
+
</body>
|
240
|
+
</html>
|