Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. <?php
  2.  
  3. // было
  4.  
  5. list($queue, $connection, $exchange) = amqp_connect(RABBIT_HOST);
  6. amqp_add([
  7. 'action' => $action,
  8. 'server' => RABBIT_HOST,
  9. 'order_type' => $app_type,
  10. 'app_id' => $app_id,
  11. 'bank' => $app['bank_code'],
  12. 'sequence' => 1,
  13. 'starttime' => 0,
  14. 'uniqid' => uniqid()
  15. ], $connection, $exchange);
  16.  
  17. // Счетчик процессов
  18.  
  19. // стало
  20.  
  21. list($queue, $connection, $exchange) = amqp_connect(RABBIT_HOST);
  22.  
  23. // проверка наличия задачи в очереди
  24. $found = false;
  25. while (true) {
  26. if ($envelope = $queue->get()) {
  27. $m = json_decode($envelope->getBody());
  28. if ($m->server == RABBIT_HOST && $m->action == $action && $app['bank_code'] == $m->bank && $app_type == $m->order_type && $app_id == $m->app_id) {
  29. $found = true;
  30. break;
  31. }
  32. $m = null;
  33. } else {
  34. break;
  35. }
  36. }
  37. if ($found) {
  38. $connection->disconnect();
  39. return false;
  40. }
  41.  
  42. amqp_add([
  43. 'action' => $action,
  44. 'server' => RABBIT_HOST,
  45. 'order_type' => $app_type,
  46. 'app_id' => $app_id,
  47. 'bank' => $app['bank_code'],
  48. 'sequence' => 1,
  49. 'starttime' => 0,
  50. 'uniqid' => uniqid()
  51. ], $connection, $exchange);
  52.  
  53. // Счетчик процессов
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement