3 namespace Wallabag\ImportBundle\Controller
;
5 use Symfony\Bundle\FrameworkBundle\Controller\Controller
;
6 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route
;
8 class ImportController
extends Controller
11 * @Route("/", name="import")
13 public function importAction()
15 return $this->render('WallabagImportBundle:Import:index.html.twig', [
16 'imports' => $this->get('wallabag_import.chain')->getAll(),
21 * Display how many messages are queue (both in Redis and RabbitMQ).
23 public function checkQueueAction()
25 $nbRedisMessages = null;
26 $nbRabbitMessages = null;
28 if ($this->get('craue_config')->get('import_with_rabbitmq')) {
29 $nbRabbitMessages = $this->getTotalMessageInRabbitQueue('pocket')
30 +
$this->getTotalMessageInRabbitQueue('readability')
31 +
$this->getTotalMessageInRabbitQueue('wallabag_v1')
32 +
$this->getTotalMessageInRabbitQueue('wallabag_v2')
34 } elseif ($this->get('craue_config')->get('import_with_redis')) {
35 $redis = $this->get('wallabag_core.redis.client');
37 $nbRedisMessages = $redis->llen('wallabag.import.pocket')
38 +
$redis->llen('wallabag.import.readability')
39 +
$redis->llen('wallabag.import.wallabag_v1')
40 +
$redis->llen('wallabag.import.wallabag_v2')
44 return $this->render('WallabagImportBundle:Import:check_queue.html.twig', [
45 'nbRedisMessages' => $nbRedisMessages,
46 'nbRabbitMessages' => $nbRabbitMessages,
51 * Count message in RabbitMQ queue.
52 * It get one message without acking it (so it'll stay in the queue)
53 * which will include the total of *other* messages in the queue.
54 * Adding one to that messages will result in the full total message.
56 * @param string $importService The import service related: pocket, readability, wallabag_v1 or wallabag_v2
60 private function getTotalMessageInRabbitQueue($importService)
63 ->get('old_sound_rabbit_mq.import_'.$importService.'_consumer')
65 ->basic_get('wallabag.import.'.$importService);
67 if (null === $message) {
71 return $message->delivery_info
['message_count'] +
1;