diff --git a/app/DoctrineMigrations/Version20160911214952.php b/app/DoctrineMigrations/Version20160911214952.php
new file mode 100644
index 000000000..35809cec6
--- /dev/null
+++ b/app/DoctrineMigrations/Version20160911214952.php
@@ -0,0 +1,42 @@
+container = $container;
+ }
+
+ private function getTable($tableName)
+ {
+ return $this->container->getParameter('database_table_prefix') . $tableName;
+ }
+
+ /**
+ * @param Schema $schema
+ */
+ public function up(Schema $schema)
+ {
+ $this->addSql('INSERT INTO `'.$this->getTable('craue_config_setting').'` (`name`, `value`, `section`) VALUES (\'import_with_redis\', \'0\', \'import\')');
+ $this->addSql('INSERT INTO `'.$this->getTable('craue_config_setting').'` (`name`, `value`, `section`) VALUES (\'import_with_rabbitmq\', \'0\', \'import\')');
+ }
+
+ /**
+ * @param Schema $schema
+ */
+ public function down(Schema $schema)
+ {
+ }
+}
diff --git a/docker-compose.yml b/docker-compose.yml
index a255b0704..27f0f14fd 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -11,6 +11,7 @@ services:
links:
- php:php
command: nginx -c /nginx.conf
+
php:
build:
context: docker/php
@@ -30,6 +31,7 @@ services:
# If all DBMS are commented out, sqlite will be used as default
# - ./docker/postgres/env
# - ./docker/mariadb/env
+
#postgres:
# image: postgres:9
# ports:
@@ -38,6 +40,7 @@ services:
# - ./docker/data/pgsql:/var/lib/postgresql/data
# env_file:
# - ./docker/postgres/env
+
#mariadb:
# image: mariadb:10
# ports:
@@ -46,7 +49,13 @@ services:
# - ./docker/data/mariadb:/var/lib/mysql
# env_file:
# - ./docker/mariadb/env
+
rabbitmq:
image: rabbitmq:3-management
ports:
- "15672:15672"
+
+ rabbitmq:
+ image: redis
+ ports:
+ - "6379:6379"
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
index b70198da6..23938b21c 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
@@ -19,6 +19,8 @@
Materialize.toast('{{ flashMessage|trans }}', 4000);
{% endfor %}
+
+ {{ render(controller("WallabagImportBundle:Import:checkQueue")) }}
{% endblock %}
{% block menu %}
diff --git a/src/Wallabag/ImportBundle/Controller/ImportController.php b/src/Wallabag/ImportBundle/Controller/ImportController.php
index c1486e382..d670746cb 100644
--- a/src/Wallabag/ImportBundle/Controller/ImportController.php
+++ b/src/Wallabag/ImportBundle/Controller/ImportController.php
@@ -16,4 +16,58 @@ class ImportController extends Controller
'imports' => $this->get('wallabag_import.chain')->getAll(),
]);
}
+
+ /**
+ * Display how many messages are queue (both in Redis and RabbitMQ).
+ */
+ public function checkQueueAction()
+ {
+ $nbRedisMessages = null;
+ $nbRabbitMessages = null;
+
+ if ($this->get('craue_config')->get('import_with_rabbitmq')) {
+ $nbRabbitMessages = $this->getTotalMessageInRabbitQueue('pocket')
+ + $this->getTotalMessageInRabbitQueue('readability')
+ + $this->getTotalMessageInRabbitQueue('wallabag_v1')
+ + $this->getTotalMessageInRabbitQueue('wallabag_v2')
+ ;
+ } elseif ($this->get('craue_config')->get('import_with_redis')) {
+ $redis = $this->get('wallabag_core.redis.client');
+
+ $nbRedisMessages = $redis->llen('wallabag.import.pocket')
+ + $redis->llen('wallabag.import.readability')
+ + $redis->llen('wallabag.import.wallabag_v1')
+ + $redis->llen('wallabag.import.wallabag_v2')
+ ;
+ }
+
+ return $this->render('WallabagImportBundle:Import:check_queue.html.twig', [
+ 'nbRedisMessages' => $nbRedisMessages,
+ 'nbRabbitMessages' => $nbRabbitMessages,
+ ]);
+ }
+
+ /**
+ * Count message in RabbitMQ queue.
+ * It get one message without acking it (so it'll stay in the queue)
+ * which will include the total of *other* messages in the queue.
+ * Adding one to that messages will result in the full total message.
+ *
+ * @param string $importService The import service related: pocket, readability, wallabag_v1 or wallabag_v2
+ *
+ * @return int
+ */
+ private function getTotalMessageInRabbitQueue($importService)
+ {
+ $message = $this
+ ->get('old_sound_rabbit_mq.import_'.$importService.'_consumer')
+ ->getChannel()
+ ->basic_get('wallabag.import.'.$importService);
+
+ if (null === $message) {
+ return 0;
+ }
+
+ return $message->delivery_info['message_count'] + 1;
+ }
}
diff --git a/src/Wallabag/ImportBundle/Resources/views/Import/check_queue.html.twig b/src/Wallabag/ImportBundle/Resources/views/Import/check_queue.html.twig
new file mode 100644
index 000000000..7168ea350
--- /dev/null
+++ b/src/Wallabag/ImportBundle/Resources/views/Import/check_queue.html.twig
@@ -0,0 +1,11 @@
+{% if nbRedisMessages > 0 %}
+
+{% endif %}
+
+{% if nbRabbitMessages > 0 %}
+
+{% endif %}