Permalink
Browse files

unique queues

  • Loading branch information...
1 parent 1e31aad commit 5dc7c4ec719036989edd8bb13b1273ef5d75d991 @rkononov committed Mar 21, 2012
Showing with 14 additions and 9 deletions.
  1. +8 −6 index.php
  2. +3 −1 iw/queueWorker.php
  3. +2 −1 mq/postMessage.php
  4. +1 −1 workers/imageWorker.php
View
@@ -47,13 +47,15 @@
<img src="http://stuntsoftware.com/img/onthejob/icon_onthejob_128.png" alt="">
</div>
-
+ <?php $input_queue_id = "input_queue_" . rand(); ?>
+ <?php $output_queue_id = "output_queue_" . rand(); ?>
<div id="upload-form">
<img src="images/ajax-loader.gif" class="spinner">
<img src="images/step-1-bg.png" alt="" style="margin: 0 auto 10px;clear: both;display: block;height: 99px;">
<h3>Or add url to pic in form below</h3>
<form action="/mq/postMessage.php" id="sendMessageForm">
<input id = "pic_url" type="text" name="url" placeholder="Search..."/>
+ <input type="hidden" name="queue_name" value="<?php echo $input_queue_id; ?>" />
<input type="submit" value="Push to Queue"/>
</form>
<small id="sample-toggler">Or even simply choose one from our robots set</small>
@@ -166,10 +168,10 @@
-->
<script>
- function queue_worker(data) {
+ function queue_worker(data,queue_name) {
var task_id = ''
$.ajaxSetup({async:false});
- $.post('/iw/queueWorker.php', { url:data },function(data) {
+ $.post('/iw/queueWorker.php', { url:data, queue_name:queue_name },function(data) {
task_id = data;
});
return task_id;
@@ -188,9 +190,9 @@ function queue_worker(data) {
});
setInterval(function () {
- $.get('/mq/getMessage.php?queue_name=input_queue', null, function (data) {
+ $.get('/mq/getMessage.php?queue_name=<?php echo $input_queue_id;?>', null, function (data) {
if (data) {
- var task_id = queue_worker(data);
+ var task_id = queue_worker(data,<?php echo $output_queue_id;?>);
var image = '<img src="' + data + '"/><br/>';
var html = '<tr><td>' + image + '</td><td><span id="' +
@@ -206,7 +208,7 @@ function queue_worker(data) {
}
});
- $.get('/mq/getMessage.php?queue_name=output_queue', null, function (data) {
+ $.get('/mq/getMessage.php?queue_name=<?php echo $output_queue_id;?>', null, function (data) {
if (data) {
$('#gears').addClass('moving');
$('#step-3 .spinner').fadeOut(400);
View
@@ -3,6 +3,7 @@
include(__DIR__.'/../lib/IronWorkerWrapper.php');
$config = parse_ini_file(__DIR__.'/../config.ini', true);
$url = $_REQUEST['url'];
+$queue_name = $_REQUEST['queue_name'];
$name = "imageWorker.php";
$tmpdir = $_SERVER['TMP_DIR'];
if (empty($tmpdir)){
@@ -19,7 +20,8 @@
'project_id' => $config['iron_mq']['project_id'],
),
- 'image_url' => $url
+ 'image_url' => $url,
+ 'queue_name' => $queue_name
);
$task_id = $iw->postTask($name, $payload);
View
@@ -1,6 +1,7 @@
<?php
include(__DIR__.'/../lib/IronMQWrapper.php');
$url = $_REQUEST['url'];
-$res = $ironmq->postMessage("input_queue", array("body" => $url));
+$queue_name = $_REQUEST['queue_name'];
+$res = $ironmq->postMessage($queue_name, array("body" => $url));
echo("Message posted");
?>
View
@@ -58,5 +58,5 @@
'token' => $payload->iron_mq->token,
'project_id' => $payload->iron_mq->project_id
));
-$ironmq->postMessage("output_queue", json_encode($links));
+$ironmq->postMessage($payload->queue_name, json_encode($links));
?>

0 comments on commit 5dc7c4e

Please sign in to comment.